Saving and entire card?

Stephen Barncard stephenrevolution at barncard.com
Sun Mar 13 17:40:13 EST 2005


I've found that when saving bulk fields in this way  - that a good 
technique to save and be able to recover all of this data is to first 
convert all returns in each field to some otherwise normally unused 
character. I use VT - vertical tab (ascii 11 decimal) as a return 
replacement, following the lead of Filemaker Pro and others for text 
export of fields containing returns.

simply

Replace return with (numToString(11)) in theFieldToConvert


Then after converting each field in turn you could use tabs to 
separate fields and returns to separate records representing each 
card in the output file. Easy to debug, because any unconverted 
returns can be seen in a good text editor set to not wrap. The VT's 
would be changed back to returns when re-loaded into fields. This 
gives you  a Filemaker-Ready tab delimited file that can be easily 
imported anywhere.

A reminder; if this information you are saving is to be used by only 
RunRev gadgets you build, it would make far more sense to set and 
save custom properties in a Rev stack that your scripts can use for 
such information, rather than using a fixed text file order method.

You'll always find more things to store when developing a project and 
when one is using a fixed list storage system one always has to put 
new items on the end to allow backward compatible expansion. Also 
that kind of storage system is not self-describing as a custom 
property would be.

And if your app needs to create documents for the outside world in 
the future, you might also consider XML.

>  >From: Kevin J <kj2005.28 at gmail.com>
>  >Subject: Saveing and entire card?
>  >
>>Say you have 5 text fields on one card is it possible to have them all
>>save to one file that the user names?
>    Eminently so. The basic idea is that you collect up all five fields into
>one variable, and you save that variable to disc. Here's a very simple handler
>which needs to be told where you want to save the variable to:
>
>on SaveAllFiveTo MyTextFile
>   put fld "first bit of text" into Fred
>   put return & return & fld "second bit of text" after Fred
>   put return & return & fld "third bit of text" after Fred
>   put return & return & fld "fourth bit of text" after Fred
>   put return & return & fld "fifth bit of text" after Fred
>
>   open file MyTextFile
>   write Fred to file MyTextFile
>   close file MyTextFile
>end SaveAllFiveTo
>
>    This is strictly off the top of my head, but it should serve to
>demonstrate the basic principle. Hope this helps...


More information about the use-livecode mailing list