use-revolution Digest, Vol 18, Issue 49
Ken Ray
kray at sonsothunder.com
Sun Mar 13 22:53:44 EST 2005
On 3/13/05 1:52 PM, "Cubist at aol.com" <Cubist at aol.com> wrote:
>> 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
If all 5 fields are numbered in sequence, you can do it even faster this
way:
on SaveAll pNumFields,pTextFilePath
put "" into tData
repeat with x = 1 to pNumFields
put fld x & numToChar(1) after tData
end repeat
delete last char of tData
put tData into url("file:" & pTextFilePath)
end SaveAll
It's probably better to use a delimiter like numToChar(1) instead of CR
because each field may already have return-delimited data in it.
Just my 2 cents,
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list