SPLat Logo

# Include hash command

NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

# Include hash command

The Include hash command lets you include one SPLat source file within another. The effect is the same as manually copying and pasting the contents of one file into another.

Example:

Suppose you have a file named maths.spt that looks like this:


kfPI fEQU 3.14159265359

; Calculate the volume of a cylinder, the formula is:
; V = pi * r^2 * h
; PARAMETERS:
; w = radius
; q = height
; RETURNS
; w = volume
subCylinderVolume:
WtoU 0 ;save "r"
fMul ;r * h
UtoQ 0 ;recall "r"
fMul ;r * r * h
fLoadQ kfPI
fMul ;pi * r * r * h
Return

Then in your main file you have:

...
...
fLoadW 2.5 ;2.5m radius
fLoadQ 1.0 ;1m of water
GoSub subCylinderVolume ;calc volume of water
...
...
#Include File("maths.spt")

When your main file is translated by SPLat/PC, the line

   #Include File("maths.spt") 

gets replaced by the entire contents of the file maths.spt . It is as if you had copied and pasted one file into another. You effectively end up with:


...
...
fLoadW 2.5 ;2.5m radius
fLoadQ 1.0 ;1m of water
GoSub subCylinderVolume ;calc volume of water
...
...
kfPI fEQU 3.14159265359

; Calculate the volume of a cylinder, the formula is:
; V = pi * r^2 * h
; PARAMETERS:
; w = radius
; q = height
; RETURNS
; w = volume
subCylinderVolume:
WtoU 0 ;save "r"
fMul ;r * h
UtoQ 0 ;recall "r"
fMul ;r * r * h
fLoadQ kfPI
fMul ;pi * r * r * h
Return

This is a very useful way of managing projects, and of keeping your favourite routines and code snippets in a library.

You can have any number of Include hash commands in a file. You can even have includes within included files. Included files can be nested 10 deep. You cannot have recursive inclusions, such as a file including itself or two files that include each other as this will violate the allowed nesting depth.

The Include hash command gives you a powerful mechanism for building and using libraries.

You cannot single step or simulate any hash command, including the Include hash command. You can however use the menu item File>Pre-process to generate a file where all the hash commands have been processed and the resultant code has been generated.

The #Include hash command is available in SPLat/PC Build 181 and later.