home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / ha3upgs1.lha / ha3_update_gs01 / rexx / zxam_run.rexx
OS/2 REXX Batch file  |  1996-10-08  |  4KB  |  187 lines

  1. /*test version1.0*/
  2.  
  3. /* This script loads a snapshot from disk */
  4.  
  5. /* Update v1.2. 19-09-96. Gerard Sweeney. Based on original AREXX
  6.    script supplied with ZXAM 2.0b */
  7.  
  8. /*  Note, this does not need to be run through DOpus... Any Directory
  9.     Manager can do it, just use RX ZXAMRUN.dopus [snapshotname]
  10.     and it should work OK.....   */
  11.  
  12. parse arg file2load    /* gets the arguments as one long text */
  13. parse var file2load nombre "|" YN  /* Splits into 2 seperate args */
  14.  
  15.  
  16. ADDLIB('rexxarplib.library',0,-30,0)
  17.  
  18. /* check filename. Step 1 if no name, step 2 if wrong name */
  19.  
  20.  
  21. call check_yn
  22. call check_filename
  23. call check_zxam
  24. call load_zxam
  25. call load_snap
  26. exit
  27.  
  28.  
  29. /* PROCEDURES FOLLOW............*/
  30.  
  31.  
  32. Check_YN:
  33.  
  34. if yn='' then do
  35. yn='Y'
  36. end
  37. return
  38.  
  39.  
  40. Check_filename:
  41.  
  42.  if nombre='' then do
  43.  prompt_str='You don''t appear to have entered a snapshot name.\Do you want to pick one yourself?'
  44.  call snap_prob
  45.  end
  46.  
  47.  
  48.  if ~open(tempsnap,nombre,"r") then do
  49.  prompt_str='Sorry Spec-Chum. I couldn''t find that file.\Do you want to pick one yourself?'
  50.  call snap_prob
  51.  end
  52. return
  53.  
  54.  
  55. Check_ZXAM:
  56.  
  57. locfile='s:zxamlocation'     /* S:zxamlocation - points to emulator */
  58.  
  59.  if ~open(zxamlocfile,locfile,"r") then do
  60.  prompt_str='The emulator location file (S:ZXAMLOCATION) could not be found\Do you want to show me where your emulator is?'
  61.  call zxam_loc_prob
  62.  end
  63.  
  64. open(zxamlocfile,locfile,"r")
  65. zxam_location=readln(zxamlocfile)
  66.  
  67.  if ~exists(zxam_location) then do
  68.  prompt_str='Sorry Spec-Chum.... I couldn''t find the emulator based on the\settings of S:ZXAMLOCATION......\\Do you want to show me where your emulator is?'
  69.  call zxam_loc_prob
  70.  end
  71. return
  72.  
  73.  
  74. load_snap:
  75.  
  76. /* Load the snapshot.. The zxamact labels allow the Reload function */
  77.  
  78.     bloque=zxampploadfile(nombre)    /* load the whole file */
  79.     formato=zxamparseloaded(bloque)        /* checks the format and loads the file */
  80.  
  81.       if formato~='' then do
  82.         zxamnameformat(zxamfilepart(nombre),formato)
  83.           pth=zxampathpart(nombre)
  84.           temp_path=zxamloadpath(pth)
  85.           path=zxamactloadpath()
  86.           path=pth
  87.           name=zxamactname()
  88.       zxamenablereload()
  89.       end
  90.  
  91.  
  92.         if upper(YN)='N' then do
  93.         exit
  94.         end
  95.          else do
  96.          zxamrun()
  97.          end
  98.  
  99.  
  100. return
  101.  
  102.  
  103. zxam_loc_prob:
  104. prompt_yes='Yes please'
  105. prompt_no='No thanks'
  106. call prompt_proc
  107. prompt_str='Try editing the file S:ZXAMLOCATION to reflect the\full name (path included) of your emulator\(e.g. DH1:UTILS/EMULATORS/SPECCY/ZXAMSPECTRUM_AGA)'
  108.  if prompt_temp='' then do
  109.  call prompt_exit
  110.  end
  111. req_str='Please select the emulator you wish to use'
  112. call req_proc
  113.  if req_temp='' then do
  114.  
  115.  call prompt_exit
  116.  end
  117. zxam_location=req_temp
  118. call open(templocfile,locfile,"w")
  119. writeln(templocfile,zxam_location)
  120. call close(templocfile)
  121. return
  122.  
  123.  
  124. load_zxam:
  125.  
  126. running=1
  127. loading=0
  128.  
  129. /* Uses the internal loaders of the emulator...
  130.  
  131.    If emulator port not found, loads program from disk using zxam_location */
  132.  
  133.  
  134.     address command
  135.  
  136.             if ~show(ports,ZXAM_REXX) then do
  137.                 ADDRESS COMMAND zxam_location
  138.                 loading=1
  139.         end
  140.  
  141.  
  142. /* Loops until ZXAM port is active, otherwise the prog cannot load the snap */
  143.  
  144. if loading=1 then do until loading=0
  145.  if show(ports,ZXAM_REXX) then do
  146.  loading=0
  147.  end
  148. end
  149. return
  150.  
  151.  
  152. snap_prob:
  153.  
  154. prompt_yes="Yes please"
  155. prompt_no="No thanks"
  156. call prompt_proc
  157. prompt_str='Try re-entering the filename'
  158.  if prompt_temp='' then do
  159.  call prompt_exit
  160.  end
  161. req_str='Please select a snapshot to load'
  162. call req_proc
  163.  if req_temp='' then do
  164.  call prompt_exit
  165.  end
  166. nombre=req_temp
  167. YN='Y'
  168. return
  169.  
  170.  
  171. REQ_PROC:
  172. req_temp=getfile(100,50,"ram:",,,REQ_STR)
  173. return
  174.  
  175.  
  176. PROMPT_PROC:
  177. prompt_temp=request(100,50,prompt_str,,prompt_yes,prompt_no)
  178. return
  179.  
  180.  
  181. PROMPT_EXIT:
  182. prompt_yes="Exit"
  183. prompt_no="Exit"
  184. call prompt_proc
  185. exit
  186. return
  187.