storing data in Windows doesn't work

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

storing data in Windows doesn't work

Post by herbwords » Tue Dec 25, 2007 12:40 am

Help!!

I cut pieces of Richard Gaskin's Employee Data Base to get these scripts they work fine in OSX but in XP and Vista the files don't show when I try to import them after saving. If I can remember the name of the file it will import it. Thanks for any suggestions! Here are the scripts:

on mouseUp
doEditExport
end mouseUp

on doEditExport
ask file "Please name the file:" with "Exported Data"
if it is empty then exit to top
put it into filePathToSave
put field "name" of card cFresh & tab \
& field "date" of card cFresh & tab \
& field "batch" of card cFresh & tab \
& field "weight" of card cFresh & tab \
& field "alcohol" of card cFresh & tab \
& field "water" of card cFresh & tab \
& field "fredry" of card cFresh & return after dataToExport
put dataToExport into URL ("file:" & filePathToSave)
end doEditExport



on mouseUp
doEditImport
end mouseUp

on doEditImport
if the platform is "MacOS" then
answer file "Choose a tab-delimited text file to import:" of type "TEXT"
else if the platform is "Win32" then
answer file "Choose a tab-delimited text file to import:" \
with filter "Text File" & return & "*.txt"
answer file "Choose a tab-delimited text file to import:"
end if
if it is empty then exit to top
put URL ("file:" & it) into fileData
put the itemdelimiter into savedDelimiter
set the itemdelimiter to tab
lock messages
lock screen
repeat for each line thisRecord in fileData
if thisRecord is empty then next repeat
put item 1 of thisRecord into field "name"
put item 2 of thisRecord into field "date"
put item 3 of thisRecord into field "batch"
put item 4 of thisRecord into field "weight"
put item 5 of thisRecord into field "alcohol"
put item 6 of thisRecord into field "water"
put item 7 of thisRecord into field "fredry"
unlock messages
unlock screen
end repeat
end doEditImport

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Tue Dec 25, 2007 8:45 am

Hi Herb,

The 'answer file' command has a slightly different syntax, so instead of:

Code: Select all

answer file "Choose a tab-delimited text file to import:" \ 
    with filter "Text File" & return & "*.txt" 
you should use:

Code: Select all

answer file "Choose a tab-delimited text file to import:" \ 
    with filter "Text File,*.txt" 
That being said, you can make your life a little easier if you're using Revolution 2.6 or higher. The following will work cross-platform:

Code: Select all

answer file "Choose a tab-delimited text file to import:" \ 
    with type "Text File|txt|TEXT" 
If applicable you can append 'as sheet' to make it look like a sheet on MacOS X - this won't have any influence if you're running Windows or Linux, but will look better on Mac.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

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

re: saving files in Windows

Post by herbwords » Tue Dec 25, 2007 6:54 pm

Thanks Jan,

I will try this out. I got a little ruthless waiting for a reply and decided since the export button wasn't asking for any specific file type, I'd meke the import file do the same! So I did this and it worked also!

answer file "Choose a tab-delimited text file to import:"-- \
--with filter "Text File" & return & "*.txt"

ah the joys of commenting out --

Thanks again!

Patrick
herbwords.com

Post Reply