Announcement

Collapse
No announcement yet.

How do I construst a variable?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I construst a variable?

    Hi Everyone,

    Im still pondering how I could construct a variable..

    I'm in a loop...

    WHILE (%i% < %LineCount% AND %spaceCount% < 2)

    I read a line at a time from a file and store it in a temp
    variable..

    %tmpLineVal% = TextFile.GetLine ("%SrcDir%
    \Menu\Games.txt", %i%)

    Then I want to assign the value of %tmpLineVal% to
    a different variable each time we loop, i.e.

    ("Game"+%i%) = Evaluate (%tmpLineVal%)

    Then increase %i% and end while..

    %i% = Evaluate ((%i%+1))

    END WHILE

    Does anyone have any idea how I can get this to work pretty please??? I'm wasting ages thinking about this, please help me!


    %curGame% = Evaluate (("%"+Game+%i%+"%"))

    // This just gives me a values of %Game1%, %Game2% not variables %Game1%, %Game2%.....

    Thanks loads for any of your time..

    Pete

  • #2
    Re: How do I construst a variable?

    You can't "construct" variables on the fly like that. Sorry.

    Comment


    • #3
      Re: How do I construst a variable?

      It's possible, but you can't do it with a Variable.SetValue action.

      You need to use a Text Object to gain recursive evaluation. (No, this isn't documented.)

      Create your variable name by whichever means you want (more on this in a sec), use the TextObject.SetText action to store that string in a Text Object, and then use the TextObject.GetText action to retrieve the evaluated value.

      The Text Object doesn't have to be visible...it can be hidden if you want.

      BTW, an easier way to construct the variable name is to just use this:

      %game%i%%

      You can just use that in the TextObject.SetText action, btw...you don't have to store that string in a variable for this to work.

      Now, all that being said...there are easier ways to accomplish what you want, which is basically a way of storing values in a list. Here are two:

      - store everything in a delimited list. You can use any delimiter you want, just add items together with the delimiter between them, and use the delimited list string actions to retrieve the appropriate item by index.

      - store everything in a Global List. Just add an empty list to your project...then you can add and remove items to and from the Global List at run time. You can even have multiple Global Lists (as many as you want).
      --[[ Indigo Rose Software Developer ]]

      Comment

      Working...
      X