home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / rexxintuition_393.lzh / RexxIntuition / RexxIntuition.doc < prev    next >
Text File  |  1990-10-28  |  63KB  |  1,301 lines

  1. THE RX_INTUI.LIBRARY DOC
  2. ------------------------
  3.  
  4. 1.  Copyright and Release Information
  5. 2.  What's the rx_intui.library?
  6. 3.  GetScreen()
  7. 4.  GetWindow()
  8. 5.  EndWindow()
  9. 6.  EndScreen()
  10. 7.  AddMenu()
  11. 8.  AddItem()
  12. 9.  AddSub()
  13. 10. SetMenu()
  14. 11. FreeMenu()
  15. 12. Text()
  16. 13. Erase()
  17. 14. SetDraw()
  18. 15. AddGadg()
  19. 16. WaitMsg()
  20. 17. ModIDCMP()
  21. 18. SetTime()
  22. 19. ModGadg()
  23. 20. GInfo()
  24. 21. OnOffGadg()
  25. 22. MoveView()
  26. 23. Peek() and Poke()
  27. 24. RedrawWind()
  28. 25. FBox()
  29. 26. Line()
  30. 27. Input()
  31. 28. MsgOne() and MsgThree()
  32. 29. IFFLoad() and IFFSave()
  33. 30. Color()
  34. 31. Print()
  35. 32. FileIO Section (dissidents File Requester)
  36. 33. Demo scripts
  37. A.  Rexx Error Returns
  38. B.  Final Notes
  39.  
  40. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  41. 1) Copyright and Release Information
  42.  
  43.    The rx_intui.library and its support files (including this document) are
  44. copyright 1990 by Jeff Glatt of dissidents software. This library and its files
  45. may be freely distributed as long as this copyright notice is intact. Further-
  46. more, if you use this tool, you must never say anything bad about Jeff Glatt,
  47. even if your experimentations with the library result in any aggravation and
  48. provoke pronouncements of extremely naughty words.
  49.  
  50.  
  51. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  52. 2) What's the rx_intui.library? (Or when is this guy gonna do something with
  53.    video? Isn't that why everyone bought an Amiga?)
  54.  
  55.    The rx_intui.library is an ARexx function library. It allows an ARexx macro
  56. script to open screens/windows, and attach gadgets, menus, and open requesters
  57. in those windows. Furthermore, it allows an ARexx macro to interact with
  58. Intuition (ie do an "IDCMP loop"), thus interacting with a user in a familiar,
  59. and friendly windowed environment. In essense, it allows a programmer to write
  60. a Rexx macro with access to the Amiga's intuition library that other languages
  61. offer, but which Bill Hawes' ARexx server does not include.
  62.    There are a few other things that this library can do, but those are its
  63. main features.
  64.    The library cannot be used without Bill Hawes' ARexx package (available
  65. from several distributors).
  66.    Since this is a Rexx function library, any ARexx macro script has automatic
  67. access to the library's functions once the library is added to ARexx. (This can
  68. be accomplished using the dissidents FuncLib program. Copy "rx_intui.library"
  69. to your LIBS: drawer. Consult FuncLib.doc for use of that program.)
  70.  
  71. FuncLib rx_intui.library 0 -30 0
  72.  
  73.    This library requires the dissidents FileIO (requester.library) library.
  74. This is readily obtained on Fred Fish PD disks, or directly from dissidents.
  75. Otherwise, it should be included on this disk in the FileIO drawer. Copy it to
  76. LIBS:
  77.    For certain other functions, this library requires other dissidents libs,
  78. but only for those particular functions (as noted).
  79.    There are many example scripts included, and a section of this document
  80. describes them.
  81.  
  82.  
  83. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  84. 3) GetScreen()
  85.  
  86.    To open a custom screen, you use this function:
  87.  
  88. screen = GetScreen(title,mode,left,top,width,height,depth)
  89.  
  90.    title  - the text displayed in the screen's titlebar (default = NONE)
  91.    mode   - the screen's ViewModes (default = HIRES) as follows:
  92.             LORES = 0, HIRES = 32768, LACE = 4, HAM = 2048, HALFBRITE = 128
  93.             DUALPF = 1024, GENLOCK VIDEO = 2, SPRITES = 16384, PFBA = 64
  94.             Simply add up the ones that you want.
  95.    left   - the upper left x position (default = 0)
  96.    top    - the upper left y position (default = 0)
  97.    width  - the width of the screen in pixels (default = Gfx's Normal Columns)
  98.    height - the height of the screen in pixels (default = Gfx's Normal Rows)
  99.    depth  - the number of bitplanes (ie colors) (default = 3, ie 8 colors)
  100.  
  101.    If you don't specify an argument, (ie just the comma without any value),
  102. then you'll get a default value. For example, here I open a HIRES 16 color
  103. screen with a title of "My Screen". Note that the default width and height will
  104. be set by the lib, and takes into account PAL as well as Interlace (if I
  105. specify LACE mode).
  106.  
  107. screen = GetScreen('My Screen',,,,,,4)
  108.  
  109.    This returns the address of the custom screen (which will be passed to other
  110. lib functions), or '' if the screen didn't open.
  111.    For all other lib functions that require the screen address to be passed,
  112. if '', then that function will do nothing or ignore this argument. This insures
  113. that if your screen doesn't open, you can't accidentally perform operations on
  114. a null pointer (ie all lib functions are always "safe" to call).
  115.    The lib will clip the screen's width and height no larger than the Normal
  116. Columns and Rows set by the graphics library.
  117.  
  118.  
  119. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  120. 4) GetWindow()
  121.  
  122.    To open a window, you use this function:
  123.  
  124. window = GetWindow(title,screen,left,top,width,height,extra,IDCMP,windFlags)
  125.  
  126.    title  - the text to appear in the window titlebar
  127.    screen - the screen upon which to open this window (default = WorkBench)
  128.    left   - the upper left x position (default = 0)
  129.    top    - the upper left y position (default = 0)
  130.    width  - the width of the window in pixels (default = screen's width)
  131.    height - the height of the window in pixels (default = screen's height)
  132.    extra  - these are the extra IDCMP flags for the window as follows:
  133.          CONVERT_RAW = 8    RAWKEY are converted to special COOKED KEY events
  134.          NO_SLEEP    = 16   If no msgs at window, returns instead of sleeps
  135.          GIMME_UP    = 32   Let's you hear about UP mousebutton events
  136.          NO_COLLECT  = 64   Reports each MOUSEMOVE instead of collecting them
  137.          GIMME_MOVE  = 128  Allows you to hear about MOUSEMOVE events
  138.          Simply add up the ones that you want. (default = none)
  139.    IDCMP  - the classes of Intuition messages which you want to receive
  140.             SIZEVERIFY = 1, NEWSIZE = 2, REFRESHWINDOW = 4, MOUSEBUTTONS = 8
  141.             MOUSEMOVE = 16, GADGETDOWN = 32, GADGETUP = 64, REQSET = 128
  142.             MENUPICK = 256, CLOSEWINDOW = 512, RAWKEY = 1024, REQVERIFY = 2048,
  143.             REQCLEAR = 4096, MENUVERIFY = 8192, NEWPREFS = 16384, DISKINSERTED
  144.             = 32768, DISKREMOVED = 65536, WBMESSAGE = 131072, ACTIVEWINDOW =
  145.             262144, INACTIVEWINDOW = 524288, DELTAMOVE = 1048576, TIMEOUT =
  146.             4194304 (TIMEOUT allows the WaitMsg routine to return after a
  147.             certain amount of time without user activity.)
  148.             Simply add up the ones that you want. (default = MOUSEBUTTONS,
  149.             GADGETDOWN, GADGETUP, MENUPICK, CLOSEWINDOW, and if you add a
  150.             proportional gadget MOUSEMOVE).
  151.    windFlags - the window flags as follows:
  152.             SIZE = 1, DRAG = 2, DEPTH = 4, CLOSE = 8, SIZEBRIGHT = 16, SIZE-
  153.             BOTTOM = 32, SIMPLE_REFRESH = 64, SUPER_BITMAP = 128, OTHER_REF =
  154.             192, BACKDROP = 256, REPORTMOUSE = 512, GIMMEZERO = 1024, BORDER-
  155.             LESS = 2048, ACTIVATE = 4096, RMBTRAP = 65536, NOCARE_REF = 131072,
  156.             SMART_REFRESH = 0
  157.             Simply add up the ones that you want. (default = SMART_REFRESH,
  158.             SIZE, DRAG, DEPTH, CLOSE, ACTIVATE, REPORTMOUSE)
  159.  
  160.    If you don't specify a parameter, then you'll get the default value. For
  161. example, here I open a window with no title on WorkBench. The lib will open
  162. the screen to full Workbench width and height (taking PAL into account).
  163. I get the default IDCMP and system gadgets.
  164.  
  165. window = GetWindow(,,,,,,,,,)
  166.  
  167.    This returns the address of the window (which will be passed to other
  168. lib functions), or '' if no window opened. If passed a screen of '', then it
  169. opens on WorkBench.
  170.  
  171.    For all other lib functions that require the window address to be passed,
  172. if '', then that function will do nothing.
  173.  
  174.    Note that when opening on WorkBench, this library expects the system font
  175. to be an 8 by 8 pixel font. If you open a window on a custom screen, the user's
  176. Preferences font setting no longer has to be set to an 8 by 8 font.
  177.    The lib will automatically clip the window's width and height to no larger
  178. than the screen upon which it is opened.
  179.  
  180.  
  181. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  182. 5) EndWindow()
  183.  
  184.    To close an opened window, simply call
  185.  
  186. err = EndWindow(window)
  187.  
  188.    where window is the address returned by GetWindow(). This automatically
  189. frees all menus and gadgets that you attached to the window. If window = '',
  190. then this does nothing.
  191.  
  192.  
  193. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  194. 6) EndScreen()
  195.  
  196.    To close an opened screen, simply call
  197.  
  198. err = EndScreen(screen)
  199.  
  200.    where screen is the address returned by GetScreen(). You should first close
  201. all windows open on the screen. If screen = '', then this does nothing.
  202.  
  203.  
  204. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  205. 7) AddMenu()
  206.  
  207.   To add a menu to an opened window, use this
  208.  
  209. menu = AddMenu(window,text,leftedge,width)
  210.  
  211.   window   - the window address as returned by GetWindow()
  212.   text     - the name of the menu (placed in the titlebar)
  213.   leftedge - how many pixels from the left window border to place the menu
  214.   width    - the width of the menu (in pixels)
  215.  
  216.   This will add a new menu to the window, so that you can start adding menu
  217. items to it. The first menu attached to the window will be menu #0. The second
  218. menu added will be #1, etc.
  219.   You should make the width as big as the width of the largest item name to be
  220. added to the menu, or the menu name itself (whichever is bigger). To calculate
  221. the width of an item or menu name, add 8 pixels for each character in the name.
  222. For example, if your menu name is "Project", the width would be 7 chars * 8 =
  223. 15 pixels wide. If you don't specify the width or leftedge, the library sets
  224. the width to the menu's name, and places it after the last added menu (ie
  225. automatically places the menu in a sensible position).
  226.   For example, here I add a menu called "Blort" and let the lib position it:
  227.  
  228. menu0 = AddMenu(window,'Blort',,)
  229.  
  230.   This returns the address of the added menu. If it can't be added, '' is
  231. returned. This does nothing if window is ''.
  232.  
  233.  
  234. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  235. 8) AddItem()
  236.  
  237. item = AddItem(menu,text,flags,exclude,IDCMP,commseq,window)
  238.  
  239.   This adds an item to a menu. The first item added is Item #0. The second
  240. item added is #1, etc. The lib automatically positions the item in the menu.
  241. You can add several items to a menu.
  242.  
  243.   menu    - the menu that the item is added to, as returned by AddMenu()
  244.   text    - the item's name
  245.   flags   - the item's flags are as follows:
  246.             CHECKIT = 1 (Put a checkmark before the item when it's selected)
  247.             CHECKED = 256 (Put the checkmark there now)
  248.             TOGGLECHECK = 8 (Each time its selected, toggle the checkmark)
  249.             COMMSEQ = 4 (Allow a Right Amiga key combo to select the item)
  250.             HIGHNONE = 192 (Don't highlight the item)
  251.             Simply add up the ones you want. (default = none of the above)
  252.   exclude - a mask of the other items to exclude when this one is selected
  253.             (default = no exclude)
  254.   IDCMP   - Extra flags that specify how the item effects IDCMP:
  255.             ISSUE CLOSE = 128 (This item sends a CLOSEWINDOW message when
  256.                                selected)
  257.             OK = 1 (CLOSEWINDOW state is OK as opposed to CANCEL)
  258.   commseq - the character to use in conjunction with the right Amiga key
  259.             (default = no commseq) Note that you should also set the COMMSEQ
  260.             flag as well.
  261.   window  - the window in which the menu was added, as returned by GetWindow()
  262.  
  263.   This returns the address of the added item so that you can add subitems to
  264. it. If it can't be added, '' is returned. If the menu or window = '', then this
  265. does nothing.
  266.  
  267.  
  268. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  269. 9) AddSub()
  270.  
  271. sub = AddSub(item,text,flags,exclude,IDCMP,commseq,window)
  272.  
  273.   This adds a subitem to an item. The first sub added is Sub #0. The second
  274. sub added is #1, etc. The lib automatically positions the subitem by its item.
  275. You can add several subitems to an item. The args are the same as AddItem()
  276. except that you pass the item to which to add the Sub, as returned by AddItem.
  277.  
  278.   This returns the address of the added subitem. If it can't be added, '' is
  279. returned. If the item or window = '', then this does nothing.
  280.  
  281.  
  282. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  283. 10) SetMenu()
  284.  
  285. oldMenu = SetMenu(window,newMenu)
  286.  
  287.   window  - the window to set the new menu strip in
  288.   newMenu - the address of menu #0 of the strip to be installed (if '' or no
  289.             arg, then a new strip is not installed)
  290.  
  291.   A menu strip is a series of menus that you added to the window.
  292.   This removes any menu strip that is presently installed in the window, and
  293. returns the address of its menu #0. Note that the old menu strip is not freed.
  294. If no previous strip was installed, it returns ''.
  295.   If you want to make several different menu "strips" for a window, and swap
  296. them at different times, use this function. The technique is to make menus
  297. using AddMenu(), AddItem(), and AddSub(). Save the address of the first menu
  298. (#0) installed. This is also the address of your strip since all the menus
  299. added together are linked to each other in the order that they were added.
  300. Now, call
  301.  
  302. oldMenu = SetMenu(window,,)
  303.  
  304. This clears out the window's strip so that you can now make a new strip of
  305. menus. Save the address of this new strip's menu #0. Now, when you want to
  306. swap strips, pass the address of the strip to install via SetMenu. Later, you
  307. will need to free the strips.
  308.  
  309.  
  310. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  311. 11) FreeMenu()
  312.  
  313. menu = FreeMenu(window)
  314.  
  315.   When you EndWindow(), the menu strip that is presently attached to the
  316. window is automatically freed (so you don't have to use this function if you're
  317. using only 1 menu strip.) On the other hand, any other strips that you made
  318. which are not currently attached, must be eventually freed using FreeMenu().
  319. Pass the address of menu #0 of the strip to free (ie the address of the strip).
  320.   Technique: FreeMenu the current menu, then SetMenu/FreeMenu for every other
  321. menu strip that you created. Then, you can close the window.
  322.  
  323.  
  324. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  325. 12) Text()
  326.  
  327. err = Text(text,window,x,y)
  328.  
  329.    This prints the passed text to the window at position (x,y).
  330.  
  331.    text   - the text to print
  332.    window - the window in which to print
  333.    x      - x position in pixels
  334.    y      - y position in pixels
  335.  
  336.    Uses the current penA color for the text, and the penB color for the back-
  337. ground behind the text, and the current drawmode. If window = '', it does
  338. nothing. If text = '' or no arg, then it just moves the pen position to (x,y).
  339. If x or y = '' or no arg, then that position is not changed. (Note that no
  340. args for both x and y allows you to print text from where you last left off.)
  341. The standard text font height is 8 pixels (for Topaz 8).
  342.  
  343.  
  344. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  345. 13) Erase()
  346.  
  347. err = Erase(charLength,window,x,y)
  348.  
  349.    This erases an area of the current text height at position (x,y). charLength
  350. is the number of characters to erase. The other args are as in Text().
  351.  
  352.  
  353. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  354. 14) SetDraw()
  355.  
  356. err = SetDraw(window,PenA,PenB,DrawMode)
  357.  
  358.    window   - in which to set the pens and mode
  359.    PenA     - the color # used for the text or line drawing (generally)
  360.    PenB     - the color # used for the background behind the text or line
  361.    DrawMode - determines how the pens are used:
  362.               JAM1 = 0 (Use only PenA), JAM2 = 1 (Use both pens), COMPLEMENT =
  363.               2 (Use complementary color #s), INVERSVID = 4 (reverse the pens)
  364.  
  365.    You should set the pens and drawmode before you start calling Text() or
  366. Erase() (unless you want the defaults of JAM1, PenA = 3, and PenB = 0). You
  367. change text/drawing colors and modes using this function.
  368.  
  369.  
  370. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  371. 15) AddGadg()
  372.  
  373. gadg=AddGadg(window,type,text,left,top,width,height,activation,ID,IDCMP,extra)
  374.  
  375.    This adds a gadget to the opened window at the specified position. You can
  376. add Proportional, String, or Boolean gadgets. Proportional gadgets are laid on
  377. their side (along the x axis) with a knob that moves left or right and a con-
  378. tainer of the size specified by width and height. String and Boolean gadgets
  379. have a border around them of the size specified by width and height (in pixels).
  380. Gadgets are placed at a position of pixel offsets from the top and left of
  381. the window's upper left corner (left = 0, top = 0). The passed text is printed
  382. to the left of the prop and string gadgets (so be sure to calculate the text
  383. width using Number of characters * 8, and add this to your desired left posi-
  384. tion.) For Bool gadgets, the text is printed (and centered) inside the gadget
  385. border (so be sure to make the gadget width as big as the text width).
  386.  
  387.    window    - in which to place the gadget (If '', then this does nothing)
  388.    type      - BOOL = 1, PROP = 3, STRING = 4
  389.    text      - string associated with the gadget. If no arg, then no gadg text
  390.    left      - # of pixels over from the left window border
  391.    top       - # of pixels down from the top of window
  392.    width     - the width of the gadget. For Bools, make this at least as big
  393.                as your text width (ie Number of characters * 8). For Props or
  394.                strings, any size will do (however long you want the gadg to be)
  395.    height     - The height of the gadget. This should be at least 12 pixels
  396.    activation - What intuition sends when the user selects, uses, and de-
  397.                 selects the gadget:
  398.                 RELVERIFY = 1 (Send a message when the user is done using it)
  399.                 IMMEDIATE = 2 (Send a message when user first starts using it)
  400.                 ENDGADGET = 4 (Send a REQCLEAR IDCMPspec when done)
  401.                 RIGHTBORD = 16 (Place the gadg inside the window right border)
  402.                 LEFTBORD = 32 (Place the gadg inside the window left border)
  403.                 TOPBORD  = 64 (Gadg in top border, title bar)
  404.                 BOTTOMBORD = 128 (in bottom border)
  405.                 TOGGLE = 256 (Each time user selects, toggle its ON/OFF state)
  406.                 STRCENTER = 512 (String Gadg - cursor stays in center of gadg)
  407.                 STRRIGHT = 1024 (String Gadg - cursor stays at right of gadg)
  408.                 Simply add up the ones you want
  409.    ID         - A number from 0 to 999 which you want associated with this
  410.                 gadget. Each gadget should have a unique ID number.
  411.    IDCMP      - Extra flags that specify how the gadget effects IDCMP:
  412.                 ISSUE_CLOSE = 128 (This gadget sends a CLOSEWINDOW message when
  413.                                   selected or released depending upon RELVERIFY
  414.                                   and IMMEDIATE. String gadgs only send on RELVERIFY)
  415.                 OK         = 1 (CLOSEWINDOW state is OK as opposed to CANCEL)
  416.                 AUTOSELECT = 2  For a string gadget, when the user hits RETURN,
  417.                              the next string gadget in the window is automatic-
  418.                              ally selected. You must specify RELVERIFY for this
  419.                              to work. Add the string gadgets in the order that
  420.                              you would like them to be selected, and set the
  421.                              AUTOSELECT of each string gadget that is to be
  422.                              autoselected. A string gadget without this flag
  423.                              set cannot be autoselected, nor auto select any
  424.                              other gadgets in the window.
  425.                 PRINTPROP  = 4  For a prop gadget, prints the value of the
  426.                              knob position as the user moves it. The value is
  427.                              printed to the left of the gadget, so you should
  428.                              leave 48 pixels space between gadgets along the
  429.                              x axis. For this to work properly, you should
  430.                              specify RELVERIFY and IMMEDIATE for the activation.
  431.                              Also, the window's extraIDCMP should NOT be
  432.                              NO_COLLECT or GIMME_MOVE.
  433.    extra      - For a string gadget, this is the number of maximum chars, MAX-
  434.                 CHARS that you want the user to be able to type in (limit =
  435.                 65525).
  436.                 For a prop, this is the number of possible pot values, RANGE,
  437.                 that you would like returned. For example, if you want only 4
  438.                 different values returned (ie 0, 1 ,2, or 3), then pass a 4.
  439.                 The largest # of values you can receive is 65,535 (0 to 65,535
  440.                 range). Note that a range of 1 (or 0), makes a knob that fills
  441.                 the entire prop (and cannot be moved).
  442.                 For a Bool, this is the initial selected state (1=On, 0=Off).
  443.  
  444.    The gadget border and text is rendered using the current PenA, PenB, and
  445. DrawMode, so you should set these values as desired before you add gadgets.
  446. Note that the border for Prop gadgets is set by Intuition, and so you have
  447. control over only the text color with props.
  448.  
  449.  
  450. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  451. 17) WaitMsg()
  452.  
  453. IDCMPspec=WaitMsg(window)
  454.  
  455.    This routine is the main function which drives your IDCMP loop. It gets
  456. the next intuition message that has arrived at your window, and puts the info
  457. into a form that your rexx script can deal with. If there is no message at the
  458. window, then your Rexx script is put to sleep until one arrives. The returned
  459. IDCMPspec is a Rexx Argstring which consists of 4 fields. You can use the
  460. standard Rexx command PARSE to place the 4 fields into separate variables.
  461. Note that you only receive messages for those IDCMP flags you set when you
  462. GetWindow() or ModIDCMP(). The first field of the IDCMPspec is the class. This
  463. tells you what type of message was received. For example, if you accept the
  464. default window IDCMP when you GetWindow() and you add some menus, when the
  465. user selects some menu item (or subitem), you'll receive an IDCMPspec whose
  466. first field is the value 2 for MENUPICK. If the user were to click the right
  467. mouse (SELECT) button, the returned IDCMPspec's class would be 3 for MOUSE-
  468. BUTTON. The other 3 fields of the IDCMPspec have different meanings depending
  469. upon what the class is. Here is a chart detailing what the fields are for all
  470. IDCMP flags (events):
  471.    A ---- means that this field has no meaning.
  472.  
  473.    flag          CLASS          FIELD #2          FIELD #3           FIELD #4
  474.  
  475. CLOSEWINDOW        0      state: 0=CANCEL,1=OK      ----               ----
  476.  
  477. GADGET             1            ID number        0=DOWN (SELECT)   For PROPs, this is the current step # of the knob
  478.                                                  1=UP (RELEASE)    For STRINGS, this is the entered text
  479.                                                                    For BOOLS, this is the On/Off state (On=1, Off=0)
  480.  
  481. MENUPICK           2             MENU #              ITEM #           SUBITEM # (if there is one)
  482.  
  483. MOUSEBUTTON        3         Left DOWN=0         x pixel position   y pixel position
  484.                              Left UP=1
  485.                              Right (Menu) DOWN=2
  486.                              Right UP=3
  487.    Note that in order to receive Menu buttons, you must specify RMBTRAP window flags.
  488.    To receive any UP button event, you must set GIMME_UP of the extraIDCMP flags
  489.    for the window.
  490.  
  491. MOUSEMOVE          4         x pixel position     y pixel position       ----
  492.    If DELTAMOVE, then x and y are a (signed) delta offset from the last position.
  493.    Note that in order to receive MOUSEMOVE, you must specify GIMME_MOVE of the
  494.    extraIDCMP flags for the window. Also, NO_COLLECT will effect whether you
  495.    receive moves while the user is moving the mouse, or whether you just receive
  496.    notice of his final position (where he stops moving the mouse). NO_COLLECT
  497.    is VERY intensive with Rexx and should only be used when you want the user
  498.    to do something like freehand drawing with the mouse.
  499.  
  500. RAWKEY            5       If RAW, this is Code.     If RAW, this         ----
  501.                           If COOKED, this is an     the qualifier.
  502.                           extended ascii char.      If COOKED, this is
  503.                                                     the modifier.
  504.    Note that to get the extended ascii char (ie COOKED KEYS), you must set
  505.    CONVERT_RAW of the extraIDCMP flags for the window. This translates an
  506.    RAWKEY press into a single ascii character. For all keys except the cursor,
  507.    function, and help keys, the ascii character is whatever the system keymap
  508.    returns, and the modifier = 0. So if the user holds the shift key and
  509.    presses the f key, 'F' is the char and modifier = 0. Alt keys may return
  510.    special chars. For the Function, cursor, and help keys, the values returned
  511.    are as follows:
  512.    Functions F1 to F10 = 0 to 9
  513.    Up cursor = 10
  514.    Down cursor = 11
  515.    Right cursor = 12
  516.    Left cursor = 13
  517.    Help = 14
  518.  
  519.    Furthermore, the modifier for these keys will be:
  520.    no ALT or SHIFT = 1
  521.    SHIFT = 2
  522.    ALT = 4
  523.  
  524.    Note that CONVERT_RAW ignores key releases.
  525.  
  526. REQ              6        If REQSET, -1                ----               ----
  527.                           If REQVERIFY, 0
  528.                           If REQCLEAR, 1
  529.  
  530. SIZE             7        If SIZEVERIFY, -1            ----               ----
  531.                           If NEWSIZE, 0
  532.                           If REFRESHWINDOW, 1
  533.  
  534. DISK             8        If INSERTED, 0               ----               ----
  535.                           IF REMOVED, 1
  536.  
  537. ACTIVE           9        If ACTIVEWINDOW, 0           ----               ----
  538.                           If INACTIVE, 1
  539.  
  540. TIMEOUT         10           ----                      ----               ----
  541.  
  542. MENUVERIFY      11           ----                      ----               ----
  543.  
  544. NEWPREFS        12           ----                      ----               ----
  545.  
  546. WBMSG           13           ----                      ----               ----
  547.  
  548.    Here's the way I envision that you'll implement your IDCMP loop in Rexx
  549. (ie receive and interprete events from intuition). You'll open a window and
  550. setup some way for the user to close the window (ie a system CLOSEGADGET, one
  551. of your gadgets set to ISSUE_CLOSE, or a menu item set to ISSUE_CLOSE). You'll
  552. initially set a variable (in this example called class) to 1. Then, you'll
  553. enter a big loop where you WaitMsg(), and process all received IDCMPspecs
  554. until you receive a class of 0 (CLOSEWINDOW). This will knock you out of the
  555. loop, and allow your program to terminate. Furthermore, you can examine the
  556. 2nd field of the CLOSEWINDOW (its state), to determine whether the user wants
  557. to do one thing (OK), or something else (CANCEL). The system CLOSEGADGET always
  558. returns CANCEL state, but you can set your own menu items or gadgets to return
  559. either OK or CANCEL state. Here's an example script:
  560.  
  561. /* An example of using the dissidents rx_intui.library */
  562.  
  563. /* Open a window on WB with default IDCMP, windowFlags, etc. */
  564. wind=GetWindow('My Window',,,,,,,,)
  565.  
  566. /* Here's our IDCMP loop. We just print all returned specs until we get */
  567. /* CLOSEWINDOW class (0). Start out class = 1 before we get into the loop. */
  568. class = 1
  569. DO WHILE class > 0
  570.  
  571. /* Get the next event or go to sleep waiting for one */
  572. spec=WaitMsg(wind)
  573.  
  574. /* Show what was returned. Could be right MOUSEBUTTON (down) or CLOSEWINDOW */
  575. SAY spec
  576.  
  577. /* divide the spec into 4 separate variables */
  578. PARSE var spec class part1 part2 part3
  579.  
  580. /* Here we would examine the class and do other things depending on it */
  581.  
  582. END
  583.  
  584. /* Close the window, thus freeing any resources for it. */
  585. /* Note that if no window opened, this does nothing. */
  586. err=EndWindow(wind)
  587.  
  588.  The TIMEOUT event allows the WaitMsg routine to return after a certain amount
  589. of time without user activity. You can set the TIMEOUT value from 0 to 255
  590. ticks. There are approximately 10 ticks per second but this depends upon system
  591. activity. So, a timeout value of 20 allows the WaitMsg() routine to wait about
  592. 2 seconds for any user activity before it returns with a TIMEOUT IDCMPspec.
  593. Note that you must set the TIMEOUT flag for your window IDCMP. Also, note that
  594. every time that you call WaitMsg(), the TIMEOUT is restarted. To disable or
  595. enable TIMEOUT, use SetTime(). This feature is useful if you want to have your
  596. IDCMP loop do something automatically on a regular basis. If not for TIMEOUT,
  597. when you called WaitMsg() and there were no messages from the user, WaitMsg()
  598. would put your macro to sleep until the user intervened. This way you can
  599. always return from WaitMsg() on a regular basis. There is only one problem with
  600. this scheme. The TIMEOUT only works if the window is active. If the user were
  601. to select some other window, then WaitMsg() really will go to sleep if no user
  602. activity. You could let the user take advantage of this as a way for him to
  603. completely halt your entire Rexx script at will. Or, you could ask to receive
  604. ACTIVEWINDOW and INACTIVEWINDOW. There is another flag (of the window's
  605. extraIDCMP) called NO_SLEEP. This flag allows WaitMsg() to never sleep. Instead,
  606. WaitMsg() immediately returns a TIMEOUT event (if there is no user activity in
  607. that window). The net result is a busy wait loop on the Amiga, but if you
  608. wanted some process to continually grind away, even when the user activates
  609. another window, you should set NO_SLEEP when you receive an INACTIVEWINDOW
  610. IDCMPspec. Later, when you receive an ACTIVEWINDOW IDCMPspec, you'll know that
  611. the user selected the window again, and you can clear NO_SLEEP (via ModIDCMP).
  612. Note that a TIMEOUT value of 0 really means 256 (ie 25.6 seconds which is the
  613. longest automatic timeout possible).
  614.  
  615.    If window = '', then this just returns CLOSEWINDOW with a CANCEL state.
  616.  
  617.  
  618. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  619. 17) ModIDCMP()
  620.  
  621. err=ModIDCMP(window,extra,IDCMP,windFlags)
  622.  
  623.     This is used to change the IDCMP and window flags of an open window. You
  624. can change the extraIDCMP and IDCMP flags as described in GetWindow(). For
  625. the windFlags, the only values that can be changed are RMBTRAP or NOCARE-
  626. REFRESH (ie to turn RMBTRAP on and NOCAREREFRESH off, windFlags = 65536, to
  627. turn it off as well as NOCAREREFRESH, windFlags = 0).
  628.  
  629.  
  630. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  631. 18) SetTime()
  632.  
  633. err=SetTime(window,timeout)
  634.  
  635.    This is used to set the timeout value in ticks (where each tick is about
  636. 1/10 of a second). If you pass a specific timeout value, then timeout is
  637. enabled. If you pass no timeout arg (ie an empty comma), then timeout is
  638. disabled.
  639.    For example, this sets a timeout of 1 second, enabling the feature:
  640.  
  641. err=SetTime(window,10)
  642.  
  643.    This disables the timeout feature completely:
  644.  
  645. err=SetTime(window,)
  646.  
  647.  
  648. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  649. 19) ModGadg()
  650.  
  651. gadg=ModGadg(window,gadg,text,activation,extra,init,ID,IDCMP,PenA,PenB,DrawMd)
  652.  
  653.    This is used to modify a gadget in a window. You can change the following
  654. parameters:
  655.  
  656.   text       - the text associated with the gadget. The new string cannot be
  657.                longer than the original string used when the gadget was made
  658.                (via AddGadg), or it will be truncated to that length. If you
  659.                pass no arg for this, then it is not changed.
  660.   activation - same as AddGadg(). If no arg, then it is not changed.
  661.   extra      - same as AddGadg(). If no arg, then it is not changed.
  662.                Note that for a string gadget, the number of chars cannot be
  663.                larger than the original value when the gadget was made. If so,
  664.                the value is unchanged.
  665.   THE NEXT 3 VALUES DO NOT APPLY TO THE BORDER OF A PROP GADGET.
  666.   PenA       - the new PenA value for the text and border. If no arg, it is
  667.                unchanged.
  668.   PenB       - the new PenB value for the text and border. If no arg, it is
  669.                unchanged.
  670.   DrawMd     - the new draw mode value for the text and border. If no arg, it
  671.                is unchanged.
  672.   init       - For a string gadget, this is the text to set inside the gadget.
  673.                If the text is longer than the gadget's maximum chars, it will
  674.                be truncated.
  675.                For a prop gadget, this is the step # upon which to set the
  676.                knob. For our preceding example, we set a RANGE of 4. Now, we
  677.                pass a value of 0, 1, 2, or 3. 0 would set the knob all the way
  678.                to the left, 3 would set it all the way to the right. The lib
  679.                does no error checking that your step # is one of the allowable
  680.                ranges, so a "wrap-around" effect may occur if you don't check.
  681.                For a Bool, this is ignored.
  682.   ID         - same as AddGadg(). If no arg, then it is not changed.
  683.   IDCMP      - same as AddGadg(). If no arg, then it is not changed.
  684.  
  685.    Note that when you first AddGadg(), you should make sure that your text,
  686. (and for a STRING gadget, the MAXCHARS), is as large as any string that you
  687. intend to pass to ModGadg() so that no truncation will occur.
  688.    If window or gadg = '', this does nothing.
  689.    Note: This routine may change the current PenA, PenB, and DrawMode if you
  690. update a PROP gadget's knob position with the PRINTPROP flag set.
  691.  
  692.  
  693. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  694. 20) GInfo()
  695.  
  696. value=GInfo(window,ID)
  697.  
  698.     This gets some info about the gadget with the passed ID. If the gadget
  699. with that ID is a Prop, this returns the step # that the knob is on. For a
  700. Bool, this returns its state (1=On,0=Off). For a string, this returns the
  701. text in the gadget. If window = '', or no gadget is found with the passed
  702. ID, this returns a null string.
  703.  
  704.  
  705. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  706. 21) OnOffGadg()
  707.  
  708. gadg=OnOffGadg(window,gadg,operation)
  709.  
  710.    This is used to turn a gadget On or Off, or to remove it altogether. If
  711. removed, it is freed. If passed a null window or gadg ptr, this does nothing.
  712.  
  713.    window    - the address of the window that the gadg is in
  714.    gadg      - the address of the gadg to affect (as returned by AddGadg)
  715.    operation - 0 for remove it, 1 for ON, 2 for OFF
  716.  
  717.    Note that this returns the address of the gadget if you are turning it ON
  718. or OFF, but it returns a NULL ptr if you remove the gadget. You should always
  719. assign the return to the same variable name as the passed gadget. This will
  720. insure that multiple calls to remove a certain gadget will be "safe".
  721.    If window or gadg = '', this does nothing.
  722.  
  723.  
  724. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  725. 22) MoveView()
  726.  
  727. err=MoveView(window,operation,data1,data2)
  728.  
  729.    This is used to move or size a window (or a window's screen). It is also
  730. used to beep (ie flash) the screen, or to activate a window. If window is null,
  731. this does nothing. No error checking is performed on the dx and dy values!
  732.  
  733. operation is 0=WindowToFront,1=ScreenToFront,2=WindowToBack,3=ScreenToBack,
  734.              4=ActivateWindow,5=DisplayBeep,6=SizeWindow,7=MoveScreen,
  735.              8=MoveWindow
  736. data1 and data2 are dx,dy if operation = MoveWindow, MoveScreen, or SizeWindow.
  737. Ignored otherwise.
  738.  
  739.  
  740. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  741. 23) Peek() and Poke()
  742.  
  743. value = PEEK(address,offset,size)
  744. value = POKE(value,address,offset,size)
  745.  
  746.    address = structure address to examine or modify
  747.    offset  = # of bytes to the desired field from the head of the structure
  748.    size    = 0 if the field is a BYTE size, 1 for WORD, or 2 for LONG
  749.    For POKE,
  750.    value   = the new value to install in that field
  751.  
  752.    These 2 routines let you modify or inspect fields of the structures that the
  753. lib returns. For example, you may wish to get the Window's RastPort address.
  754. This can be done by PEEKing the value at an offset of 50 bytes from the window
  755. address. (The window address is returned by GetWindow). Since the RastPort
  756. field of the window contains an address, it is a LONG. Therefore size = 2.
  757. So here is how we get the RastPort address of a window.
  758.  
  759. wind=GetWindow('My Window',,,,,,,,)
  760. rastport=PEEK(wind,50,2)
  761.  
  762.    These 2 do nothing if address is a null pointer. Since POKE can modify
  763. memory directly, do not use it unless you know what you're doing. Here are
  764. some other common uses for PEEK.
  765.  
  766. /* Get window's Screen address. Could be WorkBench's screen */
  767. screen=PEEK(wind,46,2)
  768.  
  769. /* Get window's ViewPort address. You must first find its screen. */
  770. viewport='' /* assume no viewport */
  771. screen=PEEK(wind,46,2)
  772. IF screen > '' THEN viewport=screen+44
  773.  
  774. /* Get Screen's ViewModes (as described in GetScreen). Note that this is a WORD size */
  775. modes=PEEK(screen,76,1)
  776. IF modes == 0 THEN SAY 'LoRES mode screen'
  777.  
  778. /* Get Screen's Width and Height */
  779. width=PEEK(screen,12,1)
  780. height=PEEK(screen,14,1)
  781.  
  782. /* Get Window's current Gadget strip address */
  783. gstrip=PEEK(wind,62,2)
  784.  
  785. /* Get Window's current LeftEdge, TopEdge, Width and Height */
  786. leftedge=PEEK(wind,4,1)
  787. top=PEEK(wind,6,1)
  788. width=PEEK(wind,8,1)
  789. height=PEEK(wind,10,1)
  790.  
  791. /* Get Window's current PenA #, PenB #, and DrawMode. These are BYTEs. You */
  792. /* must first find the window's Rastport. */
  793. rastport=PEEK(wind,50,2)
  794. penA=PEEK(rastport,25,0)
  795. penB=PEEK(rastport,26,0)
  796. drawmode=PEEK(rastport,28,0)
  797.  
  798.  
  799. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  800. 24) RedrawWind()
  801.  
  802. err = RedrawWind(window,flags)
  803.  
  804.    Can be used to redraws the window's gadgets, window frame, and set the
  805. mouse pointer.
  806.  
  807. Flags: (add up the ones you want)
  808. 1 = Draw a regular pointer
  809. 2 = Draw a Wait pointer
  810. 4 = Redraw window frames
  811. 8 = Refresh the Gadgets
  812.  
  813.  
  814. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  815. 25) FBox()
  816.  
  817. err=FBox(window,x1,y1,x2,y2)
  818.  
  819.    x1 = upper left x coord (default = inside of left border)
  820.    y1 = upper left y coord (default = below title bar)
  821.    x2 = lower right x coord (default = inside of right border)
  822.    y2 = lower right y coord (default = above bottom border)
  823.  
  824.    This is used to draw a filled box where x1 and y1 are the coordinates of
  825. the upper left corner of the box, and x2 and y2 are the coordinates of the
  826. lower right corner of the box. These values are in pixel offsets from the
  827. upper left corner of the window (where x=0, y=0). This function clips the
  828. values to within the window borders. It also checks that x1 < x2, and y1 < y2,
  829. swapping the coordinates if necessary. If window='', does nothing.
  830.    This draws the box using the current PenA and DrawMode for the window.
  831. See SetDraw().
  832.    Note that supplying no args makes a box as large as the window. Also, if
  833. you set PenA to the desired background color #, and drawmode to JAM1 or JAM2,
  834. then you can clear the entire window. Note that this can erase the gadgets as
  835. well, so you should RedrawWind().
  836.  
  837.  
  838. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  839. 26) Line()
  840.  
  841. err=Line(window,origX,origY,x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6)
  842.  
  843.    origX = x coord of where to start the line (default = use current x position)
  844.    origY = y coord of where to start the line (default = use current y position)
  845.    x1 = the x coord of the first point to which to draw
  846.    y1 = the y coord of the first point to which to draw
  847.    x2 = the x coord of the second point to which to draw
  848.    y2 = the y coord of the second point to which to draw
  849.    etc
  850.  
  851.    This function draws a series of lines (using the current pens and drawmode).
  852. The start of the line is at origX, origY. Then, the next two args define where
  853. to draw to. Subsequent args define further points to draw lines to. When there
  854. are no more args, the line drawing stops. You can draw up to 6, connected line
  855. segments with each call to this function. Note that you can draw even more
  856. connected line segments by several, subsequent calls to Line(). Don't specify
  857. a new origX or origY (ie just leave an empty comma) and drawing will continue
  858. from the last point. You can draw a single line segment by only giving origX,
  859. origY, x1, and x2. You can draw an unfilled box using this function as well.
  860.  
  861.  
  862. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  863. 27) Input()
  864.  
  865. response=Input(window,fileio,charLimit,prompt,init)
  866.  
  867.     This is a routine which allows you to get string input from the user via
  868. the window title bar. It is a handy alternative to a string gadget since it
  869. displays the prompt, gets the input, and restores the title bar without alter-
  870. ing your window display. It is ideal for getting string input without needing
  871. room in the window for a string gadget, or opening another window with a string
  872. gadget inside.
  873.     The user can cursor about the title bar, inserting, deleting chars, and use
  874. CTRL-x to clear the input.
  875.     This returns a NULL string if the user enters no input or presses the ESC
  876. key.
  877.     This also filters out any control characters, and uses the system keymap.
  878.  
  879.    window    - the window title bar to use
  880.    fileio    - a fileio (gotten via GetFIO)
  881.    charLimit - the number of characters the user can type before auto-return
  882.                (ie also the max # of characters that your string will contain)
  883.    prompt    - the prompt to display
  884.    init      - any initial input for the user to edit (must be less than
  885.                charLimit)
  886.  
  887.  
  888. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  889. 28) MsgOne() and MsgThree()
  890.  
  891. YesNo = MsgThree(window,string1,string2,string3)
  892. YesNo = MsgOne(window,string)
  893.  
  894.    These two are used to present an automessage to the user. MsgOne() only dis-
  895. plays one string and an OK gadget, and always returns 1. MsgThree() allows
  896. up to 3 lines of text, has an OK and NO gadget (returning 1 and 0 respectively)
  897. and centers the 3 lines in the requester. The 2nd or 3rd line can be omitted
  898. by passing null arguments for them.
  899.  
  900.  
  901. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  902. 29) IFFLoad() and IFFSave()
  903.  
  904.    These two load an IFF ILBM picture into a window, and save a window's
  905. rastport as an ILBM file, respectively. They both require the dissidents'
  906. ilbm.library to be in your LIBS: drawer. Without this library, a null pointer
  907. is returned.
  908.  
  909. window=IFFLoad(window,flags,filename)
  910.  
  911.   window - the address of the window to be loaded into, or 0 if you want the
  912.            lib to open a window/screen of the proper size for the ILBM. IFFLoad
  913.            returns the address of the window (or null pointer if it couldn't
  914.            open). You are responsible for closing any window and screen that
  915.            the lib opens for you. Use EndWindow() and EndScreen(). Remember, to
  916.            get the address of the window's screen, use Peek().
  917.   flags -  describes how to setup the load as follows:
  918.  
  919. 1 = MOUSEFLAG  (set for blank mouse pointer)
  920. 2 = SCREENFLAG    (set for hide screen title bar)
  921. 4 = COLORFLAG    (set for "Don't use loaded colorMap. Preserve present map.)
  922. 8 = NOSCALE        (set for "Don't scale a lower res pic to fill a larger bitmap)
  923. 16 = ADJUSTVIEW (do overscan if larger than standard Intuition view)
  924. 32 = FORCEPARSE (ignore IFF_DONE and force parsing to continue to end of file)
  925. 128 = ANIMFLAG (set if an ANIM file. The lib takes care of this one)           
  926.  
  927.   filename - the name of the IFF ILBM file to load
  928.  
  929.    If an error occurs during load (other than the window not opening), an error
  930. requester will appear to alert the user.
  931.  
  932. window=IFFSave(window,filename)
  933.  
  934.    This saves a window's contents as an ILBM file. If window is null, this does
  935. nothing. It posts an error requester if the save is not good.
  936.  
  937.  
  938. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  939. 30) Color()
  940.  
  941.     This brings up the dissidents color requester so that the user can adjust
  942. the screen's colors. This requires the dissidents color.library to be in your
  943. LIBS: drawer. This requester automatically adjusts to the number of colors in
  944. the screen, and has numerous features. See Color.doc for details, or contact
  945. dissidents.
  946.  
  947. err = Color(screen)
  948.  
  949.    This returns one of the following values:
  950.  
  951. 0  = the user selected OK
  952. 1  = the user selected CANCEL
  953. -4 = library in use, another application is displaying it
  954. -3 = passed a null screen address.
  955. -2 = screen has no depth (planes).
  956. -1 = color window can't open (probably out of memory). Buy some more.
  957.  
  958.  
  959. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  960. 31) Print()
  961.  
  962.     This uses the dissidents prtspool.library (copy to LIBS:) to print text
  963. or graphics. You can dump all or part of a window rastport to the printer,
  964. or print strings (with imbedded printer codes). The printing is spooled so
  965. that your application returns immediately (if memory permits) while the lib
  966. handles the print job. (Your macro could even end before the printing is
  967. complete.) Subsequent printing is queued and handled by the lib if the printer
  968. is in use. The preferences printer settings are used (ie color, printer name,
  969. port, etc). If not enough memory to spool, your macro will halt (with a WAIT
  970. pointer) until printing is complete. The user can abort at that time by press-
  971. ing the RIGHT MOUSE BUTTON while holding the ALT key.
  972.     This routine can also be used to abort all current print jobs by setting
  973. the ABORT flag.
  974.  
  975. err = Print(window, flags, extraCopies, data1, data2, data3, data4)
  976.  
  977. flags are: (Add up the ones that you desire)
  978. ABORT     = 512 (Abort all queued print jobs)
  979. BWFLAG    = 256 (For Graphics, when any requesters are presented, make PenA
  980.                  and PenB B+W temporarily.)
  981. GRAPHICS  = 64 (Print Graphics instead of Text)
  982. RAWWRITE  = 32 (for Text, don't translate printer codes or characters)
  983. NONEWLINE = 16 (for Text, don't force NEWLINE at end of each Print)
  984.  
  985.   If you want to dump the window rastport, set the GRAPHICS flag. Then data1
  986.   and data2 are the coords of the upper left corner of the area to print, and
  987.   data3 and data4 are the lower right corner coords (ie x1,y1,x2,y2). See
  988.   FBox() for an example of defining coords. The defaults are the same as in
  989.   FBox() (so if you don't specify the coords, you get the full rastport).
  990.   The BWFLAG is useful if you don't know whether your PenA and PenB are
  991.   similiar shades. If they are, any requesters will be indistinguishable
  992.   from the background. If you encounter this situation, (especially if you're
  993.   loading ILBMs), you should set this flag.
  994.  
  995.   If printing text, don't set GRAPHICS. Then, data1 is the string to print.
  996.   The subsequent args are ignored. The lib will force a NEWLINE at the end of
  997.   every Print(). If you don't want this, set NONEWLINE. You must then send
  998.   your own newline character (16) to flush the output when you desire a new
  999.   line. Normally, any imbedded printer escape codes (such as italics on, etc)
  1000.   will be translated to the proper codes for your printer. If you wish no
  1001.   translation of characters (ie especially for plotter control), set RAWWRITE.
  1002.   With RAWWRITE, what you send to Print() is exactly what gets shipped out.
  1003.  
  1004.   extraCopies is the number of extra copies beyond 1 that you desire. (ie pass
  1005.   a 0 if you only want the initial dump).
  1006.  
  1007.   If you want to ABORT current printing, just set the ABORT flag. extraCopies
  1008.   and data args are not needed.
  1009.  
  1010.  
  1011. «««««««««««««««««««««««««««««« FILEIO SECTION »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1012. 32) FileIO Section
  1013.  
  1014.     Here are the functions that pertain to using the File requester, and auto
  1015. requesters. Consult FileIO.doc for a more in-depth discussion of the FileIO
  1016. requester which has the ability to be used for filename selection, as well as
  1017. displaying a list of your own strings (limit 29 characters). It can do multiple
  1018. selections, reports on whether a file exists and whether it is a dir, can do
  1019. info suppression, pattern matching, display mounted devices (menu button),
  1020. customizable by the user via the 10 function keys, WB pattern matching, etc.
  1021.  
  1022. ******************************************************************************
  1023. fileio = GetFIO()
  1024.  
  1025.     This returns the address of a FileIO structure which is passed to several
  1026. other lib routines. You must get one of these once before using any routine
  1027. requiring a FileIO.
  1028.  
  1029.  
  1030. ******************************************************************************
  1031. fileio = EndFIO()
  1032.  
  1033.     This frees the FileIO structure after you are done using any FileIO
  1034. routines. It also frees any list and locks attached to the FileIO.
  1035.  
  1036.  
  1037. ******************************************************************************
  1038. path = FIOWindow(fileIO,title,flags,extension,path,obj-type,tooltypes,screen)
  1039. path = FIONW(fileIO,title,flags,extension,path,obj-type,tooltypes,window,x,y)
  1040.  
  1041.    These present the FileIO requester to the user, allowing him to make his
  1042. filename selection, and then returns the entire selected path (ie directory
  1043. and filename), or '' if CANCEL was selected (or some error occurred). An Error
  1044. could result from the requester being unable to open, or already in use (only
  1045. one program can have it open at any given time.)
  1046.  
  1047. the args are:
  1048.   the fileIO address (as returned by GetFIO)
  1049.   the window title (or '' if none)
  1050.   the FileIO flag settings (if no arg, these are not changed)
  1051.   the extension string to match (or '' if none) 14 chars MAX
  1052.   the initial path (could be a dir or filename). (If no arg, this is not changed)
  1053.         For SPECIAL_REQ, the string to initially set in the Name String Gadget
  1054.   the obj-type is the WB object to match where 1 = PROJECT and 2 = TOOL (no arg for ANY)
  1055.   the tooltypes string is for WB pattern matching (or no arg for none)
  1056.   the window (or screen if FIOWind) upon which to open the requester
  1057.   x,y are the upper left coordinate where the requester is to open (FIONW)
  1058.  
  1059.   The difference between FIOWindow() and FIONW() is that FIONW() requires you
  1060. to have a window open. FIOWindow() opens on the passed screen (if 0, then that
  1061. means WorkBench).
  1062.  
  1063.   Here are the numbers to specify for the FileIO Flags. Simply add up the ones
  1064. you want:
  1065. 1  = NO_CARE_REDRAW (Does not show the list of filenames when first opened)
  1066. 2  = USE_DEVICE_NAMES    (Displays the drives using AmigaDOS device names like DF0)
  1067. 4  = EXTENSION_MATCH (If you want an extension match. You must specify the string)
  1068. 8  = DOUBLECLICK_OFF (Double-clicking on a filename doesn't end the requester)
  1069. 16 = WBENCH_MATCH (Match ObjectType and ToolTypes string)
  1070. 32 = MATCH_OBJECTTYPE    (Don't ignore ObjectType. WBENCH_MATCH must also be set)
  1071. 64 = MULTIPLE_FILES (Multiple filename selection)
  1072. 128  = INFO_SUPPRESS (No .info files displayed)
  1073. 4096 = NO_ALPHA (Don't alphabetize the list of filenames)
  1074. 32768  = SPECIAL_REQ (Use the requester for non-disk use)
  1075.  
  1076.   Note that if you pass no arg for flags, then the flags settings will remain
  1077. the same as the last time that the fileio was used. (The very first time that
  1078. the fileio is used, all flags are clear).
  1079.  
  1080.    The SPECIAL_REQ flag is used to display a requester with a list of your own
  1081. strings. You use AddEntry() to create the list of strings. Then, FIONW() or
  1082. FIOWindow() return the selected string, or '' if CANCEL is selected (or an
  1083. error occurred). Errors could be caused by another program using the FileIO
  1084. requester, or the requester was unable to open (low on mem).
  1085.    For SPECIAL_REQ, replace the path arg with the desired string to be placed
  1086. in the Name Gadget. If no arg, then the gadget keeps its previous text.
  1087.  
  1088.    Note that only the DOUBLECLICK_OFF and MULTIPLE_FILES flags are effective
  1089. in conjunction with SPECIAL_REQ.
  1090.    Note that if you use one fileIO for both filename and custom reqs, you
  1091. should NewEntryList() before calling FIONW(), and you will have to NewEntry-
  1092. List() and make the custom list each time before using SPECIAL_REQ. You could
  1093. of course GetFIO() two fileIOs and use one for filename and the other for
  1094. SPECIAL_REQ.
  1095.    Also note that this function clears any RMBTRAP of your window, so you
  1096. should reset that via ModIDCMP() if desired.
  1097.    For filename selection, when this routine returns you should check the
  1098. FileIO's FILESIZE and the first byte of the FILENAME fields to see whether
  1099. the user has chosen a filename, and whether it already exists. This allows
  1100. you to protect against overwriting existing files, or trying to load non-
  1101. existant files. If the user has chosen a file, then the first byte of FILENAME
  1102. is not 0. If the file exists, then FILESIZE (LONG) is not 0; it is the size
  1103. of the file.
  1104.  
  1105. choose=Peek(fileIO,2,0)
  1106. IF choose > 0 THEN SAY 'User selected a file'
  1107. IF choose == 0 THEN SAY 'User selected a directory only, or no selection at all'
  1108.  
  1109. size=Peek(fileIO,240,2)
  1110. IF size == 0 THEN SAY 'This filename does not exist'
  1111. IF size > 0 THEN SAY 'This file exists and it is 'size' bytes.'
  1112.  
  1113.    If you're about to save a file, you would also want to compare the FileIO's
  1114. FREEBYTES (which tells how much room is on the chosen disk) against the number
  1115. of bytes that you intend to write to the disk. If you're going to overwrite an
  1116. existing file, don't forget to add FILESIZE to FREEBYTES before you compare.
  1117.  
  1118. /* Let's say that I want to write 30 bytes using the returned filename. */
  1119. /* I presented the req to the user and he made his selection. I got the */
  1120. /* size, and checked to see if the user made a selection of a file (not dir). */
  1121. numOfbytes=30
  1122. diskspace=Peek(fileIO,236,2)
  1123. diskspace=diskspace+size
  1124. IF numOfbytes < diskspace OR numOfbyte == diskspace THEN DO
  1125.  /* write the data */
  1126. END
  1127.  
  1128.     For SPECIAL_REQ, the FILESIZE field contains the ID number of the string
  1129. that the user selected (or the last string selected for MULTIPLE_FILES). This
  1130. will be -1 if the string is not one of the ones that you presented in the list
  1131. (ie he typed his own string into the Name Gadget).
  1132.  
  1133.  
  1134. *********************************************************************
  1135. entryNum=AddEntry(fileIO,ID,string)
  1136.  
  1137.   This adds an entry to a FileIO's list.
  1138.  
  1139. args are:
  1140.   the fileIO address (as returned by GetFIO)
  1141.   ID is any number you want associated with the string (ie not a string variable)
  1142.   string is the string to be added and displayed
  1143.  
  1144.  
  1145. **************************************************************************
  1146. error=NewEntryList(fileIO)
  1147.  
  1148.   Clears out any previous list in the fileio.
  1149.  
  1150.  
  1151. **************************************************************************
  1152. error=ClearEntries(fileIO)
  1153.  
  1154.   Doesn't actually clear the list. It just "de-selects" all previously selected
  1155. strings. This is used to clear selections after using MULTIPLE_FILES.
  1156.  
  1157.  
  1158. **************************************************************************
  1159. error=DeleteEntry(fileIO,string)
  1160.  
  1161.   Finds the string in the fileio's list, and removes it.
  1162.  
  1163.  
  1164. ***************************************************************************
  1165. string=FirstEntry(fileIO)
  1166.  
  1167.   Returns a NULL string '' if no more selected strings in the list. Otherwise,
  1168.   returns the next selected string. Must be used once before calling
  1169.   NextEntry(). NextEntry() is the same as FirstEntry(), but used for subsequent
  1170.   calls. These are used to locate all of the selections one at a time after
  1171.   MULTIPLE_FILES. See the FileIO.doc for details about MULTIPLE_FILES.
  1172.  
  1173.  
  1174. **************************************************************************
  1175. ID=IsEntryThere(fileIO,string)
  1176.  
  1177.  Returns -1 if string is not in the list. Otherwise, returns the ID associated
  1178.  with string.
  1179.  
  1180.  
  1181. **************************************************************************
  1182. path=GetPath(fileIO,filename)
  1183.  
  1184.   If filename is not NULL '', then this is copied to the fileio's filename
  1185.   buffer. Otherwise the filename is left as the user last selected. This
  1186.   returns the last selected path (ie disk:drawer/filename) spec. Useful for
  1187.   reconstructing the entire path when retrieving MULTIPLE_FILES. Note that
  1188.   this doesn't bring up the requester.
  1189.  
  1190.  
  1191. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  1192. 33) Demo scripts
  1193.  
  1194.   There are several demo scripts to show you how to use various aspects of the
  1195. library. Some are rather simple, others more complex.
  1196.   The first thing that you need to learn is how to open a window. Wind.rexx
  1197. does just that on WorkBench (with default IDCMP), then waits for ANY default
  1198. user input such as a MOUSEBUTTON or CLOSEWINDOW, and closes the window.
  1199.   Screen.rexx is almost the same except it opens a screen, and then opens the
  1200. window on that screen.
  1201.   Next, examine the text display functions. Text.rexx shows you how to print
  1202. text to a window. TextModes.rexx shows the effects of printing with different
  1203. pens and DrawModes.
  1204.   Now, look at the first instance of a minimal IDCMP loop, IDCMP.rexx. This
  1205. script just prints out all received events until CLOSEWINDOW. Note how I use
  1206. the PARSE command to break up the IDCMPspec into the 4 separate components.
  1207.   Next, you're ready to look at Menus.rexx which shows you how to setup a menu.
  1208.   Msg.rexx and Msg3.rexx show how to post some autoRequesters in a window.
  1209.   Peek.rexx shows how to use Peek().
  1210.   At this point, you're ready for Gadg.rexx. This script details several
  1211. features of the lib's gadget handling. Study this script carefully as it shows
  1212. how to setup a PROP, STRING, and BOOL gadget. Also, I start to do some things
  1213. inside the IDCMP loop which is where all of your work will be done.
  1214.   Box.rexx shows how to draw a filled box, and demos a use for this. Line.rexx
  1215. demos using the Line() function to draw an unfilled box.
  1216.   TimeOut.rexx demos the automatic timeout of WaitMsg(). Observe the script
  1217. running for several seconds. Note how this feature lets me do something without
  1218. intervention from the user.
  1219.   Keys.rexx shows how to get input from the keyboard. It just prints each key
  1220. that you press, including function, cursor, and help keys. Note that I had to
  1221. modify the IDCMP of the window since RAWKEY is not one of the defaults. I
  1222. could have just specified the IDCMP when I called GetWindow() instead of passing
  1223. a null argument then, but I wanted to show you how to use ModIDCMP().
  1224.   Input.rexx shows how to get a user input string from the window title bar,
  1225. which is a handy alternative to throwing up a string gadget just to get a
  1226. string, then removing it.
  1227.   Now, let's look at the file requester. FileIO.rexx opens the file requester
  1228. 3 times. Once with INFO_SUPPRESS (no .info files displayed), once only dis-
  1229. playing files that end in ".library" (by using EXTENSION_MATCH), and the last
  1230. time it only displays WorkBench tools (ie programs, not data files, that have
  1231. icons.) There are more things that you can do with this requester. Multiple.rexx
  1232. demos being able to select multiple filenames. When the requester is open, you
  1233. can select several filenames (selecting an already selected name "unselects"
  1234. it). This script then uses other functions to print out each one of the selected
  1235. files.
  1236.   Custom.rexx shows how to use the file requester to display a list of strings
  1237. for selection by the user.
  1238.   ILBM.rexx shows how to load an ILBM picture (letting the lib open a window
  1239. for it). Of course, you could load into an already open window. This script
  1240. also shows how to trap MENU MOUSEBUTTON events (ie Intuition no longer uses
  1241. this button to display menus. Now, I receive MENU DOWN and MENU UP MOUSEBUTTON
  1242. events.) Actually, I never receive any UP MOUSEBUTTONS because I never set the
  1243. GIMME_UP extraIDCMP flag for the window. This script also brings up the color
  1244. requester if you press the menu button after the picture is loaded.
  1245.  
  1246.  
  1247. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  1248. A) Rexx Error Handling
  1249.  
  1250.    The Rexx server's function library facilities were obviously not labored
  1251. over when the server was written. The handling of error returns from a func-
  1252. tion library causes the complete abort of the Rexx macro script (to the best
  1253. of my knowledge). If the Rexx function library allowed the macro to allocate
  1254. resources (such as this lib allows you to open windows, etc), then there is
  1255. no way for your macro to free the resources after Rexx stops it. For this
  1256. reason, the lib always returns success to the server, but null pointers when
  1257. an error occurs. All lib routines that operate on structures do nothing (ie are
  1258. safe) if passed a null pointer. This makes it possible for you to plod on if
  1259. an error occurs so that you can later free any resources that were allocated,
  1260. but also means that part of your macro may end up doing nothing. If there
  1261. wasn't enough memory to even open the window, an entire script could even do
  1262. nothing!!! Alas, I decided to forego returning error messages then have you
  1263. deal with allocated resources that can't be recovered until a reboot. Now, if
  1264. only this aspect of ARexx had been better implemented...
  1265.    The only error that may result in aborting of the Rexx script is if there is
  1266. not enough memory to even return a result to Rexx (or if you have an in-
  1267. correctly written script).
  1268.  
  1269.  
  1270. «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  1271. B) Final remarks
  1272.  
  1273.    Each of the lib's function names begins with 4, unique characters. If you're
  1274. writing a Rexx macro that has to be as "tight" as possible, you may call any
  1275. lib function using only the first 4 letters. For example,
  1276.  
  1277. window=GetW(,,,,,,,,,)
  1278.  
  1279. opens a default window on WorkBench. You also can eliminate all extra spaces
  1280. (like I did in the above example), and remove comments and blank lines from
  1281. the script.
  1282.    This library is meant to enhance the amiga's ARexx package by Bill Hawes,
  1283. allowing scripts to interact with a user in an Intuition environment. As such,
  1284. it offers the ability to create a completely interactive Rexx script which can
  1285. function as its own application program.
  1286.    The implementation of these functions reflects my own perception of what
  1287. some programmer (i.e. me) is likely to need. The most important considerations
  1288. were general functionality, speed, and size. By general functionality, I mean
  1289. that it was designed to let you interact with Intuition in a way that makes
  1290. it possible to do many typical things, but the esoteric (and fancy) manipula-
  1291. tion that other high level languages offer was excluded. Otherwise, the lib
  1292. would be much too big and slow, particularly for a SLOW interpreted language
  1293. like Rexx. It was written completely in 68000 with "aggressive optimization"
  1294. techniques. Consequently, its small size (about 7K) and speed help extend the
  1295. Rexx command set without imposing too severe an overhead.
  1296.    It may be that I implemented something in a manner which better suits my
  1297. needs than your own. For this reason, I welcome feedback from anyone experi-
  1298. menting with the library. Don't just call when you have a problem. If you have
  1299. ideas for additions, you may be able to convince me that it is a viable pro-
  1300. ject. Otherwise, I'll assume that this lib suits your needs as well.
  1301.