-
Notifications
You must be signed in to change notification settings - Fork 1
Variable
Variable is a structure used in PapajScript, that allows storing entities. Variables were introduced on November 8, 2018, along with the release of RPN Calculator 0.4.1.
Up to the version 0.5.0 of RPN Calculator the variables were stored in a simple database, where every variable had its label and value. Since September 2020 the variables engine was rebuilt, adding variables' scopes for functions and global variables. Global variables (available since 0.5.1, their prefix is global.
) are available throughout entire program and they change their values globally, unlike other variables that their values are changed only in a scope of function where it happens.
-
"abc" "xyz" vset
orabc >xyz
orabc ->xyz
orabc -> xyz
orabc -> $xyz
– Move an "abc" to a var "xyz" (note that"xyz"
is a String entity invset
). If the variable does not exist, then create it with this value. -
"xyz" vget
or$xyz
– Put either the var "xyz" or NULL on the stack, depending if the variable exists or not. -
"xyz" vexists
or?xyz
– Return true or false, depending if var "xyz" exists. -
"xyz" vdestroy
or~xyz
– Destroy a variable "xyz" if exists. -
"xyz" vcall
or@@xyz
– If the var is a function, then call it directly.
Notes:
- Calling
xyz
without any prefix or command does the following:- if
xyz
is a function, then call it (act like@@xyz
) - otherwise (if
xyz
is not a function) put the variable on the stack (act like$xyz
) This feature is available since 0.5.0.
- if
- If you are running RPN Calculator 0.5.2 (or newer) with runtime parameters, then all these params are stored in the array variable called
Params
. Note that this variable is an array of strings. - The
->
arrow is available since 0.5.1. - Global variables have
global.
prefix, e.g.global.var
. They are available since 0.5.1. - From 0.4.3 version quotes the variable names must be quoted, if using long syntax (
vset
,vget
,vexists
,vdestroy
andvcall
) functions. It does not apply to short syntax ($var
,>var
,->var
,?var
,~var
,@@var
,var
).
Versions of Papaj:
Pre-builds: Bereshit (v.0.0.1), Shemot (v.0.0.2)
Aleph (v.0.1.0), Bet (v.0.2.0), Gimel (v.0.2.1), Dalet (v.0.3.0)
Hey (v.0.3.1), Vav (v.0.4.0), Zain (v.0.4.1), Chet (v.0.4.2), Tet (v.0.4.3)
Yod (v.0.5.0), Khaf (v.0.5.1), Lamed (v.0.5.2), Mem (v.0.5.3), Nun (v.0.5.4), Samech (v.0.5.5)
Development version: Leviathan
Packages of Papaj:
Vanilla, Array, Console, Date, Math, Number, String
Structures of Papaj:
Conditional, Entity, Loop, Variable
Array, Boolean, DateTime, Exception, LogicalExpression, Function, Number, Null, String
Home, PapajScript, Papaj (interpreter), Papaj REPL