Global and local variables in ScriptCase. When creating an application, you sometimes need to use global variables. for example, you can save the user name after logging on to the application, and then use it on every page (for example, when using a set of applications, you sometimes need to use global variables. for example, after logging on successfully, you can save the user name and use it on every page (for example, use the user name to filter data that can be viewed by the user ). At this time, global variables are required.
The global variable of Scriptcase is marked as [varname].
For example, when you log on, you can save the user name you entered to [usr_login] After the verification is passed. it can be used in any application in the system, whether in the code, or in the configuration function.
To display only the data of the current user in a list, you can configure the SQL statement as follows:
SELECT filename1, fieldname2 FROM table1 WHERE login = '[usr_login]'
The system reads the global variable. if logon fails, the system prompts you to log on again.
If you want to define the variables used in the current function, you can simply use $ varname.
For fields, {fieldname} can be used for access. For example, if you want to save the password you set to the database with MD5 encryption, you can write it as follows:
{Password} = md5 ({password });
Another application of braces is the translation of multiple languages. as long as the language tag is defined, it can be used directly in the code, for example:
{Errormessage }={ lang_message_inserterror };
You can set the characters corresponding to different languages in "language settings-regional language" so that the system can support multiple languages.
Using (for example, using...