Page 1 of 1
copy fields from cards then retrieve them
Posted: Sat Jun 04, 2011 7:15 am
by herbwords
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
Re: copy fields from cards then retrieve them
Posted: Sat Jun 04, 2011 12:06 pm
by Klaus
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
Re: copy fields from cards then retrieve them
Posted: Sat Jun 04, 2011 8:42 pm
by herbwords
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
Re: copy fields from cards then retrieve them
Posted: Sat Jun 04, 2011 10:27 pm
by BvG
one immediate thing i see is that, by default, the itemdelimiter is comma, but you're using tabulators:
set the itemdelimiter to tab
Re: copy fields from cards then retrieve them
Posted: Sun Jun 05, 2011 5:21 am
by herbwords
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