Loading/Compiling Procedures

Helpful hints, useful features you may not be aware of, and more
moderator
Site Admin
Posts: 270
Joined: Thu Oct 19, 2006 4:33 pm

Loading/Compiling Procedures

Unread post by moderator »

One of the most powerful features of RATS is the ability to write "procedures" of code, which can be executed in a RATS program using a syntax nearly identical to that used for built-in RATS instructions. We ship hundreds of pre-written procedures with RATS, and even more are available on our website and here on the forum.

Procedures are usually stored on separate files, so RATS needs a way to read and "compile" the code on the procedure file, so that you can subsequently call (execute) the procedure in your RATS sessions.

As always, you can do this manually using the SOURCE instruction. You normally only need to do this once per program or session, sometime prior to the first time the procedure is called. If the file is not in the current directory, include the full path and filename. If the path or filename includes spaces, put the whole thing in quotes. For example:

source "C:\rats files\fancyproc.src"
@fancyproc
# x y z

However, with recent versions of RATS, you can omit the SOURCE instruction and let RATS search for a procedure file automatically. RATS will look for a file whose name matches the name of the procedure you are calling, with a .SRC extension.

You can use the "Procedure Directory" setting under File-Preferences... to specify the directory you want RATS to check for procedure files. By default, this should point to your main RATS user directory, where all the examples and procedures that ship with RATS are installed. If you maintain this as your search directory, and store any new or revised procedures that you download or write in this same directory, you can ensure that RATS will find the current versions of your procedures.

You can also use File-Preferences... to have a library of procedures loaded automatically.

See Section 16.2.1 in the RATS 7 User's Guide for more details.

Regards,
Tom Maycock
Post Reply