home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / alib.lha / win.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1989-08-21  |  2.4 KB  |  113 lines

  1. /*  WINDOW TEST -- A arexx script that opens a window via AmigaLibHost */
  2.  
  3. /*  USAGE: rx win <debug>          */
  4.  
  5. args mode
  6.  
  7. /* Trace if debugging requested. */
  8.  
  9. if mode ~== 'MODE' then trace ?r
  10.  
  11.  
  12. /* Access arexx host. */
  13.  
  14. call ADDLIB 'AmigaLibHost',-20
  15.  
  16.  
  17. /* Ask host to open a library. */
  18.  
  19. INTUITIONBASE = FINDLIB('intuition.library',0)
  20.  
  21.  
  22. /* Create a NewWindow structure in hex (!!) -- still better than BASIC. */
  23.  
  24. title = 'Window Opened Via AmigaLibHost'
  25. titlemem = getspace(length(title)+1)
  26. call export(titlemem,title)
  27.  
  28. /* This set of hex values corresponds to a window with close, sizing,   */
  29. /* front/back and drag gadgets. See the Rom Kernel Manual to know what  */
  30. /* all the bits mean. */
  31.  
  32. nw = '0000 0000 0200 0080 FF FF 00000200 0002000F 00000000 00000000'X ,
  33.     || titlemem || '00000000 00000000 0040 0020 FFFF FFFF 0001'X
  34.  
  35.  
  36. /* Prepare for OpenWindow call (use "fd2rx.rexx" to create these). */
  37.  
  38. OPENWINDOW.BASE = INTUITIONBASE
  39. OPENWINDOW.LVO = -204
  40. OPENWINDOW.CALL = '(OWARGS)(A0)'
  41.  
  42. /* AmigaLibHost expects numerical values, but variable nw is a string. */
  43. /* Need to tell AmigaLibHost that parameter OWARGS will be a string. */
  44.  
  45. OPENWINDOW.OWARGS = 'STRING'
  46.  
  47. /* Open the window. */
  48.  
  49. win = SENDLIB('OPENWINDOW',nw)
  50.  
  51. /* If didn't get a zero result, our window opened. */
  52.  
  53. if win ~= 0 then do
  54.  
  55.  
  56.     /* Open exec libray so we can Wait for the closebow to be clicked in. */    
  57.  
  58.     SYSBASE = FINDLIB('exec.library',0)
  59.  
  60.     WAIT.BASE = SYSBASE
  61.     WAIT.LVO = -318
  62.     WAIT.CALL = '(SIGNALSET)(D0)'
  63.  
  64.  
  65.     /* Create a signal mask for Wait() from the signal bit in the window's */
  66.     /* UserPort message port. */
  67.  
  68.     userport = PEEK(win + 86,4)
  69.     sigbit = PEEK(userport + 15,1)
  70.     sigmask = bitset('00000000'X,sigbit)
  71.  
  72.     /* SIGNALSET is a 'packed' 4-byte number. */
  73.  
  74.     WAIT.SIGNALSET = 'LONG'
  75.     call SENDLIB('WAIT',sigmask)
  76.  
  77.  
  78.     /* Release exec base. */
  79.  
  80.     call DONELIB(SYSBASE)
  81.  
  82.  
  83.     /* Close the window. */
  84.  
  85.     CLOSEWINDOW.BASE = INTUITIONBASE
  86.     CLOSEWINDOW.LVO = -72
  87.     CLOSEWINDOW.CALL = '(WINDOW)(A0)'
  88.  
  89.     call SENDLIB('CLOSEWINDOW',win)
  90. end
  91.  
  92.  
  93. /* Close intuition library. */
  94.  
  95. call DONELIB(INTUITIONBASE)
  96.  
  97. exit        /* don't let 'internal functions' get executed */
  98.  
  99.  
  100. /* Peek function -- sort of like BASIC. */
  101.  
  102. PEEK:
  103. arg location,size
  104. return c2d( import( d2c(location,4),size ),size )
  105.  
  106.  
  107. /* Poke function -- sort of like BASIC. */
  108.  
  109. POKE:
  110. arg location,value,size
  111. call export( d2c(location,4),d2c(value,size),size )
  112. return
  113.