getVar
Reads the current value of an App Var predefined at the app level in the LucyStudio designer.
Parameters
appVarName(string): a variable name predefined in the LucyStudio app settings
Returns
any — the current value of the variable. Returns null if the variable name is not defined
Description
$app.getVar reads the value of a variable predefined at the app level in the LucyStudio designer. Internally it calls LucyVarMngr.getVarValue(appVarMap, appVarName).
The value is shared across the whole app, so you can read it with the same variable name from any Form or Page.
⚠️ The variable name must be predefined in the LucyStudio designer. An undefined variable name returns
null.
$app vs $form vs $page comparison
| Item | $app.getVar | $form.getVar |
|---|---|---|
| Scope | Shared across the app | Current Form instance |
| Where it's predefined | LucyStudio app settings | LucyStudio form settings |
| Lifecycle | Kept while the app runs | Destroyed when the Form closes |
| Access from another Form | ✅ Yes | ❌ No |
Example
// Read an App Var
var userId = $app.getVar("loginUserId");
$log.i("로그인 사용자:", userId);
var theme = $app.getVar("theme");
if (theme === "dark") {
// Handle dark mode
$log.i("다크 모드 활성화");
}
// An undefined variable returns null
var unknown = $app.getVar("notDefined");
$log.i("미정의 변수:", unknown); // null
Related
$app.setVar(appVarName, data)— set an App Var$app.clearVar(appVarName)— reset an App Var to its initial value$form.getVar(localVarName)— read a Form-level variable (valid only in that Form)$app.getSharedData(key)— read in-memory data under any key you like (no predefinition needed)