.key dest,skip
.bra {
.ket }
.def dest xyzzy

;
; HDStart
; Startup File for City Desk 2.0, Hard Drive Instalation
; Copying All files takes a minimum of 4000 blocks free on Hard drive 
; or 2,048,000 bytes (approx. 2.00mg)
;
;

;data2:CDBat/skip {skip$Startup}           ; used to debug


;The  following  Tests to see if they gave me a destination.  If so I go on
;and use the destination.  If they did not, (as is the case when clicked on
;from  Workbench)  then  I  ask  them  for  a destination.  I then add that
;destination  to  .AskDest.bat  and  along  with  a carrage return and then
;execute the file that is created (.xyzzy.bat).
;
;example:
;
;.AskDest.bat
;execute data2:CDBat/.startup.bat  <--- (notice space but no Carriage Return)
;
;env:choice{$$}
;abcd <-------------------------------- (What ever they enter as a destination)
;
;CR
;<cr> <-------------------------------- (file consists of a Carriage Return only)
;
;.xyxxy.bat
;execute ram:.startup.bat abcd <cr> <-- (combines all three)
;
; If they just press return or type in an improper destination that is
; checked in Startup.bat
;
;
; ************* I must make sure that ENV is avtive befor i do this *********
;
; Also I might as well try to test for dest Then if I can't find it
; ask them if they want to enter again (call this bat file again)
;




lab Startup
   Data2:cdbat/Assign  OldFrom{$$}: ""    ; "" = the current directory
   data2:cdbat/cd data2:cdbat             ; force use of AmigaDOS v1.3 commands
   echo "*Ec*NPlease wait while I make sure everything is OK..." NOLINE

failat 21

lab Check4{Dest}
if {dest} NOT EQ "xyzzy"
   skip VerifyDest
endif

   type 'AskDest.txt
   ask -dN " Would you like to enter a destination? N"
   if NOT warn                            ; They want to enter a destination
lab Ask4Dest
      type 'EnterDest.txt
      echo " Please enter a destination and press return: " NOLINE
      setenv >NIL: Choice{$$} ?
      if $Choice{$$} NOT EQ ""
         join data2:cdbat/.askdest.bat env:choice{$$} data2:cdbat/cr as ram:.xyzzy.bat
         cd ram:
         data2:cdbat/execute ram:.xyzzy.bat
      endif
   endif
   cd ram:
   data2:cdbat/execute data2:HDInstall2 SYS


lab VerifyDest
; look for {dest}, make sure it exists
   failat 21
   assign >nil: {dest}: exists            ; Returns "20" if {dest}: does not exist
      if warn                             ; if we get an error of level 20...
  	      echo "*N*N I can't find {Dest} !!!" NOLINE
         type 'NoDest.txt
         ask -dy " Press Return..."
      lab WhatNowMenu
         echo "*Ec*N What would you like to do now?"
         echo "   1) Accept SYS: as my destination"
         echo "   2) Enter a new Destination"
         echo "   3) Quit"
         echo "*N Please choose an option by typing its number. Then press Return ?" NOLINE
      setenv >NIL: Choice{$$} ?

      Lab Eval_Choice{$$}

         if $Choice{$$} EQ 1 VAL ; Accept SYS: as {dest}
            execute HDinstall2 SYS
         endif

         if $Choice{$$} EQ 2 VAL ; Enter a New {dest}
            Skip Ask4Dest BACK
         endif
      
         if $Choice{$$} EQ 2 VAL ; Quit
            Skip ExitQuick
         endif

         ; they typed in something other than 1-7
         echo "*NYou must type in a number between 1 and 3"
         wait
         skip WhatNowMenu BACK               ; Lets see if we can get it right this time
      endif                               ; {dest}: seems to exist

lab CheckCopy
; check to see if copy is aliased as "COPY [] CLONE" or "COPY [] ALL" or both
   copy testdir to ram:temp{$$} QUIET
   if error
      echo "*N*N The COPY command is not responding properly to the QUIET parameter*N"
      type 'CopyWarning.txt      ; Copy Did not work right, Read HDInstall.readme
      Skip ExitQuick
   else
      copy testdir to ram:temp{$$} CLONE QUIET
         if error
            echo "*N*N The COPY command is not responding properly to the CLONE parameter*N"
            type 'CopyWarning.txt         ; Copy Did not work right, Read HDInstall.readme
            Skip ExitQuick
         else
            copy testdir to ram:temp{$$} ALL CLONE QUIET
            if error
               echo "*N*N The COPY command is not responding properly to the ALL parameter*N"
               type 'CopyWarning.txt               ; Copy Did not work right, Read HDInstall.readme
               Skip ExitQuick
            endif
         endif
      delete ram:temp{$$}
   endif

lab Copy2Ram
; See if they want to copy installation files to RAM:
   type data2:cdbat/'Copy2Ram.txt
   ask -dy " Copy Installation files to RAM:? Y"
   if warn
      cd data2:CDBAT
      skip CheckENV
   else
      echo "*EcMoving needed files to Ram:..." NOLINE
      Copy Data2:CDBat to RAM:CDBat ALL CLONE QUIET
      RAM:CDBat/cd RAM:CDBat
   endif
      assign CDBat: ""                    ; "" = the current directory

lab CheckENV
; Make Sure that ENV: exists
   assign >nil: env: exists               ; Check for ENV:
      if warn                             ; No ENV:
         makedir ram:env                  ; Make it
         assign env: ram:env              ; Assign it
      endif

lab MainMenu
   execute .MainMenu.bat {dest}



lab ExitQuick                             ; We got here because of a problem
   echo "*N*NExiting HDInstall..." NOLINE
   delete env:choice{$$}
   echo "*N"
   ask -dy "*N Shall I close this CLI window when I am finished? Y"
   if warn 
      cd OldFrom{$$}:                        ; goto where we were
      Data2:cdbat/Assign  OldFrom{$$}:
      quit
   else
      cd OldFrom{$$}:                        ; goto where we were
      Data2:cdbat/Assign  OldFrom{$$}:
      Data2:cdbat/endcli
   endif
