;Copyright 2000 - Mark McDonald All rights reserved
; DESC:    Return 1 IF all characters in string are a-z or space, 0 if not.
; EXAMP:   Sum = isazsp(Text$)
; ISAZSP(STRING)
;     Is A-Z or Space.
;     Returns 1 if all characters in STRING are a-z,A-Z or space.
;     Returns 0 if not.
;     EXAMPLE:  T = ISAZSP("alpha beta")         1
;               T = ISAZSP("alpha beta 123")     0

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

MCODE Segment Byte
        Assume  CS: MCODE

        Public  isazsp

isazsp Proc Far

ARG     StrHandle: WORD = Retbytes

        push    BP                      ;
        mov     BP,SP                   ;
        push    DS                      ;

        mov     AX, StrHandle           ; put string handle in AX
        push    AX                      ; push it on the on stack
        call    Get$Loc                 ; get location of string
        mov     DS,DX                   ; put segment in DS
        mov     SI,AX                   ; put offset in SI
        xor     AX,AX                   ; clear AX
        jcxz    Exit                    ; is string null?
        xor     BX,BX                   ; clear BX
ReadChar:
        lodsb                           ; load a character
        cmp     AX, 32
        jz      ItsAlpha
        cmp     AL, 'A'                 ; is it less than 'A'?
        jb      Exit                    ; yes, exit
        cmp     AL, 'Z'                 ; is it less than or equal to 'Z'?
        jbe     ItsAlpha                ; yes, return true
        cmp     AL, 'a'                 ; is it less than 'a'?
        jb      Exit                    ; yes, exit
        cmp     AL, 'z'                 ; is it more than 'z'?
        ja      Exit                    ; yes, exit
ItsAlpha:
        loop    ReadChar                ; do it CX times
        mov     BX,1                    ; all characters are sp
Exit:
        mov     AX,BX
        push    AX                      ; save return val
        push    Word Ptr StrHandle      ; push string handle
        call    Rls$Alloc               ; release string
        pop     AX                      ; restore return val
        pop     DS                      ;
        pop     BP                      ;
        retf    Retbytes                ;
isazsp EndP
MCODE EndS
        End