Hi, list... :)
I have a simple FileIO and list question...
I made a board game in flash that reads stage data from
the text file... This text file, SymbolsData.txt is formatted
like this...
(Made several lines for your eyes... It really is a one liner...)
TotalSymbols=4&
Symbols=12!21!23!30!34!40!42!44!51!53
~11!13!22!30!31!33!34!41!43!51!53!62
~12!21!23!30!34!40!44!51!52!53
~30!40!21!51!12!42!23!53!34!44
Right now I have four records which goes to 2D array in Flash
after getting rid of those delimiter signs(!, ~)...
The length of the each records may be different from stage to
stage... (I have 10, 12, 10, 10 for now...)
Then, I want to create a little program that does...
1. reads the same data file in Director on the start of the movie
2. parse the data into the form of the list,
3. display the data in graphical format(simple on and off of
5 X 10 matrix)
4. user can have options to navigate the list or add or delete
the record,
5. put the list back into the above format and save the text file.
I did a little bit of search on MM and DOUG and so on... and got
the SAME answer... FileIO... Sounded easy... tried the example
on my machine, and worked great... My first Xtra... :)
Well... what do you know??? Bad thing always happens when you
try to learn something... nothing goes right, right??? :(
I need to omit the displayOpen command on that sample because
I already know what file to open and save... So, I thought that
I could just specify the file name to open... bang!!! What???
'Bad file name' error??? what bad file??? I just don't get it...
What did I do wrong??? I just told you the name of the file to open!!!
Well... sad story... isn't it??? I even tried to pass the parameter
to the handler, and it didn't work either... :(
And... when I opened the text file with the open dialog box and
put the content of the file into the message window, I get
"whatever_the_content_of_the_file"... Why am I getting the double
quotes??? Anyway to get rid of it???
Can someone help me out??? I think I got at least a couple of days
work to go, but I can't even Open a file...
One more question... I didn't go that far yet, but I gotta ask...
How does FileIO read a data from the file??? Byte at a time, line
at a time, or whole data at a time??? What would be the best way
to parse the above form of data into the list and vice versa???
Thanks in advance
Jason
on readFromFile
global myFile
global myVar
if objectP(myFile) then set myFile = 0 -- Delete the instance if it
already exists
set myFile = new(xtra "fileio") -- Create an instance of FileIO
set fileName = "SymbolsData.txt"
if not voidP(filename) and not (filename = EMPTY) then
openFile(myFile, the moviePath & "SymbolsData.txt", 0)
if status(myFile) = 0 then
set theFile = readFile(myFile) -- Read the file into a Lingo
variable
put theFile into myVar -- save the text in a myVar
else
alert error(myfile,status(myfile)) -- display error message
end if
end if
closeFile(myFile) -- Close the file
set myFile = 0 -- Dispose of the instance
end
(Got if from the MM and edited a couple of chars for my amusement...)
:)
_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]