SEQ Function

The SEQ function returns the decimal value for the supplied character.

Format

SEQ(expr)

Parameter(s)

expr

An expression evaluating to a single character. If expr evaluates to a string longer than one character, only the first character is evaluated.

Description

The SEQ function returns the decimal value for the ASCII character given. It acts as an inverse for the CHAR function.

See Appendix B: List Of ASCII Codes for a list of ASCII character codes.

Example

To return the ASCII decimal value for a space into a variable SPACESEQ, the code would read:

SPACESEQ = SEQ (" ")

In this instance, the variable SPACESEQ would contain "32".

In the next application, a string has standard control characters (decimal [non-breaking space] 1 through decimal 31) converted into printable equivalents. The SEQ function is used to return the ASCII decimal value of each character, and that value is then used to determine whether the character falls into the ASCII range of control characters.

NO.OF.CHARS = LEN(STRING)  

NEW.STRING = ""   

FOR I  =  1 TO NO.OF.CHARS    

   CHARACTER = STRING[I ,1]   

   ASC = SEQ(CHARACTER)    

   IF (ASC > 0 AND ASC < 32 ) THEN

      NEWCHAR = "^" : CHAR(ASC + 64)

   END ELSE

      NEWCHAR = CHARACTER

   END

   NEWSTRING := CHARACTER

NEXT I    

STRING = NEW.STRING

 

See Also

Statement and Function Reference