' 様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様様

' EVMOVE.BAS - EVERLOCK Sample Program

' Written by SSS in Microsoft QuickBASIC Version 4.5.
'
'This uses QuickBASIC 4.5 compiled with the /O option for a
'stand alone program.  Linked with EVMOV3.OBJ BCOM45.LIB.
'
'BC EVMOVE.BAS /o;
'
'LINK EVMOVE.OBJ + EVMOV3.OBJ,,,BCOM45 /e;
'
'Last Updated 28/May/96 SSS
'
'  Define the SB block in the included SB.BAS file
'  $INCLUDE: 'SB.BAS'
'
   DIM SB AS SecureBlock
'
   DECLARE FUNCTION EVMOV3% (SEG SB AS SecureBlock)
'
   DECLARE SUB ParseCmd (CL$, frpth$, topth$, cntflg%, errflg%)
'
'  CL$      = command line string to be parsed
'  frpth$   = from drive variable max 62 bytes
'  topth$   = to drive variable max 62 bytes
'  cntflg%  = flag to set on if /C command line parm
'  errflg%  = flag to set if an error is encountered
'  unflg%   = flag to set on if Uninstal
'
'  Pickup the command line parms from COMMAND$.
'
   CL$ = COMMAND$
   CL$ = UCASE$(COMMAND$)
'
'  Parse the command line input
'
   ParseCmd CL$, frpth$, topth$, cntflg%, errflg%
'
   IF errflg% = 0 THEN           ' If command line parsed AOK
      IF MID$(frpth$, 2, 1) <> ":" OR MID$(topth$, 2, 1) <> ":" THEN
         errflg% = &H7045        ' If from and to path strings not input
         SB.STAT1 = &H7045       ' Set the error
      ELSE                       ' Otherwise from and to path input
         GOSUB init              ' Initialize and call EVMOV3 function
'                                '   to get Product disk info
         IF errflg% = 0 THEN     ' If no errors
            IF SB.UNINST = 1 THEN  ' If Uninstall structure value set
               unflg% = 1        ' Set the uninstall flag
            END IF
            IF unflg% = 0 AND SB.REG = 1 THEN  ' If uninstall flag is not set
            GOSUB REG            ' And Register structure value is on go get 
            END IF               '  Registration information
         END IF
'
         IF errflg% = 0 THEN     ' If no error to this point
            GOSUB MOVE           ' Perform the EVMOVE
         END IF
'
      END IF
   END IF
'
   IF errflg% <> 0 THEN          ' If there was an error
      PRINT                      ' Output error message
      PRINT "  Error "; HEX$(SB.STAT1); "-"; HEX$(SB.STAT2); "-"; HEX$(SB.STAT3)
      PRINT
   ELSE                          ' Otherwise no error 
      PRINT                      ' Print successful completion message
      PRINT "  EVMOVE Completed Successfully."
      PRINT
   END IF
'
'  Now see if there is an update list of files (CPU-Lock Updates)
'
   IF SB.PCNT <> 0 THEN
      FOR i = 1 TO SB.PCNT
         s$ = MID$(SB.SECSTR, (i - 1) * 16 + 1, 16)
         stat = ASC(MID$(s$, 1, 1)) + 256 * ASC(MID$(s$, 2, 1))
         name$ = MID$(s$, 4, 13)
         name$ = LEFT$(name$, INSTR(name$, CHR$(0)))

         IF stat <> 0 THEN
            PRINT "Error "; HEX$(stat); " Program Name: "; name$
         ELSE
            PRINT "Updated  Program Name: "; name$ 
         END IF
      NEXT
   END IF
'
   END
'
init:
'
'  Initialize fields for function 0 call to EVMOV3 to get information and
'     to see if registration is required (if Uninstall then function 0
'        call to EVMOV3 is not required.
'
   SB.SOURCE = frpth$            ' Set up the From drive and path
   SB.TARGET = topth$            ' Set up the To drive and path
   SB.ID = "AZSB"                ' Initialize the ID to AZSB
'
   SB.UNINST = 0                 ' Initialize the Uninstall value to 0
   SB.STAT1 = &H7240             ' Set the Status Return to EVMOV3 failed
   SB.FUNC = 0                   ' Use function of 0 to get Product Info
   errflg% = EVMOV3%(SB)         ' Call EVMOV3 function
   IF errflg% = 0 THEN           ' If return from EVMOV3 is 0
      errflg% = SB.STAT1         ' Set the error flag to Status Return
   END IF
'
   IF errflg% = 0 THEN           ' If no error to this point
      IF cntflg% = 1 THEN        ' If count display is required
         PRINT                   ' Display Count Info
         PRINT "Current Install Counts Available = "; SB.ICR
         DO                      ' Wait for input to continue
            INPUT "Continue (Y/N) ? "; init$
            IF init$ = "Y" OR init$ = "y" THEN
               EXIT DO
            ELSE
               IF init$ = CHR$(27) OR init$ = "N" OR init$ = "n" THEN
                  errflg% = &H7001
                  EXIT DO
               END IF
            END IF
         LOOP
      END IF
   END IF
'
   RETURN
'
REG:
'
'  Subfunction to get registration input
'
   SB.RNAME = CHR$(0)            ' Initialize all Structure fields to NULL
   SB.RCOMP = CHR$(0)
   SB.RLOC = CHR$(0)

   PRINT                         ' Get input for the fields
   INPUT "      Register to Name: "; SB.RNAME
   INPUT "               Company: "; SB.RCOMP
   INPUT "              Location: "; SB.RLOC
   PRINT


   RETURN
'
MOVE:
'
'  Subfunction to perform the function 1 to move authorization
'
   DO
      PRINT                      ' Display Moving Auth message and wait for
      PRINT                      ' Yes/No Input 
      PRINT "Moving Authorization FROM drive "; LEFT$(frpth$, 2); " TO drive "; LEFT$(topth$, 2)
      INPUT " - Confirm (Y/N) ? "; init$
      IF init$ = "Y" OR init$ = "y" THEN
         EXIT DO
      ELSE
         IF init$ = CHR$(27) OR init$ = "N" OR init$ = "n" THEN
            errflg% = &H7001
            EXIT DO
         END IF
      END IF
   LOOP
'
   IF errflg% = 0 THEN           ' If no error
      SB.STAT1 = &H7240          ' Initialize Status Return
      SB.FUNC = 1                ' Initialize func 1 (Move/Update)
      errflg% = EVMOV3%(SB)      ' Call EVMOV3 function
      IF errflg% = 0 THEN        ' If return from EVMOV3 is 0
         errflg% = SB.STAT1      ' Set the error flag to Status Return
      END IF
   END IF
'
   PRINT
   PRINT
'
   RETURN
'
'  t$  = Variable to hold Command Line string passed
'  i%  = counter
'  ln% = length of Command line string
'  SEP$ = seperator to check for
'
   SUB ParseCmd (CL$, frpth$, topth$, cntflg%, errflg%) STATIC
'
      t$ = CL$
      ln% = LEN(CL$)
      frpth$ = ""
      topth$ = ""
      cntflg% = 0
      errflg% = 0
      IF t$ = "" THEN
         errflg = &H7045
         EXIT SUB
      END IF
'
'  Get frpth$ command line parm
'
      ln% = LEN(CL$)
      SEP$ = " "
      FOR i% = 1 TO ln%
         IF MID$(t$, i%, 1) <> SEP$ THEN
            frpth$ = frpth$ + MID$(t$, i%, 1)
         ELSE
            frpth$ = frpth$ + CHR$(0)
            i% = i% + 1
            EXIT FOR
         END IF
      NEXT i%
'
'  Get topth$ command line parm
'
      FOR i% = i% TO ln%
         IF MID$(t$, i%, 1) <> SEP$ THEN
            topth$ = topth$ + MID$(t$, i%, 1)
         ELSE
            topth$ = topth$ + CHR$(0)
            i% = i% + 1
            EXIT FOR
         END IF
      NEXT i%
'
'  Get slash seperated command line parms
'
      SEP$ = "/"
      FOR i% = i% TO ln%
         IF MID$(t$, i%, 1) = SEP$ THEN
            IF MID$(t$, i% + 1, 1) = "C" THEN
               cntflg% = 1
            END IF
         END IF
      NEXT i%
'
   END SUB

