for i in 1..10 do a[i] = 0 endTo facilitate this, the Tab key inserts four spaces within the code editor.
if condition then // statements endor:
if condition then statements else statements endor:
if condition then statements elseif condition then statements; else statements; endNot:
if condition then statements endAnd not:
if condition then statements endThe chosen approach is considered to be better since each part of the if-else statement is written on separate lines of the file. This should make it easier to manipulate the statement, for instance, when moving else clauses around.
for i in set do //statements end
while condition do //statements end
case condition when ABC // statements when DEF // statements else // statements end
do statements; on e as Exception exception statements endor:
do statements; on e as Exception statements on exit statements end
a = (b + c) * dThese rules make the individual components of the statements stand out and enhance readability. It is difficult to give a complete list of the suggested use of white space in Studio code. However, the examples shown above should give a general idea.
In general, the use of comments should be minimized by making the code self-documenting through appropriate name choices and an explicit logical structure.
In an international environment, English is the preferred language.
// Comment spanning // more than one lineSince nested multi-line comments are not supported, using single line comments ensures that it is always possible to comment out entire sections of code for debugging purposes, among others.
while true do // Do something something() endNot:
while true do // Do something something() endThis is to prevent comments from breaking the logical structure of the program.
totalSum = a + b + c +
d + e
function (param1, param2,
param3)
passingText ("Long line split" +
"into two parts.")
Split lines are required when a statement becomes too wide to read comfortably, or exceeds the column limit given above. It is difficult to provide strict rules for how lines should be split, but the examples above can serve to illustrate the guidelines shown below.