[comp.sys.mac.hypercard] Writing cards to a text file

kurtzman@pollux.usc.edu (Stephen Kurtzman) (06/10/88)

In article <13394@shemp.CS.UCLA.EDU> ryan@CS.UCLA.EDU (Ryan R. Ramsey) writes:
>The problem is that in order to write the next I actually have to be
>on that physical card. As you can imagine, trying to write 500+ cards takes
>a long time... Is there any way to do this other than the way I do it?

Use container expressions such as 
     "bkgnd field 1 of card i"
Where i is the number of the card.
You don't have to be "on" the card in order to access its data.

dan@Apple.COM (Dan Allen) (06/10/88)

In article <13394@shemp.CS.UCLA.EDU> ryan@CS.UCLA.EDU (Ryan R. Ramsey) writes:
>I just completed a database that contains over 500 records and need a better
>alternative to a subroutine. What I want to do is write all the information
>I have on all of my cards to a file using the open file and write commands.
>The problem is that in order to write the next I actually have to be
>on that physical card. As you can imagine, trying to write 500+ cards takes
>a long time... Is there any way to do this other than the way I do it?

Well, I don't really know how you are doing it, but here is a generic
script that I use to export text from all BACKGROUND fields.  It creates
an ASCII file in the TAB TAB TAB CR type of format.  It also strips all
carriage returns found in fields, leaving CR to be unique as a record
separator.  (Tab is the field separator).

on mouseUp
  put the short name of this stack & ".tx" into defaultName
  ask "Export text to what file?" with defaultName
  if it is empty then exit mouseUp
  put it into fileName
  open file fileName
  go to first card
  repeat for the number of cards
    repeat with i = 1 to the number of fields
      put field i into temp
      repeat
        if return is not in temp then exit repeat
        put space into char offset(return,temp) of temp
      end repeat
      write temp to file fileName
      if i<> the number of fields then
        write tab to file fileName
      else
        write return to file fileName
      end if
    end repeat
    go to next card
  end repeat
  close file fileName
end mouseUp

Hope this helps.

Dan Allen
Apple Computer