;Copyright 2000 - Mark McDonald All rights reserved
; DECLARE: FUNCTION isca(BYVAL STRING) AS INTEGER
; DESC:    Returns true if specified character is alpha.
; EXAMP:   IF isca(INKEY$) THEN PRINT "Alpha Char"
; ISCA(STRING)
;     Is Character Alpha.
;     Returns 1 if character STRING is an alpha character (a-z,A-Z).
;     Returns 0 if not.
;     EXAMPLE:  T = ISCA("A")    1

Extrn   Get$Loc: Far
Extrn   Rls$Alloc: Far

MCODE Segment Byte
        Assume  CS: MCODE


        Public  isca

isca Proc Far

ARG     ChrString: WORD = Retbytes

        push    BP                      ;
        mov     BP,SP                   ;
        push    DS                      ;

        push    Word Ptr ChrString      ; push string handle on stack
        call    Get$Loc                 ; find location of string
        mov     DS,DX                   ; put segment in DS
        mov     SI,AX                   ; put offset in SI
        xor     AX,AX                   ; assume no match
        jcxz    Exit                    ; is string null?
        mov     BL,DS: [SI]             ; get first character
        cmp     BL,'A'                  ; is it less than 'A'?
        jb      Done                    ; yes, exit
        cmp     BL,'Z'                  ; is it less than or equal to 'Z'?
        jbe     ItsAlpha                ; yes, return true
        cmp     BL,'a'                  ; is it less than 'a'?
        jb      Done                    ; yes, exit
        cmp     BL,'z'                  ; is it equal to or more than 'z'?
        ja      Done                    ; yes, exit
ItsAlpha:
        inc     AX                      ; return true (1)
Done:
        push    AX                      ; save return val
        push    Word Ptr ChrString      ; push string handle
        call    Rls$Alloc               ; release string
        pop     AX                      ; restore return val
Exit:
        pop     DS                      ;
        pop     BP                      ;
        retf    Retbytes                ;
isca EndP
MCODE EndS
        End