CD Shell Function Reference quick lookup:

Introduction
Anywhere you would normally use a value in an expression, you can also use a function. The function will return a value to be used in the calculation of the expression.

Functions take the form 'name[parameters]'. The following is a list of all of the functions that are available.


Function List

bootCheck boot.csm
The bootCheck function checks a drive to see if it appears bootable. If this function returns 0, then the device doesn't appear bootable. If it returns 1, then the device has a bootable boot-sector. If it returns 2, then the Master Boot Record contains a bootable partition. If it returns 3, then the bootable partition has a bootable boot-sector. The disk identifier shortcuts can be used as parameters.

Examples:

if bootCheck[0]; then boot 0 # Boot from floppy.
if bootCheck[$hda] == 3; then boot $hda # Boot from hda (device 0x80).
if !bootCheck[0x81]; then print "hdb is not bootable!"

color basic.csm
The color function returns the numeric value of a color represented by keywords. Both a foreground and a background color must be specified, and are separated by the on keyword. Valid color names are: black, blue, green, cyan, red, magenta, brown, grey, brightgrey, brightblue, brightgreen, brightcyan, brightred, brightmagenta, yellow, and white.

Examples:

set textColor= color[brightgreen on black]
set boldColor= color[yellow on red]

compare basic.csm
The compare function compares two strings to see if they are the same. It returns 1 if they are the same, and 0 if they are different. The icompare function is exactly the same, only it is case-insensitive.

Examples:

if compare["$myVar" "abc"]; then print "myVar is set to 'abc'"
if icompare["apple" "Apple"]
then print "Apples are delicious."
else print "You should not see this."

defined macro.csm
The defined function checks to see if a given variable exists. It returns 1 if the variable exists, and 0 if it does not.

file basic.csm
The file function check for the existence of the file specified by its parameter. If the file is present, then the function returns 1. If the file is not found, then the function returns 0. Files are checked for in the current directory, unless an absolute path is used.

icompare basic.csm
The icompare function is exactly the same as the compare function, only it is case-insensitive.

key script.csm
The key function returns the keycode of its parameter. The given paramter can be either a single-character key, or a one-word description of the key (for special keys). These descriptions are given in the following table.

Key identifier Description
af1 ~ af12Alt-F1 through Alt-F12
backBackspace
bracketClose-Bracket (']')
cf1 ~ cf12Ctrl-F1 through Ctrl-F12
delDelete
downDown Arrow
endEnd
enterEnter
escEscape
f1 ~ f12F1 through F12
homeHome
insInsert
leftLeft Arrow
mouseMouse Event
pgdnPage Down
pgupPage Up
rightRight Arrow
sf1 ~ sf12Shift-F1 through Shift-F12
spaceSpace Bar
tabTab
upUp Arrow

The following examples make use of the $lastKey variable.

if $lastKey == key[a]; then print "You pressed the letter 'a'."
if $lastKey == key[enter]; then goto selectCurrentItem

length basic.csm
The length function returns the number of characters that lie between the delimiting parameter brackets ( [ ] ). You can use this function to calculate the length of a string, for example.

- Previous - - Next -