Skip to main content

Using Code View

Code View is available in all project types and allows you to see the script’s underlying code. It differs from ATL View in that it shows HTML formatting as well as fixed text and ATL. Seeing this representation helps you solve formatting issues as well as ATL syntax errors.

To switch to this view, click the Code View icon in the script editor toolbar.

codeView_codeViewIcon.png

The icon allows you to toggle between Code View and whatever editor view you were in previously (either Marked Up View or ATL View). Re-click the icon to revert to your previous view.

Index

Light Theme and Dark Theme

Code View allows you to switch between Light Theme and Dark Theme.

Click the Change Theme icon to toggle between the themes. Code View uses color markup to highlight HTML formatting, which some users might find more effective in Dark Theme.

codeView_changeLightTheme.gif

Note

Studio remembers the chosen theme when you return to Code View from another view.

Identifying HTML formatting issues

Code View displays HTML formatting elements alongside your fixed text and ATL. This makes it useful for resolving non-obvious formatting problems. For example, here is a common formatting issue:

The script below has unwanted paragraph and line breaks at the end, which are invisible until you switch to Code View.

codeView_deletingHTML.gif

You should delete unnecessary <p> and <br> tags from the end of a script; otherwise, they are included when you call that script in another script (e.g. Main). This can have the the effect of inserting a large amount of unwanted whitespace into the calling script.

Another common problem is when you accidentally copy unwanted or unsupported markup into your script from another source. You can fix this by selecting the entire script and clicking the Clear Formatting button, but that also clears any formatting that you have deliberately applied (e.g. bold or italics). A more precise method is to open Code View and clear specific pieces of HTML markup by editing them out.

Find and replace (Code View)

Code View includes a Find and Replace tool. A similar tool is available in ATL View but that works slightly differently.

The relevant keyboard shortcuts in Code View are:

Operation

Key Combination (Windows)

Key Combination (MAC)

Find

Ctrl + f

⌘ + f

Find next *

Ctrl + g

⌘ + g

Find previous *

Shift + Ctrl + g

Shift + ⌘ + g

Replace

Shift + Ctrl + f

⌘ + ⌥ + f

Replace all

Shift + Ctrl + r

Shift + ⌘ + ⌥ + f

Note

* Find next and Find previous work only after you've entered a find term.

The Replace option is useful when you have renamed an ATL element — e.g. a user-defined function (UDF) — and you want to instantly update all references to that element in a script. The example below finds all references to the Sales UDF and replaces them with Total.

codeView_usingReplace.gif

The search is case-insensitive by default. This is why the search for "Sales" finds the fixed text "sales" along with each reference to Sales (a UDF). The tool works through each found item, and you decide whether to replace by using the YES and NO buttons. Alternatively, you can narrow the search by clicking the CASE SENSITIVE checkbox before entering the find term.

Tip

If you know in advance that you want to replace each found item, use the Replace all option.

Code folding

Another unique feature of Code View is the option to hide and display — i.e. 'fold' — sections of your script. This is useful when your script contains a large amount of code and you want to focus on specific parts.

Code View includes a sidebar with line numbers and corresponding disclosure widgets. To hide or display content, simply click the widgets. In the following example, the user wants to focus on calls to the forAll function.

codeView_coldFolding.gif

Note

Cold folding is not saved. If you fold your code and then exit and re-enter Code View, all script content is displayed.

Bracket matching (Code View)

Code View includes a syntax-highlighting tool to help you identify syntax errors resulting from mismatched brackets.

We describe this tool in detail in the Using ATL View topic, but a brief example of its value is given below. The following ATL block is for a simple conditional. It uses three types of brackets — double square, round, and curly — and contains multiple bracket-matching errors.

codeView_conditionalWithErrors.png

To find the bracket-matching errors, place the cursor next to a bracket. Green markup indicates correct matching, whereas red markup indicates a mismatch. This is shown in the GIF below.

codeView_conditionalCorrected.gif

Important

Be aware that this feature highlights bracket-matching errors only — it does not highlight other syntax errors such as using the wrong bracket type.

Note

The color markup is slightly different for the Dark Theme. Red markup still indicates that there is a problem, but yellow markup (not green) indicates that brackets are matched correctly.

Autocomplete

Code View includes an autocomplete feature to help you work quicker and avoid mistakes when typing variable and function names. There are two ways to invoke the feature:

  1. Type opening double square brackets ( [[ ) to open a new ATL block; or

  2. Use the Ctrl + Space keyboard shortcut.

The resulting pop-up list includes all ATL functions that are (1) available in your selected project type, and (2) supported in the Function Builder. It also includes all variables except those defined in a script. The list automatically filters as you type:

codeView_autocomplete1.gif

You can move up and down the list by using your keyboard's arrow keys. Hit Enter on your keyboard to insert the highlighted item or hit Escape to dismiss the list and just carry on typing as normal. A selected function is inserted with an opening round bracket:

codeView_autocomplete2.gif

You can invoke autocomplete multiple times while writing a single ATL block. In the example directly above, autocomplete is invoked three times. This is done first by typing two opening square brackets to open the ATL block. The next two times — to call totalVal and to insert the LondonSales variable — the Ctrl + Space keyboard shortcut is used instead.

Important

The following functions are not in the autocomplete list: