.key skip/k,dest
.bra {
.ket }
.def dest xyzzy
failat 21

lab debug
   Skip {skip$Check4Dest}                 ; 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 command to Skip
;staight   to  VerifyDest  and  then  
;execute  the  file  that  is  created (.xyzzy.bat).       
;      
;example
;       
;     
;.AskDest.bat     
;data2:cdbat/execute data2:HDInstall2  <---  (notice space but no Carriage Return) 
;
;env:choice{$$}  
;abcd <------------------------------------  (What ever they enter as a destination)   
;   
;VerifyDest   
; SKIP VerifyDest<cr> <--------------------  (Space, Skip to Verify & Carriage Return) 
; 
;.xyxxy.bat <------------------------------  (combines all three)  
;data2:CDBat/Execute Data2:HDInstall2 abcd SKIP VerifyDest<cr> 
; 
;  If they just press return or type in an improper destination that is 
;  checked in VerifyDest 
; 
;


lab Check4Dest
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
      CD CDBat:
      type 'EnterDest.txt
      echo " Please enter a destination and press return: " NOLINE
      setenv >NIL: Choice{$$} ?
      join .askdest.bat env:choice{$$} CR as ram:.xyzzy.bat
      data2:cdbat/execute ram:.xyzzy.bat
   endif
   ram:cdbat/execute ram:cdbat/.CheckDest.bat skip VerifyDest dest SYS


lab VerifyDest
; look for {dest}, make sure it exists
   CD CDBat:
   assign >nil: {dest}: exists            ; Returns "20" if {dest}: does not exist
      if warn                             ; if we get an error of level 20...
  	      echo "*Ec*N I can't find {Dest} !!!" 
         type 'NoDest.txt
         ask -dy " Press Return..."
      lab WhatNowMenu
         echo "*Ec*N What would you like to do now?"
         echo "*N   1) Accept SYS: as my Destination"
         echo "*N   2) Enter a Destination"
         echo "*N   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 .CheckDest.bat skip Check4Dest dest SYS
         endif

         if $Choice{$$} EQ 2 VAL ; Enter a New {dest}
            execute .CheckDest.Bat skip Ask4Dest dest xyzzy
         endif
      
         if $Choice{$$} EQ 3 VAL ; Quit
            execute .Cleanup.bat
         endif

         ; they typed in something other than 1-3
         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

Execute HDInstall2 Skip MainMenu dest {dest}
