Scripts - Statements and comments
Statements
A MedCalc script is a set of instructions - called statements - to be executed by the program.
- A statement performs a single action.
- Statements are composed of assignments, comments, variables, control structures, commands, expressions, and mathematical operations.
- Statements end with a semicolon.
- Commands, variable names and functions are case-insensitive. In the documentation, we sometimes use uppercase for clarity.
This is an example of an assignment statement:
k=0;
In this example, a workspace variable with the name k is created and the value 0 is assigned to it.
A compound statement, or statement block, is a construct with several simple statements enclosed with braces (curly brackets):
{ k=2; k=k*2; }
Comments
The script can contain comments; this is text that will completely be ignored by the program.
A comment starts with // (two slashes). Any text between the comment marker // and the end of the line are ignored when you run the script.
k=5; // create variable k and assign the value 5 to it
In a string constant, two slashes can be used without indicating a comment.
url="https://www.medcalc.org";