xboxscene.org forums

Author Topic: Variables In Variable Names  (Read 338 times)

geniusalz

  • Archived User
  • Hero Member
  • *
  • Posts: 1635
Variables In Variable Names
« on: June 01, 2004, 06:10:00 PM »

CODE
Set cursorX 1
Set cursorY 1
Set blah%cursorx%%cursory% success
msgbox %blah{cursorx}{cursory}%


But this works:
CODE
Set cursorX 1
Set blah%cursorx% success
msgbox %blah{cursorx}%


Just to let you know, this caused me lots of grief... back to using XMLs for arrays
Doing minesweeper, by the way.
Logged

BenJeremy

  • Archived User
  • Hero Member
  • *
  • Posts: 5645
Variables In Variable Names
« Reply #1 on: June 01, 2004, 06:48:00 PM »

Hmmmm.... I'll have to take a look at the parser for that.
Logged

koldfuzion

  • Archived User
  • Hero Member
  • *
  • Posts: 1226
Variables In Variable Names
« Reply #2 on: June 01, 2004, 06:53:00 PM »

QUOTE

Set cursorx 1
Set cursory 1
SET XY %cursorx%_%cursory%
SET ARRAY1_1 success
msgbox %ARRAY{XY}%


which would work...dunno if its what you need.. just went by your example.
Logged

BenJeremy

  • Archived User
  • Hero Member
  • *
  • Posts: 5645
Variables In Variable Names
« Reply #3 on: June 01, 2004, 06:58:00 PM »

Actually, it would be bad form to squash two variables together like that....


X=11 and Y=1

or X=1 and Y=11

Given the above, there is no difference in the example.

I would recommend putting an underscore between them.
Logged

koldfuzion

  • Archived User
  • Hero Member
  • *
  • Posts: 1226
Variables In Variable Names
« Reply #4 on: June 01, 2004, 07:02:00 PM »

smile.gif
Logged

BenJeremy

  • Archived User
  • Hero Member
  • *
  • Posts: 5645
Variables In Variable Names
« Reply #5 on: June 01, 2004, 07:12:00 PM »

QUOTE (koldfuzion @ Jun 1 2004, 11:02 PM)
im still an idiot.

updated sample to BJ's recommendation.

Well, it wasn't a direct response to your post, but rather a general observation of good practices. wink.gif
Logged

koldfuzion

  • Archived User
  • Hero Member
  • *
  • Posts: 1226
Variables In Variable Names
« Reply #6 on: June 01, 2004, 07:15:00 PM »

smile.gif
Logged

flattspott

  • Archived User
  • Hero Member
  • *
  • Posts: 1220
Variables In Variable Names
« Reply #7 on: June 01, 2004, 09:03:00 PM »

I ran into a similar issue in the FileManager.
Logged

geniusalz

  • Archived User
  • Hero Member
  • *
  • Posts: 1635
Variables In Variable Names
« Reply #8 on: June 01, 2004, 10:08:00 PM »

tongue.gif (but I will probably have different sizes for difficulty levels)

kf's example would work.  But xml doesn't need an extra line tongue.gif

And I have a superstition xml is faster than just using tons of variables, for a 2d array (non-linear search as opposed to linear search, unless the variable routines do smart searching)

<ignore this>
1
--1
--2
--3
2
--1
--2
--3
3
--1
--2
--3

1_1
1_2
1_3
2_1
2_2
2_3
3_1
3_2
3_3
Logged

geniusalz

  • Archived User
  • Hero Member
  • *
  • Posts: 1635
Variables In Variable Names
« Reply #9 on: June 02, 2004, 07:20:00 AM »

In windows minesweeper, whenever a '0' box (without any adjacent mines) is clicked, a whole area 'opens up', for all adjacent '0' boxes.

Wondering how to do the recursion in script, without using an array as a makeshift stack to keep track of the recursion.  Any ideas?
Logged

geniusalz

  • Archived User
  • Hero Member
  • *
  • Posts: 1635
Variables In Variable Names
« Reply #10 on: June 02, 2004, 06:07:00 PM »

QUOTE
CStdString GetTrueEnvName( LPCTSTR szVar,  TMapStrings * pLocal )
{
...
  iPos = sReturn.Find( _T('{') );
  tcEndChar = _T('}');
   }
   if ( iPos > -1 )
   {
  // OK, find end bracket...
  int iEndPos = sReturn.ReverseFind( tcEndChar );
Logged