When making an application, sometimes you need to use global variables. For example, after successful login, save the username and then use it in every page (for example, using the username to see what the user can see) filtered data). At this time, global variables need to be used.
The global variable mark of Scriptcase is: [varname].
For example, when logging in, after passing the verification, the user name filled in by the user can be saved in [usr_login], and it can be used in applications in the system in the future, whether in code or in configuration functions.
On a certain list, we may want to display only the current user’s data, then the SQL statement can be configured as:
SELECT filename1, fieldname2 FROM table1 WHERE login='[usr_login]'
The system will read the global variable. If the login fails, the user will be prompted to log in again.
If you are defining a variable used in the current function, you can use $varname directly.
For fields, you can use {fieldname} to access. For example, if we want to encrypt the password set by the user with MD5 and save it to the database, we can write it in the following form:
{password} = md5({password});
Another application of braces is for multi-language translation. As long as the language tag is defined, it can be used directly in the code, such as:
{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.