home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / emulator / applem / loadram.rexx < prev    next >
OS/2 REXX Batch file  |  1995-02-27  |  1KB  |  50 lines

  1. /* Load file into RAM V0.9 */
  2. parse source mycall .
  3. if mycall=FUNCTION then trace l
  4. call open(file,arg(1))
  5. call readch(file,2)
  6. if RESULT="ffff"x then do /* Recognize special file */
  7.     from=c2d(reverse(readch(file,2)))
  8.     len=c2d(reverse(readch(file,2)))-from+1
  9. end
  10. else do /* Suppose basic file */
  11.     from=2049
  12.     len=c2d(RESULT)
  13. end
  14. /*
  15. if ~show('l','rexxsupport.library') then
  16.     call addlib('rexxsupport.library',0,-30)
  17. call forbid
  18. */
  19. do for 10 until RESULT~=0
  20.     call findprocess("applem000")
  21. end
  22. if RESULT=0 then exit 1
  23. call findseg(RESULT)
  24. call export(d2c(c2d(import(d2c(RESULT+150,4),4))+from,4),readch(file,len))
  25. exit 0
  26.  
  27. FINDPROCESS: /* Based on c't 89/3 p. 142 */
  28. ExecBase=c2d(import('00000004'x,4))
  29. TaskWait=c2d(import(d2c(ExecBase+420,4),4))
  30. do while TaskWait~=0
  31.     if c2d(import(d2c(TaskWait+8,4),1))=13 &,
  32.        c2d(import(d2c(TaskWait+140,4),4))~=0 then do
  33.         CLI=c2d(import(d2c(TaskWait+172,4),4))
  34.         CommandName=c2d(import(d2c(CLI*4+16,4),4))
  35.         CommandName=import(d2c(CommandName*4+1,4))
  36.         if abbrev(reverse(CommandName),reverse(arg(1))) then leave
  37.     end
  38.     TaskWait=c2d(import(d2c(TaskWait,4),4))
  39. end
  40. return TaskWait
  41.  
  42. FINDSEG: /* Based on Xoper hunks */
  43. seglist=import(d2c(arg(1)+172,4),4)
  44. seglist=c2d(seglist)*4+60
  45. do 2
  46.     seglist=import(d2c(seglist,4),4)
  47.     seglist=c2d(seglist)*4
  48. end
  49. return seglist
  50.