Home AMX User Forum AMX Technical Discussion
Options

What's wrong with this?!?

Okay - I'm a bit sleep deprived and cannot for the life of me figure out why this won't compile.

This is within a CASE statement, and nothing is before it. If it comment out the assignment, it compiles fine. Clue?! I'm sure it's something obvious - I'm just having a REALLY blah day...
STACK_VAR CHAR Temp[2][10];
STACK_VAR CHAR Status[4][10];
Status[1] = 'SECURE'
Status[2] = 'NOT_READY'
Status[3] = 'TROUBLE'
Status[4] = 'BYPASS'

Comments

  • Options
    mpullinmpullin Posts: 949
    jjames wrote: »
    Okay - I'm a bit sleep deprived and cannot for the life of me figure out why this won't compile.

    This is within a CASE statement, and nothing is before it. If it comment out the assignment, it compiles fine. Clue?! I'm sure it's something obvious - I'm just having a REALLY blah day...
    STACK_VAR CHAR Temp[2][10];
    STACK_VAR CHAR Status[4][10];
    Status[1] = 'SECURE'
    Status[2] = 'NOT_READY'
    Status[3] = 'TROUBLE'
    Status[4] = 'BYPASS'
    
    You mean inside a switch-case? If I'm not mistaken, LOCAL_VAR and STACK_VAR have to be created first thing in the event, before anything else happens. I'd end all those assignment lines with semicolons, just to make sure the interpreter doesn't have any funny thoughts. What error do you get?
  • Options
    jjamesjjames Posts: 2,908
    Here's the whole thing:
    CASE 'SECPOINTSTATE-':
    {
    	STACK_VAR CHAR Temp[2][10];
    	
    	STACK_VAR CHAR Status[4][10];
    	Status[1] = "'SECURE'";
    	Status[2] = "'NOT_READY'";
    	Status[3] = "'TROUBLE'";
    	Status[4] = "'BYPASS'";
    	
    	SPLIT_STRING(DATA.TEXT,',',Temp);
    	
    	FOR(nLOOP1 = 1;nLOOP1<=4;nLOOP1++)
    	{
    		IF(Temp[2] == Status[nLOOP1])
    		{
    			ZoneStatus[ATOI(Temp[1])] = nLOOP1;
    			BREAK;
    		}
    	}
    }
    

    I added double quotes and the ending wink to it . . . still no help.

    The error is the awesome, very descriptive syntax error . . .
  • Options
    jjamesjjames Posts: 2,908
    Strange, I move the assignments to below the SPLIT_STRING and it compiles fine . . . weird. I'll have to look into it more, but for now I'm just happy I got it compiled.

    I hate those kind of "bugs" / "errors" . . . can totally clean your clock.

    Thanks for the help though!
  • Options
    Joe HebertJoe Hebert Posts: 2,159
    jjames wrote: »
    Okay - I'm a bit sleep deprived and cannot for the life of me figure out why this won't compile.

    This is within a CASE statement, and nothing is before it. If it comment out the assignment, it compiles fine. Clue?! I'm sure it's something obvious - I'm just having a REALLY blah day...
    STACK_VAR CHAR Temp[2][10];
    STACK_VAR CHAR Status[4][10];
    Status[1] = 'SECURE'
    Status[2] = 'NOT_READY'
    Status[3] = 'TROUBLE'
    Status[4] = 'BYPASS'
    
    This looks familiar and I'm pretty sure I posted something about this long ago but I don't remember where or when.

    Change this:
    STACK_VAR CHAR Status[4][10];
    

    To this:
    STACK_VAR CHAR Status[4][10]
    

    and then it will compile.

    Or leave the declares as is and add another line of code before the assignment like this:
    STACK_VAR CHAR Temp[2][10];
    STACK_VAR CHAR Status[4][10];
    SEND_STRING 0, 'What the !@#?'
    Status[1] = 'SECURE'
    Status[2] = 'NOT_READY'
    Status[3] = 'TROUBLE'
    Status[4] = 'BYPASS'
    

    and then it will compile

    I thought I had figured out before why the compiler chokes on the semi-colon in an example like yours but my mind is failing me at the moment. Maybe it was just reported as a bug, I don?t know?
  • Options
    Not sure why, but it compiles for me when I put another STACK_VAR declaration below it:
      CASE 'SECPOINTSTATE-':
      {
    	 STACK_VAR CHAR Temp[2][10];
    	 STACK_VAR CHAR Status[4][10];
    	 STACK_VAR INTEGER nTestVariable
    	 
    	 Status[1] = "'SECURE'";
    	 Status[2] = "'NOT_READY'";
    	 Status[3] = "'TROUBLE'";
    	 Status[4] = "'BYPASS'";
      }
    

    --John
  • Options
    I really need to refresh before I post.

    What Joe said.

    :)

    --John
  • Options
    DHawthorneDHawthorne Posts: 4,584
    I've seen this a few times before too ... sometimes if you don't put the semicolon, it takes the next line as part of the declaration, and sometimes if you do it just chokes. There is something wonky in the way it handles array declarations, and it all depends on what follows.
Sign In or Register to comment.