!Write a function pred$ that returns the predecessor

!(in the ASCII table) of a character parameter.

!If the parameter string is longer than one character,

!the function returns the predeccessor of the first character.

!Test your function using the string values "C", "A", "@", and "qed".

 

DECLARE FUNCTION pred$

INPUT prompt "Character? ": entry$

PRINT "Predecessor of "; entry$[1:1];" is "; pred$(entry$[1:1])

END !main program

 

EXTERNAL function pred$(ch$)

LET ch$=ch$[1:1]

LET pred$=chr$(ord(ch$)-1)

END FUNCTION