Extender function won't compile :-/

Started by Monsieur OUXX, Fri 31/01/2014 12:21:29

Previous topic - Next topic

Monsieur OUXX

This is probably a silly issue -- with some inverted lines of code, or a forgotten "import" or something.
I have a script (it's not the global script).

In the header:

Code: ags

import void AddItem_Safe(ListBox* this,  String item);


In the body:
Code: ags

void AddItem_Safe(ListBox* this,  String item)
{
  this.AddItem(item); 
}

void WrapLine(ListBox* lstBox,  String desc)
{
  String buffer = "";
  lstBox.AddItem_Safe(buffer);
}



Then, when I compile :
Error: '.AddItem_Safe' is not a public member of 'ListBox'
(this error is rasied on the line with lstBox.AddItem_Safe(buffer);

I don't get it. What am I missing?
 

Crimson Wizard

#1
The proper syntax is:
void AddItem_Safe(ListBox this*,  String item) (* asteriks at different place)
Quotevoid AddItem_Safe(this ListBox*,  String item)
http://www.adventuregamestudio.co.uk/wiki/Extender_functions

What you wrote is a normal function which takes a list box object as first parameter.

Khris

#2
The proper syntax is
Code: ags
void AddItem_Safe(this ListBox*,  String item)


Also, this is a pure RTFM fail. Just saying.

Crimson Wizard

lol, right. Incorrectly edited the quote.

Monsieur OUXX

Yep, pure RTFM. I told you it was silly!
The worse part is that I did read the manual page thouroughly, to check if I was putting the function in the right script, and if the import was OK.

Thanks guys.
 

SMF spam blocked by CleanTalk