# Routines - PeatSoft

## isDigit (QBasic)

- Source: Common LISP
```' Test whether -ch- is a digit in the specified -radix-. If it is a digit
' in that -radix-, the function returns an integer >= 0; otherwise -1 is
' returned.
FUNCTION isDigit% (ch AS STRING, radix AS INTEGER)
isDigit% = -1
FOR i = 0 TO radix - 1
IF UCASE\$(ch) = CHR\$(48 + i - 7 * (i > 9)) THEN
isDigit% = i
EXIT FOR
END IF
NEXT i
END FUNCTION
```

## GenSymbol (QBasic)

- Source: Common LISP
```' Creates and returns a fresh, new symbol that can be used as a name for
' a variable, function, etc.
DECLARE FUNCTION GenSymbol\$ (atm1 AS STRING, atm2 AS INTEGER)

DIM SHARED GenSymPrefix AS STRING
DIM SHARED GenSymCount AS INTEGER

GenSymPrefix = "G"
GenSymCount = 3142

FUNCTION GenSymbol\$ (atm1 AS STRING, atm2 AS INTEGER)
IF atm1 = "" AND atm2 = -1 THEN
ELSEIF atm1 <> "" AND atm2 = -1 THEN
GenSymbol = atm1 + LTRIM\$(STR\$(GenSymCount))
GenSymCount = GenSymCount + 1
EXIT FUNCTION
ELSEIF atm1 = "" AND atm2 >= 0 THEN
GenSymbol = GenSymPrefix\$ + LTRIM\$(STR\$(atm2))
EXIT FUNCTION
END IF
GenSymbol = GenSymPrefix\$ + LTRIM\$(STR\$(GenSymCount))
GenSymCount = GenSymCount + 1
END FUNCTION
```