;Copyright 2000 - Mark McDonald All rights reserved
; DESC:    Return 1 IF all characters in string are space, 0 if not.
; EXAMP:   Sum = isspaces(Text$)

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

MCODE Segment Byte
        Assume  CS: MCODE

        Public  isspaces

isspaces 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?
ReadChar:
        lodsb                           ; load a character
        cmp     AX,32                   ; is character a space?
        jnz     Notsp                   ; if not jump to Notsp
        loop    ReadChar                ; do it CX times
        mov     AX,1                    ; all characters are sp
        jmp     Exit                    ;
Notsp:
        xor     AX,AX                   ; return 0
Exit:
        push    AX                      ; save return val
        push    Word Ptr StrHandle      ; push string handle
        call    Rls$Alloc               ; release string
        pop     AX                      ;
        pop     DS                      ;
        pop     BP                      ;
        retf    Retbytes                ;
isspaces EndP
MCODE EndS
        End