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