Log in

View Full Version : Var in Includes



FrÕzÑ_§ÕµL
03-17-2008, 06:59 AM
If you create a variable at the top of an include, outside of a procedure, and then include that in a script, can the variable be used anywhere? So it becomes a global variable?

Da 0wner
03-17-2008, 07:12 AM
Yes. It will be avaliable for every script you include it in.

Try this.

1. Save this script as TestInclude.scar inside include folder.


Var
GlobalVar : String;


2. Include that on top of this script. ( {.include TestInclude.scar} )


Program Test;
{.include TestInclude.scar}

Begin

GlobalVar := 'Hello World';

Writeln('Global Var from TestInclude.scar = ' + GlobalVar);

End.

FrÕzÑ_§ÕµL
03-17-2008, 07:17 AM
Sweetness thank you ;)

See you can't overwrite a file in use right? So including all scripts into includes, and even seperate includes, means you can change even one line of a script as soon as he user runs it! WOOT!