Hi,
Can anyone suggest a script that when you close a stack will copy 4 fields from 10 cards and save the data to a tab-delimited text file.
And a script that when you open the stack will retrieve the data from the tab-delimited text file and put it in the 4 fields on the 10 cards.
Thanks,
Patrick
copy fields from cards then retrieve them
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: copy fields from cards then retrieve them
Hi Patrick,
what part exactly makes you problems?
Collecting a couple of field contents into a variable?
Writing a simple text file to disk?
Checking if this text file exists the next time the stack open?
Read this text file into a variable?
Put the content of the variable back into your fields?
Best
Klaus
what part exactly makes you problems?
Collecting a couple of field contents into a variable?
Writing a simple text file to disk?
Checking if this text file exists the next time the stack open?
Read this text file into a variable?
Put the content of the variable back into your fields?

Best
Klaus
Re: copy fields from cards then retrieve them
I'm not getting this, what am I doing wrong?
on openStack
doEditImport
end openStack
on doEditImport
put URL ("file: fileData" & it) into thisRecord
lock messages
lock screen
repeat with x = 3 to the number of cards
go to card x
repeat for each line thisRecord in fileData
if thisRecord is empty then next repeat
put item 1 of thisRecord into field "amount"
put item 2 of thisRecord into field "date"
put item 3 of thisRecord into field "comment"
put item 4 of thisRecord into field "notes"
end repeat
end repeat
unlock screen
end doEditImport
on closeStack
doEditSave
end closeStack
on doEditSave
lock screen
repeat with x = 3 to the number of cards -- (needs to copy fields on cds 3-13 only)
go to card x
put field "amount" of card x & tab \
& field "date" of card x & tab \
& field "comment" of card x & tab \
& field "notes" of card x & return after fileData
put fileData into URL ("file:" & filePathToSave)
end repeat
unlock screen
end doEditSave
Thanks,
Patrick
on openStack
doEditImport
end openStack
on doEditImport
put URL ("file: fileData" & it) into thisRecord
lock messages
lock screen
repeat with x = 3 to the number of cards
go to card x
repeat for each line thisRecord in fileData
if thisRecord is empty then next repeat
put item 1 of thisRecord into field "amount"
put item 2 of thisRecord into field "date"
put item 3 of thisRecord into field "comment"
put item 4 of thisRecord into field "notes"
end repeat
end repeat
unlock screen
end doEditImport
on closeStack
doEditSave
end closeStack
on doEditSave
lock screen
repeat with x = 3 to the number of cards -- (needs to copy fields on cds 3-13 only)
go to card x
put field "amount" of card x & tab \
& field "date" of card x & tab \
& field "comment" of card x & tab \
& field "notes" of card x & return after fileData
put fileData into URL ("file:" & filePathToSave)
end repeat
unlock screen
end doEditSave
Thanks,
Patrick
Re: copy fields from cards then retrieve them
one immediate thing i see is that, by default, the itemdelimiter is comma, but you're using tabulators:
set the itemdelimiter to tab
set the itemdelimiter to tab
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: copy fields from cards then retrieve them
Hi,
I decided to save to a stack instead. I'm not sure which method is better but this is the one I got to work. So thanks for your interest.
Best Regards,
Patrick
I decided to save to a stack instead. I'm not sure which method is better but this is the one I got to work. So thanks for your interest.
Best Regards,
Patrick