Variables in Scriptcase

Hi people,

Now we will see how variables work in Scriptcase.

Local Variables

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

$var1 = ‘local’;

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

Global Variables

It is used with square brackets

[var2] = ‘global’;

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 I create it in the login application, so I can call it in any application of my project.

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, so it should be an OUT variable.
If the application is RECEIVING the variable from another one, so 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

Fields can be called using “curly brackets”.

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

V?tor Jamil

Re: Variables in Scriptcase

Thanks you for this tips. it?s good.

Could you tell me what mean variables POST y GET?
When i can use them?

Re: Variables in Scriptcase

There are two ways the browser client can send information to the web server.

The GET Method
The POST Method
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.

name1=value1&name2=value2&name3=value3
Spaces are removed and replaced with the + character and any other nonalphanumeric characters are replaced with a hexadecimal values. After the information is encoded it is sent to the server.

The GET Method

The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character.

http://www.test.com/index.htm?name1=value1&name2=value2
The GET method produces a long string that appears in your server logs, in the browser’s Location: box.

The GET method is restricted to send upto 1024 characters only.

Never use GET method if you have password or other sensitive information to be sent to the server.

GET can’t be used to send binary data, like images or word documents, to the server.

The data sent by GET method can be accessed using QUERY_STRING environment variable.

The PHP provides $_GET associative array to access all the sent information using GET method.

Try out following example by putting the source code in test.php script.

<?php
if( $_GET[“name”] || $_GET[“age”] )
{
echo "Welcome “. $_GET[‘name’]. “<br />”;
echo “You are “. $_GET[‘age’]. " years old.”;
exit();
}
?>
<html>
<body>
<form action=”<?php $_PHP_SELF ?>” method=“GET”>
Name: <input type=“text” name=“name” />
Age: <input type=“text” name=“age” />
<input type=“submit” />
</form>
</body>
</html>

The POST Method

The POST method transfers information via HTTP headers. The information is encoded as described in case of GET method and put into a header called QUERY_STRING.

The POST method does not have any restriction on data size to be sent.

The POST method can be used to send ASCII as well as binary data.

The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.

The PHP provides $_POST associative array to access all the sent information using GET method.

Try out following example by putting the source code in test.php script.

<?php
if( $_POST[“name”] || $_POST[“age”] )
{
echo "Welcome “. $_POST[‘name’]. “<br />”;
echo “You are “. $_POST[‘age’]. " years old.”;
exit();
}
?>
<html>
<body>
<form action=”<?php $_PHP_SELF ?>” method=“POST”>

Name: <input type=“text” name=“name” />
Age: <input type=“text” name=“age” />

<input type=“submit” />
</form>
</body>
</html>

Re: Variables in Scriptcase

Thank you very much

Re: Variables in Scriptcase

Hi Vitor,
Thanks More Infomative …!

I have a clarification on URL encoding…!
It is converting all name /value joine with equal sign = and convert all spaces to +. if the Values passed in one of name has special character ‘+’ how does it handles…?

I have any issue with document (Filename) where the filename contains ‘+’ symbole and SC unable to Open… and shows [space] instead of [+]

The cause is due to this URL encoding…? If then how do we resolve or any other alternative…?

Thanks
Dhana

Re: Variables in Scriptcase

Its not that hard.Keywords are case sensitive.If you publish for Flash 6 or earlier, then the rest of the language is NOT case sensitive If you publish for Flash 7, then the rest of the language IS case sensitive There are NO bugs and NO inconsistencies. You may be reading documents that apply to earlier versions of flash when it was NOT case sensitive.

Re: Variables in Scriptcase

Hi i am wondering why nothing shows in my global variables page, how can i make this to happen??

Re: Variables in Scriptcase

How must define a global array?

[ myArray[] ]={…}

Is this right? (I don’t think so…)

Thanks !