;
; Program: SHFILE
; Author: Richard Conn
; Version: 1.0
; Date: 5 Mar 84
;
version equ     10

;
;       SHFILE defines the name of the shell variable file or displays it.
;

;
; Equates for Key Values
;
z3env   SET     0f400h  ;address of ZCPR3 environment
fcb     equ     5ch
cr      equ     0dh
lf      equ     0ah

;
; External Z3LIB and SYSLIB Routines
;
       ext     z3init,getfn1,print,pfn1,moveb,qprint

;
; Environment Definition
;
       if      z3env ne 0
;
; External ZCPR3 Environment Descriptor
;
       jmp     start
       db      'Z3ENV' ;This is a ZCPR3 Utility
       db      1       ;External Environment Descriptor
z3eadr:
       dw      z3env
start:
       lhld    z3eadr  ;pt to ZCPR3 environment
;
       else
;
; Internal ZCPR3 Environment Descriptor
;
       MACLIB  Z3BASE.LIB
       MACLIB  SYSENV.LIB
z3eadr:
       jmp     start
       SYSENV
start:
       lxi     h,z3eadr        ;pt to ZCPR3 environment
       endif

;
; Start of Program -- Initialize ZCPR3 Environment and Print Banner
;
       call    z3init  ;initialize the ZCPR3 Environment
       call    qprint
       db      'SHFILE, Version '
       db      (version/10)+'0','.',(version mod 10)+'0',cr,lf,0
;
; Set Name of Shell Variable File
;
       call    getfn1          ;get ptr to file name 1
       lxi     d,fcb+1         ;pt to name in FCB
       xchg                    ;copy from FCB
       mvi     b,11            ;11 bytes
       mov     a,m             ;get first char
       cpi     ' '             ;don't define if no name
       jz      prshfile
       call    moveb           ;define name
       call    setshdef        ;set default file type if none given
;
; Print Name of Shell Variable File
;
prshfile:
       call    print
       db      ' Shell Variable File Name is ',0
       call    getfn1          ;pt to name
       xchg
       call    pfn1
       ret
;
; Set Type of Shell Variable File if None Given
;
setshdef:
       call    getfn1          ;check for file type
       lxi     d,8             ;pt to file byte
       dad     d
       xchg
       lxi     h,shvtype       ;default file type
       mvi     b,3             ;3 chars
       ldax    d               ;get char
       cpi     ' '             ;set if space
       cz      moveb           ;copy
       ret

;
; Buffers
;
shvtype:
       db      'VAR'

       end