[WIP] <RetVar/IF> get global variable: name = <Var/String>

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Post Reply
mark_a_condren
Posts: 1385
Joined: Wed, 3. Aug 05, 05:05
x3tc

[WIP] <RetVar/IF> get global variable: name = <Var/String>

Post by mark_a_condren » Thu, 9. Sep 10, 11:15

[skip|else] if [not]|while [not]| <RetVar/IF> = get global variable name = <Var/String>


[skip|else] if [not]|while [not]| = The possible 'Conditional' statements that can be used with this command.
<RetVar/IF> = Command return, with an 'if' statement used it will be TRUE (1) if condition passes or FALSE (0) if it fails, otherwise if you use a 'Variable', this variable will contain a 'pointer' to the information being stored in the global variable.
<Var/String> = The string that was previously set as the name for the information, this can be read in from a text file or entered directly as a string.


Returns the value of a previously set global variable (see: set global variable).
If the global variable was not previously set, then this instruction returns null.
<RetVar/IF> is not the actual data that was saved to the global variable, but rather a 'pointer' to its location in memory. Altering this value does not alter the information it points to. The pointer must be redirected to the altered value for this to take effect.


Examples:

$info.being.stored = get global variable name = 'my_global_variable_name'

This command retrieves the stored information and stores it in $info.being.stored .

-------------------------------------------

if -> get global variable name = 'my_global_variable_name'
| write to logbook = 'This global variable exists'
else if not -> get global variable name = 'my_global_variable_name'
| write to logbook = 'This global variable does not exist'
end

Using the 'Conditional' statement 'if' does not actually retrieve the information being stored, it just checks to see if the global variable <Var/String> exists.

Note:
Another useful command that can be used as a substitute for 'write to logbook' as used in the above example is the command,
display subtitle text: text = <Var/String> duration = <Var/Number> ms

Further resources:
Global Variables by Cycrow.


Command Location:
Last edited by mark_a_condren on Wed, 22. Sep 10, 15:23, edited 1 time in total.

User avatar
s9ilent
Posts: 2011
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Wed, 22. Sep 10, 14:58

Hi Mark, sorry just to correct you on your if statement

Doing an if on the global var is equiv to
$var = get global var....
if $var

So it depends on the value of the global var
If the global var stores the value int(0) or bool(false) (which is actually the same as int(0)) then it will not go into the if statement

mark_a_condren
Posts: 1385
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren » Wed, 22. Sep 10, 15:09

s9ilent

Don't be sorry, thats what i want, any errors pointed out so they can be corrected.

The global and local variable commands i think all still need a lot of work, hence the WIP status.

Thanks for the added info.


EDIT:
Sorry, i thought thats what i said here. Or have i made it a bit ambiguious and hard to understand (written badly is what im saying).
"otherwise if you use a Variable it will be the information returned that was being stored. "


EDIT2:
Made some changes to the <RetVar/IF> information, is this any better now?

Mark

Post Reply

Return to “MSCI Reference”