Examples
Tip |
---|
JavaScript is case sensitive |
...
Symbol/Function
...
Description
...
Example
...
=
...
set equal to
...
#myVar=5;
...
==
...
is equal to
...
if (#myVar==3) #myVar2=8;
...
>=
...
is greater than or equal to
...
if (#myVar>=1) #myVar2=9;
...
>
...
is greater than
...
if (#myVar>4) #myVar2=4;
...
<=
...
is less than or equal to
...
if (#myVar<=20) #myVar2=0;
...
<
...
is less than
...
if (#myVar<10) #myVar2=5;
...
!=
...
is not equal to
...
if (#myVar != 3) #myVar2=0;
...
&&
...
and
...
if (#myVar>3 && #myVar<9) #myVar2=22;
...
||
...
or
...
if (#myVar==3 || #myVar==9) #myVar2=22;
...
null
...
a blank value
...
if (#myVar==null) #myVar2=null;
...
isNull()
...
is null
...
if (isNull(#myVar)) #myVar2=9;
...
!isNull()
...
is not null
...
if (!isNull(#myVar) #myVar2=99;
...
+
...
plus
...
#myVar + #myVar2;
...
-
...
minus
...
#myVar - #myVar2;
...
*
...
times
...
#myVar * #myVar2;
...
/
...
divided by
...
#myVar / #myVar2;
...
//
...
comment (characters following the // are comments)
...
#myVar2=3; // set value of myVar2 equal to 3
...
/*
*/
...
block comment (/* starts the block comment and */ ends the block comment)
...
/*
comments are entered on these lines
code entered here will not be executed
*/
...
Math.pow(a,b)
...
a raised to the b power
...
Math.pow(2,4) outputs 16
...
Math.round(a)
...
integer closes to a
...
Math.round(5.4) outputs 5
...
Math.round(a*10^x)/10^x
...
the value of a rounded to x decimal points
...
[14/3 = 14.66666667]
Math.round(14/3) outputs 5
Math.round(14/3*10)/10 outputs 4.7
Math.round(14/3*100)/100 outputs 4.67
...
Math.abs(a)
...
absolute value of a
...
Math.abs(-5) outputs 5
...
Math.ceil(a)
...
integer closest to a an not greater than a
...
Math.ceil(5.2) outputs 6
...
math.floor(a)
...
interger closest to a and not greater than a
...
Wiki Markup |
---|
h3. Examples
{tip}JavaScript is case sensitive{tip}
Note: #var = #code
\\
|| Function || Description ||
| age(#birth); | Gives the current age where #birth is the data export name for the birth date variable |
| ageAsOf(#birth, #diagnosis); | Gives the age at the date entered for variable #diagnosis |
| st_calculateBmi(true, #hCm, #wKgs); | Calculates BMI with #hCm height in centimeters and #wKgs weight in kilograms. |
| st_calculateBmi(false, #hInch, #wLbs); | Calculates BMI with #hInch height in inches and #wLbs weight in pounds. |
| st_round(#var1, numberOfDecimalPlaces); | Returns the value of var1 rounded to the number of decimal places indicated. |
| st_isBetween(#var1, lowerBound, upperBound); | is less than or equal to |
| \#var1.enable(#var2 == 3); | is less than |
| \#var3.disable(); | is not equal to |
| \#var1.showRow(#var2 == 3); | and |
| \#var3.hideRow(); | or |
| \#var3.showVariableGroup(#var4 == 1); | a blank value |
| if (#bgl < 70) #result.setValue(0); | is null |
| \!isNull() | is not null |
| if (#bgl < 70) #result.setValue(0); | plus |
| if (#sex == 0) {\\
\#var5.style.background='blue';\\
\#var5.style.color='white';\\
} | minus |
| \#var1.style.background = "green"; | times |
| \#var1.style.color = "white"; | divided by | |