Jojie, Leah, Kiahra & Kahyla wrote:

Hi list.

It's been a while since I've touched programming. I have string that I would like to convert as a variable-name so that I can use that to call a variable with different values on them.

basically this is what it's supposed to do roughly

on beginspite
myVariable = "myVariable" & the spriteNum of me
end

on mouseUP
put myVariable

end


lingo.ini
-- then you have this here
myVariable1 = "dfddf"
myVariable2 = "etc"
myVariable3 = "etc etc"

It looks like the object of the game here is to pass particular values to individual sprites from an external (editable) text file.

Consider using the fileIO xtra, then you can use a regular text file instead of the lingo.ini file.

To get you started, in the message window type:

  put interface(xtra"fileio")

This will give you a somewhat terse description of the commands and their formats.

To use fileIO to read-in the contents of an external file would go something like this:

  FIOobj = new(xtra"fileIO")
  FIOobj.openfile("ExternalFileNameWithAppropriatePathInfo.txt",1)
  gExternalContent = FIOobj.readFile()  -- a global
  FIOobj.closefile()
  FIOobj = void

You now have the text from the external file as a string in the global variable gExternalContent and you can parse it as you please.

(Note: This routine has _no_ error checking. Only use something as bare-bones as this if you have 100% confidence that the external file will be there and in the correct format)

Your text file could then look like:

1 dfddf
2 etc
3 etc etc
5 more stuff
6 and even more stuff and such

or even

dfddf
etc
etc etc

more stuff
and even more stuff and such

Which would make your beginsprite look like this:

 on beginsprite
   the itemdelimiter = numtochar(10)
     -- or 13 depending on the text file*
   myVariable = gExternalContent.item[the spriteNum of me]
 end




* in MX, fileIO seems to be reading text in with linefeeds instead of returns. Did I miss something here? In 8.5 I recall it reading in with returns. Am I delusional? I'm sure I used to be able to use line[x] on text read-in by fileIO.


--

Carl West
mailto:[EMAIL PROTECTED]
http://carl.west.home.comcast.net
----------------------------------
Thinking outside the box - Good
 Pooping outside the box - Bad
[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!]

Reply via email to