Comments

Home, Up: Scripts

 

On this page:

Comment Lines, Comments in Scripts, In-Command Comments, Overview.

 

Comment Lines

This page makes references to loops, which will be discussed in the next chapter.

Comments can have two purposes: documentation, or information for a script's user.

A comment line, that is a line that begins with the hash sign #, can be included in script files and in insert files (which usually will be data files).

In an insert file, comment lines will always be ignored by Hypatia -- you will only see them when you open the file with an editor.

 

Comments in Scripts

In a script file, a comment line will be displayed when the script is called directly, but not when it is called in a loop (unless echo mode is on).

Comment lines that begin with #: (instead of #) will also be displayed in loops. (The colon will not be displayed.)

A comment line that begins with double hash signs ## will never be displayed, except with echo mode on.

For documentation purposes in scripts you can add a comment at the end of any command or calculation line, preceded by a space and double hash signs ##. These comments will never be displayed, not even in echo mode.

Comment lines get displayed with upper and lower case characters as they were written.

 

Comments (that is, text beginning with the hash sign #) following I1:, I*:, THEN, ALSO: and ELSE: will always be displayed when those conditions are met.

 

Comment lines that begin with #: will also be written to the log file hy.log when logging mode is on. Comment lines that begin with # will not be written to the log file (this also applies to comments following I1:, I*:, IF ... THEN, ALSO: and ELSE:).

 

#: without any further text will display a blank line.

 

In-Command Comments

The commands SAVE, SAVE@ and BUFFER SAVE let you add an optional comment after the file name.

Anything after the file name is a comment, it does not need to begin with a hash sign.

This comment will be written as a comment line at the beginning of the file.

The files written by SAVE and SAVE@ are script files. Therefore, when you retain the variables or user defined elements saved to these files with _filename, the comment line will be displayed.

A file written by BUFFER SAVE consists of numbers and can only be used as an insert file, the comment line will not be displayed by Hypatia.

 

The PROMPT command lets you add an optional comment after the name of the variable.

This comment will be displayed when the PROMPT command is executed, to inform the user about the value they are asked to enter.

 

The ENDLOOP and ABORT commands let you add optional comments that will be displayed if these commands are executed.

 

Only the commands listed above (SAVE, SAVE@, BUFFER SAVE, PROMPT, ENDLOOP, ABORT) allow in-command comments.

In-command comments do not need to begin with a hash sign #.

For technical reasons in-command comments will be shown in all lower case regardless of how you type them, though the first character will be in upper case.

 

As mentioned above, I1:, I*:, IF ... THEN, ALSO: and ELSE: can be followed by comments that begin with a hash sign # -- these are not in-command comments.

 

Overview

# comment -- comment line, starts with a hash sign, will be shown in a script but not when the script runs in a loop.

IF ... THEN # comment -- comment following IF ... THEN will always be shown when the condition is met.

I1: # comment, I*: # comment, ALSO: # comment, ELSE: # comment -- comment will always be shown when the condition is met.

#: comment -- comment line, starts with hash sign and colon, will always be shown (in a loop at each pass). The colon will not be shown.

#: -- if not followed by a text, #: writes an empty line to the screen (also after I1:, I*:, IF ...THEN, ALSO: and ELSE:).

## comment -- comment line, starts with double hash signs, will never be shown (except with echo mode on).

... ## comment -- comment can be added to any command or calculation line after a space and double hash signs, this will never be shown.

 

Commands that accept optional comments, no hash sign needed:

POMPT $variable comment -- comment will be shown.

ENDLOOP comment -- comment will be shown when the command is executed.

ABORT comment -- comment will be shown when the command is executed.

SAVE filename comment -- comment will be written to the file as comment line.

SAVE@ filename comment -- comment will be written to the file as comment line.

BUFFER SAVE filename comment -- comment will be written to the file as comment line.

 

Comment lines in insert files are never shown.

 

Home, Up: Scripts, Prev: GOTO and Labels, Next: Script Example: Body Mass Index