Posted on: 29th May 2019, 9:30 am
Qlik script syntax highlighting is an efficient and useful way for developers to keep track of their script.
Qlik Sense script uses a syntax colour highlighter to identify script keywords. This is very useful for developers to distinguish a field name from a variable name, for example. Effectively, it provides the developer with live feedback of how Qlik reads the script. Allowing developers to spot errors before performing a reload.
Qlik Script Syntax Highlighting
Below is a key to understand the syntax highlighter:
RGB(106, 143, 222)
|Statements / Keywords||In Qlik Sense script, a number of script statements can be utilised. A statement can also be referred to as a keyword. All script keywords can be typed with any combination of lower and upper case characters.||LOAD
RGB(204, 153, 102)
|Field name||Within a LOAD statement, Qlik will represent field names in this colour. Spaces must be escaped with parenthesis.||Field_Name
RGB(142, 71, 125)
|Table name||In Qlik script you can specify a table name prior to a LOAD statement. Spaces must be escaped with parenthesis.||Table_name
RGB(204, 153, 204)
|Variable|| You can create a variable using the SET and LET control statements. A variable is defined by a single word.|
It is not recommended to name a variable identically to a field or a function in Qlik Sense.
RGB(68, 117, 29)
|String literal||String literals are commonly used for defining a variable value or assigning a static value within a Load script. String literals are wrapped in single quotes ( ‘ ).||‘DD/MM/YYYY’
RGB(89, 89, 89)
|Normal text||Normal text can be seen after the SQL keyword, as Qlik does not offer highlighting for third-party languages. Other examples include after the TRACE statement.||This is what normal text, within the script, looks like.|
|Error||Shown immediately at the position of an error detected in the script.||This is what an error looks like in the script.|
|Black with a Red shadow|
RGB(89, 89, 89) RGB(240, 85, 85)
|Post-error||All script following an error will change to this colour until the script has been corrected and valid.||This is what a post-error script looks like.|
RGB(128, 128, 128)
|Comment||It is best practice to comment your script. Comments are shown in grey. There are three methods of commenting; ‘//’, ‘/**/’, REM.||This is what text that has been commented out looks like.|
As always, you can stay up-to-date on the latest Qlik news by following Ometis on Twitter, LinkedIn and YouTube. We’re always keen to hear feedback as well, so please let us know your thoughts on any of the above in the comments below.
By Chris Lofthouse