The BS editor: signature help and formatting
Open a bracket after a function name and the BS editor shows what the call takes, with the argument you're on in bold and, for a function with several forms, each one to page through. Shift+Alt+F tidies the whole script, keeping your comments and your line breaks. Here is what each one does, and when formatting leaves a script alone.

Two more things the BS editor does while you write a Parsware script. Signature help shows the arguments a function takes as soon as you open its bracket, so you don't have to remember their order. Formatting tidies a whole script with one key.
We used the Course plan command button from BS Lang in ten minutes again: a button on the Training Course list, whose script runs when somebody presses it.
Signature help: what a call takes
A command button can open a view with openView. Type the name and an opening bracket:

The hint shows:
- the parameters:
openViewtakes atableand aview, both text; - the one you're typing now, in bold;
- a line saying what the function does.
Type the first argument and a comma, and the bold moves to the next parameter:

The hint stays open while you type an argument, so it's still there when you need to know what comes next. Press Escape to close it. To bring it back inside a call, press Ctrl+Shift+Space.
It works for the host's functions, like openView here, for the methods of a value, such as
lines.join(, and for your own functions.
A function with several forms
In BS Lang, two functions can share a name if they take different arguments. The language picks
the one that matches the call. Here describe has one form that takes hours, and one that takes
hours and a unit:

1/2 means this is the first of two forms. Press the Down arrow, or click the arrows, to see
the other one, describe(hours: int, unit: string). The hint remembers which form you picked while
you type the arguments.
Formatting: a tidy script in one key
Scripts get untidy: pasted from somewhere else, written in a hurry, edited by three people. Here is the Course plan script with the spacing and indenting gone:

The same script, formatted:

What changed:
- Spacing. One space around
=,>=and+=, after:in a type or an object, and after each comma. - Indenting. Everything inside a function, an
ifor a loop is indented one step, and each level inside that one more. - Braces. An opening brace goes on its own line, under the line that opens the block.
What didn't:
- Comments stay. The comment at the top and the one at the end of the
totalline are exactly where they were. - Your line breaks stay. Formatting doesn't join lines or split long ones. The three courses are still on three lines because they were written that way. If you write two statements on one line, they stay on one line, so give each statement its own.
- What the script does. Formatting only changes spaces and line breaks, never the code itself.
Press Ctrl+Z to undo a format, like any other edit.
Signatures worth knowing by sight
Signature help shows every function's parameters as you type, but a handful come up in almost every script, and it helps to recognise their shape:
| Function | Takes | Where |
|---|---|---|
getValue(field) |
A field's logical name | Form rules, buttons, server rules |
setValue(field, value) |
The field, then its new value | Form rules, buttons, plugin steps before a save |
setVisible(field, visible) |
The field, then true or false |
Form rules |
setRequired(field, required) |
The field, then true or false |
Form rules |
openView(table, view) |
A table's logical name, then a view's | Command buttons |
openRecord(table, id) |
A table, then a record's id | Command buttons |
getRecord(table, id) |
A table, then a record's id | Server scripts |
runQuery(query) |
One query document, as an object | Server scripts |
throwValidationError(message) |
The words to show whoever is saving | Plugin steps |
sendEmail(service, message) |
The mail service's name, then an object with to, subject and body |
Server scripts |
Notice the pattern: the thing first, then what to do with it. A field, then its value; a table, then a record. Once that is familiar, signature help is mostly a confirmation rather than a lookup.
Signature help for your own functions
A function you write gets signature help too, and it is only as good as the names you give its parameters. Compare:
func check(a: number, b: number): bool { … } // check(a: number, b: number)
func overLimit(amount: number, limit: number): bool { … } // overLimit(amount: number, limit: number)
The second tells the next person, through the hint, exactly what to pass and in which order, without opening the function. Name parameters for what they hold, and put the types on, because the hint shows both. In a solution script shared by several rules this matters even more: the hint is the documentation most people read.
When to give a function two forms
Two forms of one function are useful when the second simply adds detail to the first, as describe(hours) and
describe(hours, unit) do. They are confusing when the two do different things. A rule of thumb: if you would
explain the two in one sentence, describes a course length, optionally in a unit, one name is right. If you
need two sentences, use two names.
What formatting does to a real script
Before, as it was pasted:
var total=0;
for(course of courses){total+=course.hours;
if(course.hours>=8){lines.push(`${course.name} (full day)`);}}
After Shift+Alt+F:
var total = 0;
for (course of courses)
{
total += course.hours;
if (course.hours >= 8)
{
lines.push(`${course.name} (full day)`);
}
}
Same script, same behaviour, but now the shape of the code shows what is inside what. That is the main reason to format before you ask anybody to read a script: a missing closing brace is obvious in the second version and nearly invisible in the first.
A team habit
When several people work on the same solution, agree on one thing: format before saving. Then every script in the solution has the same layout, a change shows up as a change rather than as a sea of moved spaces, and nobody argues about where braces go, because the formatter has already decided. It takes one key and never changes what the script does.
The keys, together
| Key | Does |
|---|---|
( after a function name |
Opens signature help |
, |
Moves the bold to the next parameter |
| Up, Down | Switch between a function's forms, when it has more than one |
| Ctrl+Shift+Space | Brings signature help back inside a call |
| Escape | Closes it |
| Shift+Alt+F | Formats the whole script |
| Ctrl+Z | Undoes a format, like any edit |
Questions that come up
Does formatting change the script in the solution? Only when you save. Formatting changes the text in the editor; save it, and the formatted version is what the solution stores and exports.
Can I format part of a script? Format works on the whole document. Because it keeps your line breaks and comments, formatting the whole script is safe even when you only touched one function.
Why does signature help say nothing for my field names? A field name is text in quotes, so it has no
signature. The hint is about the function, getValue(field: string), and the field is yours to name.
A broken script is left alone
Formatting needs to read the script, so it only works on a script without syntax errors. Here the
if on line 8 has lost its closing bracket. We pressed Shift+Alt+F and nothing changed:

Fix the error in the problems list first (errors as you type), then format.
This is the behaviour now. When we started this article, the formatter did reformat a broken script. The parser works around a syntax error to keep going, and the formatter then rewrote the whole script from that guess, which can move the error and the lines around it. The editor now checks for syntax errors first and leaves the script exactly as you typed it.
Try it
Open any script in a development environment. Type a host function and ( and watch the hint
follow your arguments. Then remove a few spaces and indents and press Shift+Alt+F.
Next: the helpers panel, and finding a function without leaving the editor.