importing a function with enum [solved]

Started by TheMagician, Tue 15/11/2005 20:45:39

Previous topic - Next topic

TheMagician

This might be a stupid question but just a few minutes ago this module header stopped working:

=======================
enum DecisionQuestion {
  eOverwrite, eDelete
};

struct SaveLoad {
  import static function DecisionGUI_Yes (enum);    // <-----this line causes the error
};

=======================

It says "Parse error at enum".

What did I change/forget?
Thanks in advance!

Stefan

Rui 'Trovatore' Pires

Shouldn't there be something after that "enum"?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

DoorKnobHandle

You need to change the line to:

Code: ags

import static function DecisionGUI_Yes (DecisionQuestion);


I am sure that you understand your syntax error now, once you see the "solution". If not, go ahead and ask! :=

TheMagician

#3
@RUI:
Well there could be something after the enum (which would later show up in the autocomplete feature of the script editor) but I think it isn't necessary

@DKH:
Well, now I don't get an error in the header anymore.
But what do I have to write in the script when I define the function for the first time?
Right now I have in my module script:

===
static function SaveLoad::DecisionGUI_Open (    )
===

What do I have to put into the brackets?
If I put in:

static function SaveLoad::DecisionGUI_Open (DecisionQuestion)

it says: parameter doesn't match prototype.

HeirOfNorton

Try static function SaveLoad::DecisionGUI_Open (DecisionQuestion thisDecision)
or somesuch. Bear in mind, enum is not itself a type like int or char, its more like a typedef. The way AGS sees it, DecisionQuestion is the type, and must be used in the header on its own. When the function is defined, you have to use the type (DecisionQuest) AND an instance of the type (like thisDecision), just like how you would have, say:

struct MyStruct {
    function One (int);
}

function MyStruct::One (int thisInt) {
...
}

See what I mean?

HoN

TheMagician

Thanks for your explanation, HeirOfNorton!

I changed the code according to your descriptions and it seems to work perfectly now.
I think I've finally understood the way "enum" works .... at least until I have the next question  ;)

Stefan

monkey0506

And if you include an instance name in the import, it will show up in autocomplete, even though it's not necessary.  This could help if you had a function like:

import int do_something(int, int);

Then you could clarify what the parameters were for by saying like:

import int do_something(int max, int min);

Or some such.

SMF spam blocked by CleanTalk