Correct syntax fpr appending data

Klaus Major klaus at major-k.de
Mon Mar 6 14:03:51 EST 2006


Hi Ben,

> What is the correct syntax for Rev to append data to the next line  
> in a text file?
>
> I have a quiz in a standalone, and when the participant finishes,  
> the file needs to save.  the next particpant's scores should go on  
> the next line.  I use a button at the end of the quiz:
>
>
> on mouseUp
>
> set itemDelimiter to tab
>
> put fld "quiz_item1" into item 1 of line 1 of field "data field" of  
> stack "data sample"
>
> put fld "quiz_item2" into item 2 of line 1 of field "data field" of  
> stack "data sample"
>
> put fld "data field " into url "file:test data.txt"

## OK so far :-)

> ##get url "file:test data.txt"

## But now you could use this lines to check if the saving was  
successful:
if the result = empty then ## Success
     put "File saved successfully!" into fld "sample field that  
proves to me something is going to the test data file"
else ## NO success
     put "Error while saving to disk!" into fld "sample field that  
proves to me something is going to the test data file"
end if
	
> ##save url "file:test data.txt"
## Does not work! Wrong Syntax!

> end mouseUp
>
> 1) So how do I get the next person's data to enter the next line  
> and save, without over writing the previous person's data?

put CR & the_new_data_2_save AFTER url "file:test data.txt"
## Puts a RETURN (= new line) and the new data AFTER that file.  
That's it.

> 2) Do you see flaws in this approach?

No should work fine.

> My frustration with the Rev docs disappears when I use this support  
> forum.  Thanks, as always, for the help.
>
> Ben

Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de




More information about the use-livecode mailing list