copy fields from cards then retrieve them

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
herbwords
Posts: 70
Joined: Sat Dec 01, 2007 2:59 am

copy fields from cards then retrieve them

Post by herbwords » Sat Jun 04, 2011 7:15 am

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

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: copy fields from cards then retrieve them

Post by Klaus » Sat Jun 04, 2011 12:06 pm

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?
8)


Best

Klaus

herbwords
Posts: 70
Joined: Sat Dec 01, 2007 2:59 am

Re: copy fields from cards then retrieve them

Post by herbwords » Sat Jun 04, 2011 8:42 pm

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: copy fields from cards then retrieve them

Post by BvG » Sat Jun 04, 2011 10:27 pm

one immediate thing i see is that, by default, the itemdelimiter is comma, but you're using tabulators:

set the itemdelimiter to tab
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

herbwords
Posts: 70
Joined: Sat Dec 01, 2007 2:59 am

Re: copy fields from cards then retrieve them

Post by herbwords » Sun Jun 05, 2011 5:21 am

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

Post Reply