The BS editor: errors as you type
The BS editor checks a script while you write it. A mistake is underlined within half a second, hovering says what is wrong, and a problems list under the script counts every error, jumps to each one and copies them all as text. Here is what it catches, and what it can't.

Every script in Parsware is written in the same editor, the BS editor: a form rule, a command button, a plugin step, a Custom API, a step in a process, a binding on a Studio screen. It checks the script while you type, so most errors show up as soon as you've written them.
This article covers the errors part: the red underline, the message behind it, and the problems list under the script. We used the Course plan button from BS Lang in ten minutes, and broke its script on purpose.
Two mistakes, found before saving
We made two changes to the script. On line 21 the call to describe lost its last letter. On
line 24 we built the message with + instead of a template, which BS Lang refuses (see
BS Lang in ten minutes):

About half a second after you stop typing, the editor checks the whole script. It doesn't check on every key, because then every half-typed name would be underlined as unknown and you'd soon learn to ignore the red.
Each mistake gets a red underline, and a red mark in the strip on the right edge, so you can see where the errors are in a long script without scrolling.
Hover to read the message
Point at an underline and the editor says what is wrong:

The code in brackets, E030, is the language's own number for this error. It stays the same when the wording changes, so it's the thing to search for. Alt+F8 moves to the next problem without the mouse.
The problems list
A hover only helps if you already suspect a line. The problems list under the script doesn't wait to be asked. It says how many errors there are and, for each one:
- where it is, as line and column (
21:33is line 21, column 33); - what is wrong, in the same words as the hover;
- its code, on the right.
Click a problem to go to it. The caret lands on that line and column, and the editor scrolls to it:

Copy puts the whole list on the clipboard as plain text, one problem per line, with its line, column and code:
21:33 Function describ not found. [E030]
24:8 Only numbers or strings are allowed in this expression. [E0163]
That's the form to paste into a message to a colleague or a support request: nobody has to retype it from a screenshot, and the code stays searchable.
When the last error is fixed, the list disappears. There's no "0 problems" bar. If you see no list, the script passed.
Two kinds of error
The editor finds two kinds of mistake, and they read differently.
Syntax errors mean the script can't be read at all: a bracket missing, a semicolon in the wrong place. Their messages come from the parser and say what it expected:

"mismatched input ';' expecting {',', ')'}" means: I found a ;, and I wanted a comma or a
closing bracket. The call to notify was never closed. One missing bracket can produce several
syntax errors further down, because the parser loses its place. Fix the first one, and the rest
usually go with it.
Meaning errors are found once the script can be read: a function that doesn't exist, text
added to a number with +, a call with the wrong number of arguments. They carry an E code, like
the two above.
The check knows where the script runs
Different scripts can call different functions. A form rule can call setVisible, because it has
a form in front of it. A plugin step can't, because it runs on the server with no form. The editor
checks each script against the functions its host offers. So setVisible is fine in a form
rule, but in a plugin step it's reported as Function setVisible not found, before you save,
rather than when it runs.
The same goes for a script that imports a solution script: the check reads the imported script, so a call to one of its functions is accepted, and a misspelt one is not.
What the list doesn't do
- It doesn't stop you saving. A script with problems can still be saved. The list is there so you know before you do; read it before pressing Save.
- It can't know your data. A misspelt field name inside quotes,
getValue('par_amont'), is valid text, so it isn't underlined. It fails when the script runs. The completion article shows where the editor can help with names. - One-line fields have no list. A binding on a Studio screen is one line in a narrow panel, with no room for a list. The underline and its hover carry the message there.
The errors you will meet most
Most of what the editor reports is one of a dozen messages. Knowing them by sight saves reading each one twice. (The code in the list can carry an extra digit at the end, such as E0163, which narrows down where in the checker it was found; the first three digits are the error.)
| Code | Message | Usually means | The fix |
|---|---|---|---|
| E030 | Function name not found | A misspelt function, or one this place doesn't offer | Check the spelling, or the helpers panel for this host |
| E016 | Only numbers or strings are allowed in this expression | Text and a number joined with + |
Use a template: `Total: ${total}` |
| E015 | Only numbers are allowed in this expression | Arithmetic on text, such as '5' * 2 |
Make sure the value is a number first |
| E012 | Expected n arguments, got m | A function called with too few or too many values | Signature help shows what it takes |
| E023 | Type mismatch | A value of the wrong kind, such as a decimal into a whole-number variable | Start the variable with the right kind, such as 0.0 |
| E004 | Duplicate variable name | The same var twice in one block |
Drop the second var, or give it another name |
| E006 | name not found in module path | An imported function the solution script doesn't export | Export it, or fix the name |
| E042 | Module not found path | An import naming a solution script that doesn't exist |
Check the module path on the Scripts list |
| E046, E050 | Index out of range | Reading past the end of a list | Check length() first |
| E059 | An array does not grow by assignment | Writing to list[5] on a list of three |
Use push(value) |
| E047 | Object member name not found | A member an object doesn't have | Check the name, or that the object isn't empty |
The last four are often found only when the script runs, because whether a list has six items or an object a member depends on the data. The editor catches what can be known from the script alone.
Reading a syntax error
Syntax errors are the ones whose messages come from the parser, and they always say what it found and what it wanted. Three patterns cover most of them:
mismatched input ';' expecting {',', ')'} -> a bracket was opened and never closed
extraneous input '}' expecting ... -> one closing bracket too many
missing ';' at 'var' -> the line before ended without a semicolon
The line and column point at where the parser noticed, which is often just after the real mistake. If line 24 is reported and looks fine, look at the end of line 23.
Habits that keep the list short
- Write a little, then pause. The editor checks half a second after you stop. A pause after each statement tells you about that statement while you still remember what you meant.
- Fix the first problem first. Later problems are often caused by an earlier one, particularly after a syntax error.
- Let completion type names. A function picked from the completion list can't be misspelt. The BS editor: completion shows it.
- Read the list before every save. Saving is allowed with problems, so that you can save half-finished work, but a script saved with a red line in it will fail where that line is.
- Copy the list when you ask for help. The plain-text form with codes is easier for a colleague than a screenshot, and the codes can be searched.
Mistakes the editor can't see
The checker reads the script, not your data, so some mistakes are only found when the script runs.
- A misspelt field name in quotes,
getValue('par_amont'), is valid text. It reads as empty when the script runs, so a rule quietly does nothing. Copy field names from the table's Fields page, or from completion where it offers them. - A record that isn't there.
getRecordreturns nothing for an id that doesn't exist, or one the person may not read. Check withisEmptybefore using what came back. - A value that is empty. A field with no value arrives as an empty string in most scripts, and adding it to a number fails. What a script can see explains how values arrive.
For these, the best check is to run the script once with real data in a development environment, as the Try it below does, before relying on it.
A gap we found and fixed
Writing this article, the misspelt describ at first wasn't reported. Only the + on line 24
was. The cause was in the checker: when it read the describe function, the function's return
stayed switched on after the function ended. Every block after that, like the for loop, was
then checked only as far as its first line. So a mistake on the second line of the loop was
missed.
It's fixed. The checker now reads each function's return only inside that function, and a test
with this exact script makes sure it stays fixed. If a script you wrote earlier suddenly shows a
problem it didn't show before, this is why: the problem was always there.
Try it
Open any script in a development environment and misspell a function name. Wait half a second, hover the underline, then click the problem in the list. Fix it and watch the list go.
Next: the BS editor's completion, which offers names as you type.