My #define's gone broken??

Started by Ishmael, Sat 06/12/2003 20:31:08

Previous topic - Next topic

Ishmael

Version 2.55

I had some defines in the script header:

#define DIALOG 1;
#define LIST 2;
#define OK 3;
#define CANCEL 4;

[Using modified BlueGUI save/load scripts, credit to Rick]

and the functions have if's:

...
if (state == DIALOG) {
blah blah balh...
}
if (state == LIST) {
blah blah blah...
}

etc.

When I tried to complile, it game me error:

... Problem in "Main Script"
(Line blah) Error in expr near '1'
etc.

I changed the "DIALOG" in the if to "1", and the script was compliled.

I had call for the fucntion in interface_click:

if (button == 2) {
Load(DIALOG);
}

It gave the same error on the Load()-call line.

I changed the "DIALOG" to "1", and it worked aswel. The same for all #defined using functions. I can't use the #defines! Argh!

And, the same comes up with v2.56d. Are my game files somehow corrupted, or what is it? I'd like to know if someone knows this problem or even knows how to fix it.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Scorpiorus

Hey, TK the define directive works the way that it just replace the macro identifier with appropriate string, so:

#define DIALOG 1;

turns out into:

if (button == 2) {
Load(1;); // originally was Load(DIALOG);
}

~Cheers


After

That goes for the whole line, so don't put a comment on the same line either.

Ishmael

I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Kweepa

Also, watch out for tabs between #define and the symbol. Use spaces instead.
Still waiting for Purity of the Surf II

Ishmael

My tabs with MRC room names worked just fine...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

After

Quote from: SteveMcCrea on Sun 07/12/2003 12:42:07
Also, watch out for tabs between #define and the symbol. Use spaces instead.
Same between symbol and definition. Use spaces if you want them nicely aligned.

SMF spam blocked by CleanTalk