Skip to main content

Adding subscripts

As your script grows in length, you may find it becoming unwieldy. To address this issue, Studio allows you to call various subscripts from the Main script. Let’s try this out. Let’s take the two sentences we have produced so far and bundle them into their own script.

  1. In the Compose view, click Add New Script (highlighted below). Now, you have a new, blank script to fill in.

    Adding Subscripts 1 (new).png
  2. Hover over the new script, click on the three dots, and select Rename.

  3. Change the script's name from NewScript to TotalSales.

  4. Click Main to go back to the Main script, and cut the text (leave the Monthly Sales heading in place).

  5. Go back to your TotalSales script and paste in the text you cut from Main.

  6. Click Preview.

    Adding Subscripts 2 (new).png

    The result includes the sentences you moved to TotalSales, but not the title, which is still in Main. This is because Preview Mode shows only the output for the currently selected script.

    Note

    If you want even more fine-grained control, you can select just part of the script and click Preview. The output is text generated solely for your selection. This can be handy when you get an error in your script and you are trying to pinpoint precisely what is wrong.

    At this point, we have created the new script, but we still need to call it from Main. To do this, we just put the name of the script in ATL tags ( [[TotalSales]]). You don’t need to type that out, however. You can use the Insert Script button.

  7. Go back to your Main script.

  8. Position your cursor under the heading, then click the Insert Script button, and select TotalSales from the drop-down.

    Adding Subscripts 3 (new).png

    The ATL [[TotalSales]] is now added to your Main script, and if you click Preview from Main, the additional output you see for Main is actually that which is generated by the TotalSales subscript.

Great! So let’s review what we’ve done. In this step of the tutorial, we’ve bundled content into a new subscript and we’ve added a call to it from the Main script. Now let’s create a user-defined function.

Defining new functions