Jump to content


Photo

Variables In Variable Names


  • Please log in to reply
10 replies to this topic

#1 geniusalz

geniusalz

    Team MXM

  • Head Moderators
  • PipPipPipPipPip
  • 1,827 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 02 June 2004 - 01:10 AM

This doesn't seem to work:
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.

#2 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 02 June 2004 - 01:48 AM

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

#3 koldfuzion

koldfuzion

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,480 posts

Posted 02 June 2004 - 01:53 AM

you could also use

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.

Edited by koldfuzion, 02 June 2004 - 02:07 AM.


#4 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 02 June 2004 - 01:58 AM

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.

#5 koldfuzion

koldfuzion

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,480 posts

Posted 02 June 2004 - 02:02 AM

im still an idiot.

updated sample to BJ's recommendation.


i can see that posing a problem with his code if the mine is set at "position" 11

not impossible to work around thoough.. would just have to do some string functions instead of IF# mine == 11


edit 4,222 : but not if the mine was set at position 1_1... still, a string comparison though. smile.gif

Edited by koldfuzion, 02 June 2004 - 02:14 AM.


#6 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 02 June 2004 - 02:12 AM

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

#7 koldfuzion

koldfuzion

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,480 posts

Posted 02 June 2004 - 02:15 AM

i didnt really think that far ahead. just tried to find somethng that worked.

but thats why you are in the drivers seat and the rest of us are chasing the car. smile.gif

#8 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 02 June 2004 - 04:03 AM

I ran into a similar issue in the FileManager.

#9 geniusalz

geniusalz

    Team MXM

  • Head Moderators
  • PipPipPipPipPip
  • 1,827 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 02 June 2004 - 05:08 AM

I see what you mean about bad form, but by chance, I guess, I have a 10x10 board 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

#10 geniusalz

geniusalz

    Team MXM

  • Head Moderators
  • PipPipPipPipPip
  • 1,827 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 02 June 2004 - 02:20 PM

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?

#11 geniusalz

geniusalz

    Team MXM

  • Head Moderators
  • PipPipPipPipPip
  • 1,827 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:unknown

Posted 03 June 2004 - 01:07 AM

Third post.. oh well

Think it's this:

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 );





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users