loading an array from an external text file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
loading an array from an external text file
I have figured out (thanks to a search of these forums) how to save a combined array to a text file. Now, I need to know how to make an "open" dialog box pop up, and how to read the data in a chosen text file and put it back into a variable for splitting. any help would be greatly appreciated
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
This can be as simple as
HTH,
Jan Schenkel.
Code: Select all
on mouseUp
local tFilePath, tData, tLine, tItem
local tArray, tRowCounter, tColumnCounter
answer file "Open tab-delimited text file"
if it is empty then exit mouseUp
put it into tFilePath
put URL ("file:" & tFilePath) into tData
put 0 into tRowCounter
set the itemDelimiter to tab
repeat for each line tLine in tData
add 1 to tRowCounter
put 0 into tColumnCounter
repeat for each item tItem in tLine
add 1 to tColumnCounter
put tItem into tArray[tRowCounter,tColumnCounter]
end repeat
end repeat
end mouseUp
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- VIP Livecode Opensource Backer
- Posts: 10050
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Stacks are files too, and natively support arrays in custom properties.
You can save yourself some parsing time by just using stack files for you file format:
set the customProperties of tMyDataStack to MyArray
put the customProperties o tMyDataStack into tMyArray
You can save yourself some parsing time by just using stack files for you file format:
set the customProperties of tMyDataStack to MyArray
put the customProperties o tMyDataStack into tMyArray
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn