Page 1 of 1

more question

Posted: Wed Aug 01, 2012 5:09 am
by enric
Sorry Pip I've more question :oops:

I'm trying to make a library with several functions.

1) is there a way to compile a ready library so you can include compiled?.

2) to make some function independent, is there a way to pass a pointer as a parameter?

Re: more question

Posted: Wed Aug 01, 2012 2:48 pm
by pipfromslitherine
I'm not sure what you mean. The scripting system doesn't include libraries - if you mean a collection of function that you want to use over and over then just create a BSF with them in, and you can then include it at the top of anywhere you want to use it

include "somefile.bsf"

the scripting system doesn't have any concept of pointers. What are you trying to achieve?

Cheers

Pip

Re: more question

Posted: Wed Aug 01, 2012 4:28 pm
by enric
  • 1) A library of functions like the already used but already compiled, to avoid BA compile every time it uses, or maybe it is always interpreted?
    exemples:
    include "functions.BSF"
    include "tools.BSF"
    include "myFuntions.BSF"
  • 2) A pointer to a variable as way to change its value without knowing about it.
    Now, you're obliged to process the returned value, and only one value can be returned.
    Imagine I've a global gMyGlobal (or a local).
    I would call a functions passing the actual value of gMyGlobal and the function will attempt to change it.


    The call:
    int i;
    i = MyFunction (gMyGlobal, others,…);
    SetGlobal ("gMyGlobal", i);


    FUNCTION MyFuntion (theValue, others, etc.)
    {
    // do some job
    theValue += 1; // or anything else
    return theValue;
    }

Re: more question

Posted: Wed Aug 01, 2012 5:20 pm
by pipfromslitherine
1 - BA parses scripts each time it runs. There is pretty much no real cost to it, it is very quick. Just put functions in a bsf and include them.

2 - there isn't any way to do this currently. It is definitely a restriction in the language (hence the GetUnitX and GetUnitY functions). I have language improvements on my todo list, but there is a ton of other stuff too :(.

Cheers

Pip