Keyword Lines🔗

The second type of line in a GT program is a keyword line. Keywords always start with an asterisk character (i.e "*"). There is only a fixed set of different keywords that you can use. Keywords either act as commands, or modify the behavior of other commands. They tell the program to do something. For example:

*quit

This is a keyword that stops the currently running program file. GT programs can consist of one text file or multiple text files that refer to each other. If this *quit keyword is encountered and your GT program just consists of one program file, that program file will immediately stop running and the GT session will be over. You don't have to type *quit at the end of your program to make it stop running (the program will stop automatically when it reaches the end of your main file), but *quit can be a handy feature in more advanced programs. We'll explain why in more depth later.

Keyword Configurations🔗

attributes, properties, settings

Many keywords have configuration options that can be set. For instance, if you're using a keyword to ask the user a question, you'll need to specify what question you're actually asking. The most important configurations that keywords have are set using a colon (i.e. ":") right after the keyword. Below is a simple example. To ask a question, one uses the question keyword, which is written *question. But, you'll need to make it clear what you want the text of the question to be, so you'll use a colon to configure this. Here's a simple example of a GT program that asks a question.

*question: How are you feeling today, Dracula?

â–¶ Run

When run, this program will simply ask the user "How are you feeling today, Dracula?" and will display a text box where the user has to type their answer. There will also be a submit button which the user will have to click when they are done typing.


Next: