Open topic with navigation

VARIABLES IN SCRIPTCASE

Dependent Applications Concepts.

ScriptCase considers dependent applications those applications (Form or Grid) that need to receive external parameters (variables) passed by Get or Post HTML methods.

To build a Dependent Grid specify which parameters receive external values by using square brackets [ ] to indicate a "global variable" on the WHERE or HAVING clause. For example:

SELECT field1,field2 FROM table_duplicates WHERE cod_client = [glo_clientid]

Scriptcase uses variables in any application event or method. There are Local Variable and Gobal variables:


Local Variables

It should be used as a common PHP variable (beginning with $).

$var1 = 'local';

It is used in only in an event or method. Its scope ends at the end of the event.
If it is being used in onLoad event it will be used just in that event.


Global Variables

Before the browser sends the information, it encodes it using a scheme called URL encoding. In this scheme, name/value pairs are joined with equal signs and different pairs are separated by the ampersand.

Scriptcase uses global variables with square brackets.

[var2] = 'global';

It can be called in any event or method of an application.


Note 1: A local variable can be a global variable if you use sc_set_global
$var3 = 'testing';                          // var3 is a local variable
sc_set_global($var3);                    // transforming var3 in a global variable
echo [var3] ." global variables";       // Now we can call [var3] in any other event


Session Variables

It is used like a global variable (with square brackets)

[var4] = 'session';

But you must access "Application>>Global Variables" to set var4 to be "SESSION".

Session variables can be called in any event of any application.
If created it in the login application it can be called it in any project application.


Note 2: Accessing "Application>>Global Variables" you can define if a global/session variable is IN or OUT variable.
If the application is CREATING the variable, it should be an OUT variable.
If the application is RECEIVING the variable from another one, it should be an IN variable. (IN is default)


Note 3: Global and Session variables can be reseted using sc_reset_global macro.
sc_reset_global ([var3],[var4]);

Fields Variables

Field values can be called in an event using "curly brackets". 

{field_x} = 'field_x receive this value';
{field_y} = [var3];
{field_z} = {field_y};