disable NOP on AROS.
[AROS-Contrib.git] / bgui / RexxBGUI / rexxbguilib.e
bloba42fd6156f4e0ea3e7721edf1d2222cbb9eb2c49
1 -> rexxbgui.library version 4.0
2 -> Date: June 24, 1999
3 -> Copyright © Jilles Tjoelker 1999
4 ->
5 -> New in V4.0:
6 -> * Version number bumped because of new functions.
7 -> * Added image buttons.
8 -> * Added a simple file requester function.
9 -> * Added a function to set up listview control with the arrow keys.
10 -> * Bug fixed: I once disabled CYC_Active but forgot to enable it again.
12 -> New in V3.0:
13 -> * Version number bumped because of new functions.
14 -> * Added separators and cycle gadgets.
15 -> * Added version testing functions bguirexxversion() and bguiversion().
17 -> New in V2.0:
18 -> * Version number bumped because of new functions.
19 -> * Added menus.
20 -> * Added progress bar (suggested by Ingo Musquinier) and indicator.
21 -> * Bug fixed: bguiwindow() did not get the argument count correctly. This
22 -> caused problems, because ARexx does not clear extra argument slots but
23 -> instead leaves in them what values happen to be contained in them from
24 -> previous function calls.
26 -> New in V1.1:
27 -> * New functions: bguiwinbusy(), bguiwinready(), bguipages(), bguimx(),
28 -> bguiactivategadget(), bguilist(), bguiaddcondit(), bguilistvaddentry(),
29 -> bguilistvcommand(), bguilistvreplacesel()
30 -> * New argument for bgui[hv]group(), equal, to force equal width or height
31 -> of the objects in the group
32 -> * New argument for bguiwindow(), pos, to open the window on another position
33 -> than centred on the screen
34 -> * Some nonfunctional tags removed
35 -> * New tags: BT_#?, PAGE_#?, MX_#?, TAG_IGNORE
36 -> * Better documentation
37 -> * Bug fixed: the library could be flushed from memory when a bguiopen() was
38 -> still outstanding.
39 -> * A control-C break is now accepted immediately in bguiwinwaitevent() and
40 -> bguiwait() and passed to ARexx.
41 -> * Bug fixed: BGUI 41.10 took the command name, which is always equal to "", for
42 -> the prefs filename. Fixed by temporarily setting the pr_Cli pointer to zero.
44 -> Look in the example scripts for more information.
45 -> General ARexx limitation: functions can only have up to 15 arguments.
47 /* ESCAPE SEQUENCES
48 ^^^ in bold */
49 -> Escape sequences can be used in most texts, including labels, frame titles
50 -> info object contents and listview entries. Frame titles may have shadow.
51 -> Listview entries and labels within objects can be text on background or
52 -> filltext on fill; when you change the colours it cannot be restored.
53 -> ESC='1b'x or just use the Esc key to put it in a string constant.
54 ->
55 -> ESC||ESC no operation; used to separate sequences ending in a digit
56 -> from normal digits.
57 -> ESC'u' underlined on (do not use for indicating a hotkey)
58 -> ESC'b' bold on
59 -> ESC'i' italics on
60 -> ESC'z' underscore on (can indicate the hotkey for a gadget, only visual
61 -> though, use BT_Key to make it work)
62 -> ESC'n' normal text
63 -> ESC'd'n set DrawInfo pen #n (2=text, 3=shine, 4=shadow, 5=selected gadget
64 -> fill, 6=text on fill, 7=background, 8=important text)
65 -> ESC'p'n set colour #n
66 -> ESC'D'n set DrawInfo pen #n as background
67 -> ESC'P'n set colour #n as background
68 -> ESC's' shadow on (additionally use ESC'd3')
69 -> ESC'-'ch turn something off (ch=u/b/i/s/z)
70 -> ESC'c' centre this and the following lines
71 -> ESC'r' right-justify this and the following lines
72 -> ESC'l' left-justify this and the following lines
73 -> '0a'x new line. This does not work for listview entries and frame titles.
75 /* FUNCTIONS
78 OPT OSVERSION=37,LARGE
80 MODULE 'rexx/storage','rexxsyslib','tools/rexxvar','rexx/rxslib',
81 'exec/nodes','exec/lists','exec/ports','dos/dos','icon',
82 'exec/tasks','exec/libraries','exec/memory','amigalib/lists',
83 'utility','dos/dosextens','utility/tagitem','tools/boopsi',
84 'intuition/intuition','intuition/gadgetclass','bgui',
85 'libraries/bgui','libraries/gadtools','workbench/workbench',
86 'libraries/asl','utility/hooks','tools/installhook',
87 'devices/inputevent','*strchr','*stricmp'
89 LIBRARY 'rexxbgui.library',4,0,'rexxbgui.library 4.0 (24.6.99)' IS
90 query(A0)
92 OBJECT idcmphook OF hook
93 window_object
94 listview
95 doarrowmessages
96 enter_id
97 ENDOBJECT
99 OBJECT tasknode
100 task:PTR TO tc
101 bguibase:PTR TO lib
102 lastid
103 stringspace:mlh -> MinList of stringbuffer
104 objects:mlh -> MinList of objnode
105 images:mlh -> MinList of imagenode
106 filereq
107 chipmem:PTR TO memblock
108 idcmphook:idcmphook
109 ENDOBJECT
111 OBJECT objnode
112 node:mln
114 ENDOBJECT
116 OBJECT imagenode
117 node:mln
118 dobj:PTR TO diskobject
119 ENDOBJECT
121 OBJECT memblock
122 next:PTR TO memblock
123 ENDOBJECT
125 CONST QUANTUM=4000
127 OBJECT stringbuffer
128 node:mln
129 ptr:LONG
130 space[QUANTUM]:ARRAY
131 ENDOBJECT
133 ENUM TAG_INT,TAG_STRING,TAG_OBJECT,TAG_MENU,TAG_MAX
135 OBJECT taginfo
136 name:PTR TO CHAR
137 value:LONG
138 type:LONG
139 ENDOBJECT
141 DEF templist[160]:LIST,tempstr[256]:STRING,tasknode=NIL:PTR TO tasknode
142 DEF rexxbguibase:PTR TO lib
144 PROC idcmphook_func(h:PTR TO idcmphook,wd_obj,imsg:PTR TO intuimessage)
145 DEF code,qual,wnd,reportid=0,ridflags=0
146 IF h.window_object<>wd_obj THEN RETURN
147 GetAttr(WINDOW_Window,wd_obj,{wnd})
148 code:=imsg.code; qual:=imsg.qualifier
149 IF imsg.class=IDCMP_RAWKEY
150 IF (code=67) OR (code=68)
151 reportid:=h.enter_id
152 ELSEIF code=$4C -> Arrow up
153 IF imsg.qualifier AND (IEQUALIFIER_LSHIFT OR IEQUALIFIER_RSHIFT)
154 SetGadgetAttrsA(h.listview,wnd,NIL,[LISTV_Select,LISTV_Select_Page_Up,0])
155 ELSEIF imsg.qualifier AND (IEQUALIFIER_LALT OR IEQUALIFIER_RALT)
156 SetGadgetAttrsA(h.listview,wnd,NIL,[LISTV_Select,LISTV_Select_First,0])
157 ELSE
158 SetGadgetAttrsA(h.listview,wnd,NIL,[LISTV_Select,LISTV_Select_Previous,0])
159 ENDIF
160 reportid:=h.doarrowmessages
161 ELSEIF code=$4D -> Arrow down
162 IF imsg.qualifier AND (IEQUALIFIER_LSHIFT OR IEQUALIFIER_RSHIFT)
163 SetGadgetAttrsA(h.listview,wnd,NIL,[LISTV_Select,LISTV_Select_Page_Down,0])
164 ELSEIF imsg.qualifier AND (IEQUALIFIER_LALT OR IEQUALIFIER_RALT)
165 SetGadgetAttrsA(h.listview,wnd,NIL,[LISTV_Select,LISTV_Select_Last,0])
166 ELSE
167 SetGadgetAttrsA(h.listview,wnd,NIL,[LISTV_Select,LISTV_Select_Next,0])
168 ENDIF
169 reportid:=h.doarrowmessages
170 ENDIF
171 ENDIF
172 ListCopy(templist,[WM_REPORT_ID])
173 listadd2(templist,reportid,ridflags)
174 domethod(wd_obj,templist)
175 ENDPROC
177 PROC query(rm:PTR TO rexxmsg) HANDLE
178 DEF rc=1,result=NIL,q:PTR TO CHAR,wnd:PTR TO window
179 DEF funcname
180 DEF obj,n,i,plong:PTR TO LONG
181 DEF dos:PTR TO doslibrary,temp2str[80]:STRING,c
182 DEF t:PTR TO taginfo,flags
184 MOVE.L A6,rexxbguibase
186 StrCopy(tempstr,rm.args[0],4)
187 IF stricmp(tempstr,'bgui') THEN Raise(0)
189 dos:=dosbase
190 utilitybase:=dos.utilitybase
191 rexxsysbase:=rm.libbase
192 funcname:=rm.args[0]+4
193 IF funcname[]="_" THEN funcname++
195 IF stricmp(funcname,'open')=0
196 /* success=bguiopen([taskname],[noerrorifopenfail])
197 0 1 2 */
198 -> This function opens bgui.library. Version 41 is required.
199 -> taskname indicates the name of the prefs file, default "ARexx".
200 -> Predefined are: ID.WIN(CLOSE|NOMORE|INACTIVE|ACTIVE).
201 -> If this function has not yet been called, all functions starting with
202 -> 'bgui' cause "Error return from function".
203 n:=rm.action AND $F
204 IF tasknode:=findtasknode(rm)
205 rc:=12
206 Raise(0)
207 ENDIF
208 IF n>=1
209 tasknode:=addtasknode(rm,rm.args[1])
210 ELSE
211 tasknode:=addtasknode(rm,NIL)
212 ENDIF
213 rc:=setRexxVar(rm,'ID.WINCLOSE','65536',STRLEN) OR
214 setRexxVar(rm,'ID.WINNOMORE','131072',STRLEN) OR
215 setRexxVar(rm,'ID.WININACTIVE','196608',STRLEN) OR
216 setRexxVar(rm,'ID.WINACTIVE','262144',STRLEN)
217 IF rc<>0
218 freetasknode(rm,tasknode)
219 tasknode:=0
220 ENDIF
221 IF tasknode
222 result:=CreateArgstring('1',STRLEN)
223 ELSE
224 IF n>=2 AND rm.args[2]
225 result:=CreateArgstring('0',STRLEN)
226 ELSE
227 rc:=12
228 ENDIF
229 ENDIF
230 ELSEIF (tasknode:=findtasknode(rm))=NIL
231 rc:=12
232 ELSEIF stricmp(funcname,'wait')=0
233 /* x=bguiwait()
234 0 */
235 -> Wait for most events; Control-C is passed trough to ARexx
236 -> (signal on break_c).
237 i:=Wait($FFFF0000 OR SIGBREAKF_CTRL_C)
238 IF i AND SIGBREAKF_CTRL_C
239 SetSignal(SIGBREAKF_CTRL_C,SIGBREAKF_CTRL_C)
240 ENDIF
241 rc:=0
242 result:=CreateArgstring('1',STRLEN)
243 ELSEIF stricmp(funcname,'winevent')=0
244 /* id=bguiwinevent(winobj,[destvar])
245 0 1 2 */
246 -> This function does not wait for events.
247 IF rm.action AND $F<1
248 rc:=17 -> Wrong number of arguments
249 ELSE
250 installhook(tasknode.idcmphook,{idcmphook_func})
251 obj:=Long(rm.args[1])
252 rc:=domethod(obj,[WM_HANDLEIDCMP])
253 StringF(tempstr,'\d',rc)
254 result:=CreateArgstring(tempstr,EstrLen(tempstr))
255 rc:=0
256 IF rm.args[2]
257 rc:=setRexxVar(rm,rm.args[2],tempstr,EstrLen(tempstr))
258 ENDIF
259 ENDIF
260 ELSEIF stricmp(funcname,'winwaitevent')=0
261 /* id=bguiwaitwinevent(winobj,[destvar])
262 0 1 2 */
263 -> This function is much more efficient than the bguiwinevent()/bguiwait()
264 -> combination.
265 IF rm.action AND $F<1
266 rc:=17 -> Wrong number of arguments
267 ELSE
268 installhook(tasknode.idcmphook,{idcmphook_func})
269 obj:=Long(rm.args[1])
270 i:=0
271 WHILE (rc:=domethod(obj,[WM_HANDLEIDCMP]))=WMHI_NOMORE
272 i:=Wait($FFFF0000 OR SIGBREAKF_CTRL_C)
273 EXIT i AND SIGBREAKF_CTRL_C
274 ENDWHILE
275 IF i AND SIGBREAKF_CTRL_C
276 SetSignal(SIGBREAKF_CTRL_C,SIGBREAKF_CTRL_C)
277 ENDIF
278 StringF(tempstr,'\d',rc)
279 result:=CreateArgstring(tempstr,EstrLen(tempstr))
280 rc:=0
281 IF rm.args[2]
282 rc:=setRexxVar(rm,rm.args[2],tempstr,EstrLen(tempstr))
283 ENDIF
284 ENDIF
285 ELSEIF stricmp(funcname,'winopen')=0
286 /* success=bguiwinopen(winobj)
287 0 1 */
288 -> This function must be used to open a window. When a window object is created,
289 -> it does not open automatically, unlike some other GUI engines' behaviour.
290 -> This enables you to do things like bguiwintabcycleorder() in time.
291 IF rm.action AND $F<>1 OR (rm.args[1]=NIL)
292 rc:=17 -> Wrong number of arguments
293 ELSEIF LengthArgstring(rm.args[1])<>4
294 rc:=18 -> Invalid argument to function
295 ELSE
296 obj:=Long(rm.args[1])
297 rc:=0
298 IF domethod(obj,[WM_OPEN])
299 result:=CreateArgstring('1',STRLEN)
300 ELSE
301 result:=CreateArgstring('0',STRLEN)
302 ENDIF
303 ENDIF
304 ELSEIF stricmp(funcname,'winclose')=0
305 /* x=bguiwinclose(winobj)
306 0 1 */
307 IF rm.action AND $F<>1 OR (rm.args[1]=NIL)
308 rc:=17 -> Wrong number of arguments
309 ELSEIF LengthArgstring(rm.args[1])<>4
310 rc:=18 -> Invalid argument to function
311 ELSE
312 rc:=0
313 obj:=Long(rm.args[1])
314 domethod(obj,[WM_CLOSE])
315 result:=CreateArgstring('1',STRLEN)
316 ENDIF
317 ELSEIF stricmp(funcname,'winbusy')=0
318 /* success=bguiwinbusy(winobj)
319 0 1 */
320 -> Use this function to set a busy pointer and zero-size requester that blocks
321 -> input on a window. It nests, i.e. the window will not be unblocked until
322 -> one bguiwinready() has been done for each bguiwinbusy() executed.
323 IF rm.action AND $F<>1 OR (rm.args[1]=NIL)
324 rc:=17 -> Wrong number of arguments
325 ELSEIF LengthArgstring(rm.args[1])<>4
326 rc:=18 -> Invalid argument to function
327 ELSE
328 obj:=Long(rm.args[1])
329 rc:=domethod(obj,[WM_SLEEP])
330 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
331 rc:=0
332 ENDIF
333 ELSEIF stricmp(funcname,'winready')=0
334 /* success=bguiwinready(winobj)
335 0 1 */
336 IF rm.action AND $F<>1 OR (rm.args[1]=NIL)
337 rc:=17 -> Wrong number of arguments
338 ELSEIF LengthArgstring(rm.args[1])<>4
339 rc:=18 -> Invalid argument to function
340 ELSE
341 obj:=Long(rm.args[1])
342 rc:=domethod(obj,[WM_WAKEUP])
343 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
344 rc:=0
345 ENDIF
346 ELSEIF stricmp(funcname,'window')=0
347 /* obj=bguiwindow(title,mastergroup,[scalew],[scaleh],[refwin],[scrname],[pos],[menu])
348 0 1 2 3 4 5 6 7 8 */
349 -> scale[wh]: 0% = minimum size, 100% = full screen
350 -> Precede scalew and/or scaleh with a minus sign to lock the dimension.
351 -> Locking both removes the size gadget.
352 -> refwin: the new window object will open on the same screen as refwin
353 -> pos 'S' centre on screen
354 -> 'M' centre on mouse pointer
355 -> 'T' top-left of the screen
356 -> 'W' centre on window
357 -> 'B' l t w h position in screen (pixel) coordinates
358 -> 'R' l t w h centre window on this box
359 -> '*' (anywhere) do not activate window upon opening (doesn't really
360 -> fit here but this saves arguments)
361 -> menu: concatenate bguimenu() results
362 rc,result:=createwindow(rm,templist,tempstr)
363 ELSEIF stricmp(funcname,'layout')=0
364 /* info=bguilayout(tag,value,[tag],[value],...)
365 0 1 2 3 4 */
366 -> Concatenate the return value of this to an object. It does not work for
367 -> VarSpace members.
368 IF (n:=rm.action AND $F)<2 OR Odd(n)
369 rc:=17
370 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL)
371 rc:=17 -> Wrong number of arguments
372 ELSE
373 rc:=0
374 ListCopy(templist,[-1])
375 FOR q:=1 TO n-1 STEP 2
376 t:=findtag(rm.args[q])
377 SELECT TAG_MAX OF t.type
378 CASE TAG_INT; listadd2(templist,t.value,Val(rm.args[q+1]))
379 DEFAULT; rc:=18 -> Invalid argument to function
380 ENDSELECT
381 EXIT rc<>0
382 ENDFOR
383 IF rc=0
384 ListAdd(templist,[TAG_DONE])
385 result:=CreateArgstring(templist,ListLen(templist)*4)
386 ENDIF
387 ENDIF
388 ELSEIF stricmp(funcname,'varspace')=0
389 /* info=bguivarspace(weight)
390 0 1 */
391 -> A weight controlled spacing in a group; 1<weight<1023
392 -> bguilayout() cannot be used on this.
393 IF (rm.action AND $F)<>1
394 rc:=17
395 ELSEIF rm.args[1]=NIL
396 rc:=17 -> Wrong number of arguments
397 ELSEIF (q:=Val(rm.args[1]))<=0
398 rc:=18 -> Invalid argument to function
399 ELSEIF q>=1024
400 rc:=18 -> Invalid argument to function
401 ELSE
402 rc:=0
403 result:=CreateArgstring({q},SIZEOF LONG)
404 ENDIF
405 ELSEIF stricmp(funcname,'hgroup')=0 OR ((q:=stricmp(funcname,'vgroup'))=0)
406 /* obj=bgui[hv]group(objects,[spacing],[offset],[title],[equal])
407 0 1 2 3 4 5 */
408 -> Double use of objects or forgotten '||' is caught -> error 12.
409 -> spacing/offset -1 narrow
410 -> -2 normal (default, unlike groupclass itself)
411 -> -3 wide
412 -> offset 'F' frame (required for a title)
413 -> equal 'W' all objects the same width
414 -> 'H' all objects the same height
415 -> 'S' all objects the same width and height
416 IF q=0
417 ListCopy(templist,[GROUP_Style,GRSTYLE_VERTICAL])
418 ELSE
419 SetList(templist,0)
420 ENDIF
421 IF (n:=rm.action AND $F)<1
422 rc:=17
423 ELSEIF rm.args[1]=NIL
424 rc:=17
425 ELSE
426 IF rm.args[2] AND (n>=2)
427 listadd2(templist,GROUP_Spacing,Val(rm.args[2]))
428 ELSE
429 listadd2(templist,GROUP_Spacing,GRSPACE_NORMAL)
430 ENDIF
431 IF rm.args[3] AND (n>=3)
432 IF Char(rm.args[3])="f" OR (Char(rm.args[3])="F")
433 ListAdd(templist,[
434 GROUP_HorizOffset,GRSPACE_NORMAL,
435 GROUP_VertOffset,GRSPACE_NORMAL,
436 FRM_Type,FRTYPE_DEFAULT
438 ELSE
439 listadd2(templist,GROUP_HorizOffset,Val(rm.args[3]))
440 listadd2(templist,GROUP_VertOffset,Val(rm.args[3]))
441 ENDIF
442 ENDIF
443 IF rm.args[4] AND (n>=4)
444 listadd2(templist,FRM_Title,addstring(rm.args[4]))
445 ENDIF
446 IF rm.args[5] AND (n>=5)
447 IF (c:=Char(rm.args[5]))="w" OR (c="W")
448 ListAdd(templist,[GROUP_EqualWidth,TRUE])
449 ELSEIF c="h" OR (c="H")
450 ListAdd(templist,[GROUP_EqualHeight,TRUE])
451 ELSEIF c="s" OR (c="S")
452 ListAdd(templist,[GROUP_EqualWidth,TRUE,GROUP_EqualHeight,TRUE])
453 ENDIF
454 ENDIF
455 rc:=0
456 plong:=rm.args[1]
457 q:=plong+LengthArgstring(rm.args[1])
458 WHILE q-plong>=4
459 obj:=plong[]
460 IF obj>0 AND (obj<1024)
461 listadd2(templist,GROUP_SpaceObject,obj)
462 ELSEIF obj=-1
463 IF (n:=ListLen(templist))>=4 AND (templist[n-1]=0) AND (templist[n-2]=0)
464 SetList(templist,n-2)
465 plong++
466 WHILE q-plong>=4
467 EXIT plong[]=0
468 listadd1(templist,plong[])
469 plong++
470 ENDWHILE
471 ListAdd(templist,[TAG_END,0])
472 ELSE
473 WHILE q-plong>=4
474 EXIT plong[]=0
475 plong++
476 ENDWHILE
477 ENDIF
478 ELSEIF removeobjnode(obj)
479 listadd2(templist,GROUP_Member,obj)
480 ListAdd(templist,[TAG_END,0])
481 ELSE
482 rc:=18 -> Invalid argument to function
483 ENDIF
484 plong++
485 ENDWHILE
486 ListAdd(templist,[TAG_DONE])
487 obj:=NIL
488 IF obj:=BgUI_NewObjectA(BGUI_GROUP_GADGET,templist)
489 IF rc
490 DisposeObject(obj)
491 ELSE
492 addobjnode(obj)
493 result:=CreateArgstring({obj},4)
494 ENDIF
495 ELSE
496 rc:=12
497 ENDIF
498 ENDIF
499 ELSEIF stricmp(funcname,'pages')=0
500 /* obj=bguipages(name,objects)
501 0 1 2 */
502 -> This function only creates OBJ.name, not ID.name.
503 -> Do not set PAGE_Active values which are out of range!
504 -> The usage of pages increases the number of objects that can be in a window
505 -> and therefore object creation time. The BGUI prefs program is an example of
506 -> this!
507 IF rm.action AND $F<>2 OR (rm.args[1]=NIL) OR (rm.args[2]=NIL)
508 rc:=17
509 ELSE
510 ListCopy(templist,[TAG_IGNORE,0])
511 rc:=0
512 plong:=rm.args[2]
513 q:=plong+LengthArgstring(rm.args[2])
514 WHILE q-plong>=4
515 obj:=plong[]
516 IF removeobjnode(obj)
517 listadd2(templist,PAGE_Member,obj)
518 ELSE
519 rc:=18 -> Invalid argument to function
520 ENDIF
521 plong++
522 ENDWHILE
523 ListAdd(templist,[TAG_DONE])
524 obj:=NIL
525 IF obj:=BgUI_NewObjectA(BGUI_PAGE_GADGET,templist)
526 IF rc
527 DisposeObject(obj)
528 ELSE
529 addobjnode(obj)
530 StringF(tempstr,'OBJ.\s',rm.args[1])
531 UpperStr(tempstr)
532 rc:=setRexxVar(rm,tempstr,{obj},4)
533 result:=CreateArgstring({obj},4)
534 ENDIF
535 ELSE
536 rc:=12
537 ENDIF
538 ENDIF
539 ELSEIF stricmp(funcname,'button')=0
540 /* obj=bguibutton(name,label)
541 0 1 2 */
542 -> As other "real" gadget creation functions, this one sets both ID.name
543 -> (compare with bguiwinevent() or bguiwinwaitevent() result) and OBJ.name (for
544 -> bguiget() and similar functions).
546 -> Prefix the keyboard shortcut with '_' in label. This also applies to other
547 -> gadgets. Take care that all shortcuts are different! BGUI does not check
548 -> this (MUI doesn't either). This type of bug is present in much software.
549 IF rm.action AND $F<>2
550 rc:=17 -> Wrong number of arguments
551 ELSE
552 SetList(templist,0)
553 StringF(tempstr,'ID.\s',rm.args[1])
554 UpperStr(tempstr)
555 tasknode.lastid:=tasknode.lastid+1
556 q:=tasknode.lastid
557 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
558 listadd2(templist,GA_ID,q)
559 listadd2(templist,LAB_Label,addstring(rm.args[2]))
560 listadd1(templist,TAG_DONE)
561 IF obj:=BgUI_NewObjectA(BGUI_BUTTON_GADGET,templist)
562 addobjnode(obj)
563 StringF(tempstr,'OBJ.\s',rm.args[1])
564 UpperStr(tempstr)
565 rc:=setRexxVar(rm,tempstr,{obj},4)
566 result:=CreateArgstring({obj},4)
567 ELSE
568 rc:=12
569 ENDIF
570 ENDIF
571 ELSEIF stricmp(funcname,'toggle')=0
572 /* obj=bguitoggle(name,label,[state])
573 0 1 2 3 */
574 IF (n:=rm.action AND $F)<2 OR (n>3)
575 rc:=17 -> Wrong number of arguments
576 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL)
577 rc:=17 -> Wrong number of arguments
578 ELSE
579 SetList(templist,0)
580 StringF(tempstr,'ID.\s',rm.args[1])
581 UpperStr(tempstr)
582 tasknode.lastid:=tasknode.lastid+1
583 q:=tasknode.lastid
584 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
585 listadd2(templist,GA_ID,q)
586 listadd2(templist,LAB_Label,addstring(rm.args[2]))
587 IF rm.args[3]
588 listadd2(templist,GA_SELECTED,Val(rm.args[3]))
589 ELSE
590 ListAdd(templist,[GA_SELECTED,FALSE])
591 ENDIF
592 ListAdd(templist,[GA_TOGGLESELECT,TRUE,TAG_DONE])
593 IF obj:=BgUI_NewObjectA(BGUI_BUTTON_GADGET,templist)
594 addobjnode(obj)
595 StringF(tempstr,'OBJ.\s',rm.args[1])
596 UpperStr(tempstr)
597 rc:=setRexxVar(rm,tempstr,{obj},4)
598 result:=CreateArgstring({obj},4)
599 ELSE
600 rc:=12
601 ENDIF
602 ENDIF
603 ELSEIF stricmp(funcname,'checkbox')=0
604 /* obj=bguicheckbox(name,[label],[state])
605 0 1 2 3 */
606 IF (n:=rm.action AND $F)<2 OR (n>3)
607 rc:=17 -> Wrong number of arguments
608 ELSEIF rm.args[1]=NIL
609 rc:=17 -> Wrong number of arguments
610 ELSE
611 SetList(templist,0)
612 StringF(tempstr,'ID.\s',rm.args[1])
613 UpperStr(tempstr)
614 tasknode.lastid:=tasknode.lastid+1
615 q:=tasknode.lastid
616 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
617 listadd2(templist,GA_ID,q)
618 IF rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
619 IF rm.args[3]
620 listadd2(templist,GA_SELECTED,Val(rm.args[3]))
621 ELSE
622 ListAdd(templist,[GA_SELECTED,FALSE])
623 ENDIF
624 ListAdd(templist,[TAG_DONE])
625 IF obj:=BgUI_NewObjectA(BGUI_CHECKBOX_GADGET,templist)
626 addobjnode(obj)
627 StringF(tempstr,'OBJ.\s',rm.args[1])
628 UpperStr(tempstr)
629 rc:=setRexxVar(rm,tempstr,{obj},4)
630 result:=CreateArgstring({obj},4)
631 ELSE
632 rc:=12
633 ENDIF
634 ENDIF
635 ELSEIF stricmp(funcname,'ibutton')=0
636 /* obj=bguiibutton(name,itype,idata,[label],[lplace])
637 0 1 2 3 4 5 */
638 -> Image button.
640 -> itype 'B' BGUI built-in
641 -> 'I' icon
642 -> 'M' bitmap image
643 -> 'V' vector (not yet implemented)
644 -> '-' (anywhere) no frame
645 -> '*' (anywhere) no spacing between frame and image
646 -> idata (itype='B') number, 'F'=getfile, 'P'=popup, 'D'=getpath
647 -> (itype='I') filename without .info
648 -> (itype='M') one or two results of bguiimage() (normal & selected)
649 -> (itype='V') string
650 -> lplace 'L' left (default)
651 -> 'R' right
652 -> 'A' above
653 -> 'B' below
654 rc,result:=createibutton(rm,tempstr,templist)
655 ELSEIF stricmp(funcname,'info')=0
656 /* obj=bguiinfo(name,[label],contents)
657 0 1 2 3 */
658 -> Non-clickable information object.
659 IF rm.action AND $F<>3
660 rc:=17 -> Wrong number of arguments
661 ELSE
662 SetList(templist,0)
663 StringF(tempstr,'ID.\s',rm.args[1])
664 UpperStr(tempstr)
665 tasknode.lastid:=tasknode.lastid+1
666 q:=tasknode.lastid
667 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
668 listadd2(templist,GA_ID,q)
669 listadd2(templist,INFO_FixTextWidth,TRUE)
670 listadd2(templist,FRM_Type,FRTYPE_DEFAULT)
671 IF rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
672 listadd2(templist,INFO_TextFormat,q:=rm.args[3])
673 n:=1; WHILE c:=q[]++ DO IF c="\n" THEN n++
674 listadd2(templist,INFO_MinLines,n)
675 listadd1(templist,TAG_DONE)
676 IF obj:=BgUI_NewObjectA(BGUI_INFO_GADGET,templist)
677 addobjnode(obj)
678 StringF(tempstr,'OBJ.\s',rm.args[1])
679 UpperStr(tempstr)
680 rc:=setRexxVar(rm,tempstr,{obj},4)
681 result:=CreateArgstring({obj},4)
682 ELSE
683 rc:=12
684 ENDIF
685 ENDIF
686 ELSEIF stricmp(funcname,'string')=0
687 /* obj=bguistring(name,[label],[contents],maxchars)
688 0 1 2 3 4 */
689 IF rm.action AND $F<>4
690 rc:=17 -> Wrong number of arguments
691 ELSEIF rm.args[1]=NIL OR (rm.args[4]=NIL)
692 rc:=17 -> Wrong number of arguments
693 ELSE
694 SetList(templist,0)
695 StringF(tempstr,'ID.\s',rm.args[1])
696 UpperStr(tempstr)
697 tasknode.lastid:=tasknode.lastid+1
698 q:=tasknode.lastid
699 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
700 listadd2(templist,GA_ID,q)
701 IF rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
702 IF rm.args[3]
703 listadd2(templist,STRINGA_TEXTVAL,rm.args[3])
704 ENDIF
705 listadd2(templist,STRINGA_MAXCHARS,Val(rm.args[4]))
706 listadd1(templist,TAG_DONE)
707 IF obj:=BgUI_NewObjectA(BGUI_STRING_GADGET,templist)
708 addobjnode(obj)
709 StringF(tempstr,'OBJ.\s',rm.args[1])
710 UpperStr(tempstr)
711 rc:=setRexxVar(rm,tempstr,{obj},4)
712 result:=CreateArgstring({obj},4)
713 ELSE
714 rc:=12
715 ENDIF
716 ENDIF
717 ELSEIF stricmp(funcname,'integer')=0
718 /* obj=bguiinteger(name,[label],[contents],[maxchars],[min],[max])
719 0 1 2 3 4 5 6 */
720 -> It is not guaranteed, that min<=bguiget(int,STRINGA_LongVal)<=max.
721 IF (n:=rm.action AND $F)>6
722 rc:=17 -> Wrong number of arguments
723 ELSEIF rm.args[1]=NIL
724 rc:=17 -> Wrong number of arguments
725 ELSE
726 SetList(templist,0)
727 StringF(tempstr,'ID.\s',rm.args[1])
728 UpperStr(tempstr)
729 tasknode.lastid:=tasknode.lastid+1
730 q:=tasknode.lastid
731 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
732 listadd2(templist,GA_ID,q)
733 IF n>=2
734 IF rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
735 ENDIF
736 IF n>=3 AND rm.args[3]
737 listadd2(templist,STRINGA_LONGVAL,Val(rm.args[3]))
738 ELSE
739 listadd2(templist,STRINGA_LONGVAL,0)
740 ENDIF
741 IF n>=4 AND rm.args[4]
742 listadd2(templist,STRINGA_MAXCHARS,Val(rm.args[4]))
743 ELSE
744 listadd2(templist,STRINGA_MAXCHARS,12)
745 ENDIF
746 IF n>=5 AND rm.args[5]
747 listadd2(templist,STRINGA_IntegerMin,Val(rm.args[5]))
748 ELSE
749 listadd2(templist,STRINGA_IntegerMin,$80000000)
750 ENDIF
751 IF n>=6 AND rm.args[6]
752 listadd2(templist,STRINGA_IntegerMax,Val(rm.args[6]))
753 ELSE
754 listadd2(templist,STRINGA_IntegerMax,$7FFFFFFF)
755 ENDIF
756 listadd1(templist,TAG_DONE)
757 IF obj:=BgUI_NewObjectA(BGUI_STRING_GADGET,templist)
758 IF rm.args[3]=NIL OR (n<3)
759 GetAttr(STRINGA_TEXTVAL,obj,{q})
760 SetGadgetAttrsA(obj,NIL,NIL,[STRINGA_LONGVAL,0,TAG_DONE])
761 q[]:=0
762 ENDIF
763 addobjnode(obj)
764 StringF(tempstr,'OBJ.\s',rm.args[1])
765 UpperStr(tempstr)
766 rc:=setRexxVar(rm,tempstr,{obj},4)
767 result:=CreateArgstring({obj},4)
768 ELSE
769 rc:=12
770 ENDIF
771 ENDIF
772 ELSEIF stricmp(funcname,'listview')=0
773 /* obj=bguilistview(name,[label],[stem],[type],[ncolumns])
774 0 1 2 3 4 5 */
775 -> type 'R' read-only
776 -> 'S' select (default)
777 -> 'D' drag'n'drop
778 -> In multi-column listview entries, the columns are separated by a tab
779 -> character. Attributes set with escape sequences do not continue from
780 -> one column to the next.
781 -> Optionally, you can append column weights to ncolumns, e.g. '3 10 45 45' to
782 -> create one small column and two wider ones.
783 IF (n:=rm.action AND $F)<1 OR (n>5)
784 rc:=17 -> Wrong number of arguments
785 ELSE
786 SetList(templist,0)
787 StringF(tempstr,'ID.\s',rm.args[1])
788 UpperStr(tempstr)
789 tasknode.lastid:=tasknode.lastid+1
790 q:=tasknode.lastid
791 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
792 listadd2(templist,GA_ID,q)
793 IF n>=2 AND rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
794 IF n>=4 AND (q:=rm.args[4])
795 c:=q[]
796 IF c="R" OR (c="r")
797 ListAdd(templist,[LISTV_ReadOnly,TRUE])
798 ELSEIF c="D" OR (c="d")
799 ListAdd(templist,[LISTV_ShowDropSpot,TRUE,BT_DragObject,TRUE,BT_DropObject,TRUE])
800 ENDIF
801 ENDIF
802 IF n>=5 AND (q:=rm.args[5])
803 listadd2(templist,LISTV_Columns,Val(q,{c}))
804 ListAdd(templist,[LISTV_DragColumns,TRUE])
805 q:=q+c
806 IF q[]>"9" OR (q[]<"0") THEN q++
807 plong:=tempstr
808 WHILE c
809 plong[]:=Val(q,{c})
810 EXIT c=0
811 q:=q+c
812 IF q[]>"9" OR (q[]<"0") THEN q++
813 plong++
814 ENDWHILE
815 IF plong<>tempstr THEN listadd2(templist,LISTV_ColumnWeights,tempstr)
816 ENDIF
817 listadd1(templist,TAG_DONE)
818 IF obj:=BgUI_NewObjectA(BGUI_LISTVIEW_GADGET,templist)
819 addobjnode(obj)
820 StringF(tempstr,'OBJ.\s',rm.args[1])
821 UpperStr(tempstr)
822 rc:=setRexxVar(rm,tempstr,{obj},4)
823 result:=CreateArgstring({obj},4)
824 IF n>=3 AND (q:=rm.args[3])
825 StringF(tempstr,'\s.COUNT',q)
826 UpperStr(tempstr)
827 IF getRexxVar(rm,tempstr,{n})=0
828 n:=Val(n)
829 FOR i:=0 TO n-1
830 StringF(tempstr,'\s.\d',q,i)
831 UpperStr(tempstr)
832 IF getRexxVar(rm,tempstr,{c})=0
833 ListCopy(templist,[LVM_ADDSINGLE,NIL])
834 listadd1(templist,c)
835 ListAdd(templist,[LVAP_TAIL,0])
836 domethod(obj,templist)
837 ENDIF
838 ENDFOR
839 ENDIF
840 ENDIF
841 ELSE
842 rc:=12
843 ENDIF
844 ENDIF
845 ELSEIF stricmp(funcname,'mx')=0
846 /* obj=bguimx(name,[label],stem,[type])
847 0 1 2 3 4 */
848 -> type 'R' radio buttons (default)
849 -> 'T' tabs
850 -> 'U' upside down tabs
851 -> The number of entries is limited to 63 (it must fit on the screen, so it's not
852 -> much of a limitation)
853 IF (n:=rm.action AND $F)<3 OR (n>4)
854 rc:=17 -> Wrong number of arguments
855 ELSEIF rm.args[1]=NIL OR (rm.args[3]=NIL)
856 ELSE
857 SetList(templist,0)
858 StringF(tempstr,'ID.\s',rm.args[1])
859 UpperStr(tempstr)
860 tasknode.lastid:=tasknode.lastid+1
861 q:=tasknode.lastid
862 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
863 listadd2(templist,GA_ID,q)
864 ListAdd(templist,[LAB_NoPlaceIn,TRUE])
865 IF n>=2 AND rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
866 IF n>=4 AND (q:=rm.args[4])
867 c:=q[]
868 IF c="T" OR (c="t")
869 ListAdd(templist,[MX_TabsObject,TRUE])
870 ELSEIF c="U" OR (c="u")
871 ListAdd(templist,[MX_TabsObject,TRUE,MX_TabsUpsideDown,TRUE])
872 ELSE
873 ListAdd(templist,[GROUP_Style,GRSTYLE_VERTICAL])
874 ENDIF
875 ENDIF
876 q:=rm.args[3]
877 StringF(temp2str,'\s.COUNT',q)
878 UpperStr(temp2str)
879 plong:=tempstr
880 IF getRexxVar(rm,temp2str,{n})=0
881 n:=Bounds(Val(n),0,63)
882 FOR i:=0 TO n-1
883 StringF(temp2str,'\s.\d',q,i)
884 UpperStr(temp2str)
885 IF getRexxVar(rm,temp2str,{c})=0
886 plong[]++:=addstring(c)
887 ENDIF
888 ENDFOR
889 IF plong=tempstr THEN plong[]++:=addstring('\eb\ei\euNO LABELS')
890 plong[]:=NIL
891 listadd2(templist,MX_Labels,tempstr)
892 listadd1(templist,TAG_DONE)
893 IF obj:=BgUI_NewObjectA(BGUI_MX_GADGET,templist)
894 addobjnode(obj)
895 StringF(tempstr,'OBJ.\s',rm.args[1])
896 UpperStr(tempstr)
897 rc:=setRexxVar(rm,tempstr,{obj},4)
898 result:=CreateArgstring({obj},4)
899 ELSE
900 rc:=12
901 ENDIF
902 ELSE
903 rc:=12
904 ENDIF
905 ENDIF
906 ELSEIF stricmp(funcname,'cycle')=0
907 /* obj=bguicycle(name,[label],stem,[type])
908 0 1 2 3 4 */
909 -> type 'P' force popup regardless of BGUI prefs
910 -> 'N' popup if enabled in BGUI prefs (default)
911 -> Pop on active setting is taken from BGUI prefs
912 -> The number of entries is limited to 63 (BGUI popup cycles truncate a list that
913 -> doesn't fit on the screen, so it's not much of a limitation)
914 IF (n:=rm.action AND $F)<3 OR (n>4)
915 rc:=17 -> Wrong number of arguments
916 ELSEIF rm.args[1]=NIL OR (rm.args[3]=NIL)
917 ELSE
918 SetList(templist,0)
919 StringF(tempstr,'ID.\s',rm.args[1])
920 UpperStr(tempstr)
921 tasknode.lastid:=tasknode.lastid+1
922 q:=tasknode.lastid
923 setRexxVar(rm,tempstr,StringF(temp2str,'\d',q),EstrLen(temp2str))
924 listadd2(templist,GA_ID,q)
925 ListAdd(templist,[LAB_NoPlaceIn,TRUE])
926 IF n>=2 AND rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
927 IF n>=4 AND (q:=rm.args[4])
928 c:=q[]
929 IF c="P" OR (c="p")
930 ListAdd(templist,[CYC_Popup,TRUE])
931 ENDIF
932 ENDIF
933 q:=rm.args[3]
934 StringF(temp2str,'\s.COUNT',q)
935 UpperStr(temp2str)
936 plong:=tempstr
937 IF getRexxVar(rm,temp2str,{n})=0
938 n:=Bounds(Val(n),0,63)
939 FOR i:=0 TO n-1
940 StringF(temp2str,'\s.\d',q,i)
941 UpperStr(temp2str)
942 IF getRexxVar(rm,temp2str,{c})=0
943 plong[]++:=addstring(c)
944 ENDIF
945 ENDFOR
946 IF plong=tempstr THEN plong[]++:=addstring('\eb\ei\euNO LABELS')
947 plong[]:=NIL
948 listadd2(templist,CYC_Labels,tempstr)
949 listadd1(templist,TAG_DONE)
950 IF obj:=BgUI_NewObjectA(BGUI_CYCLE_GADGET,templist)
951 addobjnode(obj)
952 StringF(tempstr,'OBJ.\s',rm.args[1])
953 UpperStr(tempstr)
954 rc:=setRexxVar(rm,tempstr,{obj},4)
955 result:=CreateArgstring({obj},4)
956 ELSE
957 rc:=12
958 ENDIF
959 ELSE
960 rc:=12
961 ENDIF
962 ENDIF
963 ELSEIF stricmp(funcname,'progress')=0
964 /* obj=bguiprogress(name,[label],min,max,[format],[type])
965 0 1 2 3 4 5 6 */
966 -> format: C-style format string for text in the gadget. Use %ld as a
967 -> placeholder for the number. Other percent signs must be doubled. Other
968 -> possibilities: "%03ld" forces a field size of three digits and pads on the
969 -> left with zeroes. "%lD" formats the number according to the language selected
970 -> and works only if locale.library is installed. "%lx" creates a hexadecimal
971 -> format.
972 -> BGUI 41.10 draws the text in the last colour used (if done=max then the
973 -> progress bar colour else the background colour) because of a bug, therefore
974 -> the format string should begin with ESC'd2'ESC||ESC (not necessarily 2).
975 -> ESC'D'n is also recommended if the text should be always visible on two
976 -> colour screens or screens with strange pens (e.g. non-newlook (no 3D look)).
977 -> If you don't want the problems of a format string, then you can use
978 -> bguiaddmap() to put the number in an indicator next to the progress bar.
979 -> type 'H' horizontal
980 -> 'V' vertical
981 -> The amount done is set to zero or the minimum.
982 IF (n:=rm.action AND $F)<4 OR (n>6)
983 rc:=17 -> Wrong number of arguments
984 ELSEIF rm.args[1]=NIL OR (rm.args[3]=NIL) OR (rm.args[4]=NIL)
985 rc:=17 -> Wrong number of arguments
986 ELSE
987 SetList(templist,0)
988 IF rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
989 listadd2(templist,PROGRESS_Min,Val(rm.args[3]))
990 listadd2(templist,PROGRESS_Max,Val(rm.args[4]))
991 IF n>=5 AND rm.args[5]
992 listadd2(templist,PROGRESS_FormatString,addstring(rm.args[5]))
993 ENDIF
994 IF n>=6 AND rm.args[6]
995 IF (c:=Char(rm.args[6]))="V" OR (c="v")
996 ListAdd(templist,[PROGRESS_Vertical,TRUE])
997 ENDIF
998 ENDIF
999 ListAdd(templist,[TAG_DONE])
1000 IF obj:=BgUI_NewObjectA(BGUI_PROGRESS_GADGET,templist)
1001 addobjnode(obj)
1002 StringF(tempstr,'OBJ.\s',rm.args[1])
1003 UpperStr(tempstr)
1004 rc:=setRexxVar(rm,tempstr,{obj},4)
1005 result:=CreateArgstring({obj},4)
1006 ELSE
1007 rc:=12
1008 ENDIF
1009 ENDIF
1010 ELSEIF stricmp(funcname,'indicator')=0
1011 /* obj=bguiindicator(name,[label],min,max,[level],[justify],[format])
1012 0 1 2 3 4 5 6 7 */
1013 -> Textual level indication gadget.
1014 -> justify 'L' left (default)
1015 -> 'C' centre
1016 -> 'R' right
1017 -> format: the same thing as in bguiprogress() except that setting colours is
1018 -> not necessary and that it has a default "%ld".
1019 rc,result:=createindicator(rm,templist)
1020 ELSEIF stricmp(funcname,'hseparator')=0
1021 /* obj=bguihseparator([title])
1022 0 1 */
1023 -> Horizontal separator line with optional title.
1024 -> Use in vertical groups only.
1025 -> This function does not take a name argument because modifying the object is not
1026 -> supported by RexxBGUI and not useful anyway.
1027 IF (n:=rm.action AND $F)>1
1028 rc:=17 -> Wrong number of arguments
1029 ELSE
1030 SetList(templist,0)
1031 listadd2(templist,SEP_Horiz,TRUE)
1032 IF n>=1 AND rm.args[1] THEN listadd2(templist,SEP_Title,addstring(rm.args[1]))
1033 listadd1(templist,TAG_DONE)
1034 IF obj:=BgUI_NewObjectA(BGUI_SEPARATOR_GADGET,templist)
1035 addobjnode(obj)
1036 rc:=0
1037 result:=CreateArgstring({obj},4)
1038 ELSE
1039 rc:=12
1040 ENDIF
1041 ENDIF
1042 ELSEIF stricmp(funcname,'vseparator')=0
1043 /* obj=bguivseparator()
1044 0 */
1045 -> Vertical separator line.
1046 -> Use in horizontal groups only.
1047 -> This function does not take a name argument because modifying the object is not
1048 -> supported by RexxBGUI and not useful anyway.
1049 IF rm.action AND $F
1050 rc:=17 -> Wrong number of arguments
1051 ELSE
1052 IF obj:=BgUI_NewObjectA(BGUI_SEPARATOR_GADGET,[SEP_Horiz,FALSE,TAG_DONE])
1053 addobjnode(obj)
1054 rc:=0
1055 result:=CreateArgstring({obj},4)
1056 ELSE
1057 rc:=12
1058 ENDIF
1059 ENDIF
1060 ELSEIF stricmp(funcname,'get')=0
1061 /* res=bguiget(obj,attr)
1062 0 1 2 */
1063 -> Error descriptions here:
1064 -> "Invalid keyword" if you supplied an attribute that RexxBGUI does not know -
1065 -> see "tags" further on in this file for which attributes are available.
1066 -> "Error return from function" if the obj parameter was not OK or if the
1067 -> object did not understand the attribute, for example an attribute of another
1068 -> gadget class or one that is not gettable;
1069 -> "Wrong number of arguments" if rm->rm_Action & 0xF is not 2 or if
1070 -> rm_Args[1] or rm_Args[2] is equal to zero.
1071 IF rm.action AND $F<>2 OR (rm.args[1]=NIL) OR (rm.args[2]=NIL)
1072 rc:=17 -> Wrong number of arguments
1073 ELSEIF LengthArgstring(rm.args[1])<>4
1074 rc:=18 -> Invalid argument to function
1075 ELSEIF (t:=findtag(rm.args[2]))=NIL
1076 rc:=33 -> Invalid keyword
1077 ELSE
1078 rc:=0
1079 SELECT TAG_MAX OF t.type
1080 CASE TAG_INT
1081 IF GetAttr(t.value,Long(rm.args[1]),{q})
1082 StringF(tempstr,'\d',q)
1083 result:=CreateArgstring(tempstr,EstrLen(tempstr))
1084 ELSE
1085 rc:=18 -> Invalid argument to function
1086 ENDIF
1087 CASE TAG_STRING
1088 IF GetAttr(t.value,Long(rm.args[1]),{q})
1089 IF q
1090 result:=CreateArgstring(q,StrLen(q))
1091 ELSE
1092 result:=CreateArgstring('',0)
1093 ENDIF
1094 ELSE
1095 rc:=18 -> Invalid argument to function
1096 ENDIF
1097 CASE TAG_OBJECT
1098 IF GetAttr(t.value,Long(rm.args[1]),{q})
1099 result:=CreateArgstring({q},4)
1100 ELSE
1101 rc:=18
1102 ENDIF
1103 DEFAULT; rc:=18 -> Invalid argument to function
1104 ENDSELECT
1105 ENDIF
1106 ELSEIF stricmp(funcname,'set')=0
1107 /* x=bguiset(obj,[refwin],tag,value,[tag],[value],...)
1108 0 1 2 3 4 5 6 */
1109 -> refwin: window object in which the gadget is located; necessary if you want
1110 -> visual updating. Specifying another window causes strange results...
1111 -> If you need to set more than 6 tags, split it out over multiple calls and
1112 -> omit refwin in all possibly except the last. Put at least one attribute
1113 -> causing visual update in the last call, if you want any update.
1114 IF (n:=rm.action AND $F)<4 OR Odd(n) OR (rm.args[1]=NIL)
1115 rc:=17 -> Wrong number of arguments
1116 ELSEIF LengthArgstring(rm.args[1])<>4
1117 rc:=18 -> Invalid argument to function
1118 ELSE
1119 wnd:=NIL
1120 IF rm.args[2]
1121 IF LengthArgstring(rm.args[2])=4
1122 GetAttr(WINDOW_Window,Long(rm.args[2]),{wnd})
1123 ENDIF
1124 ENDIF
1125 obj:=Long(rm.args[1])
1126 SetList(templist,0)
1127 rc:=0
1128 FOR q:=3 TO n-1 STEP 2
1129 t:=findtag(rm.args[q])
1130 IF t=NIL THEN rc:=33 -> Invalid keyword
1131 EXIT t=NIL
1132 SELECT TAG_MAX OF t.type
1133 CASE TAG_INT; listadd2(templist,t.value,Val(rm.args[q+1]))
1134 CASE TAG_STRING
1135 IF t.value=BT_Key
1136 PutChar(obj+40,Char(rm.args[q+1]))
1137 PutChar(obj+41,0)
1138 listadd2(templist,t.value,obj+40)
1139 ELSE
1140 listadd2(templist,t.value,rm.args[q+1])
1141 ENDIF
1142 CASE TAG_OBJECT
1143 IF LengthArgstring(rm.args[q+1])=4
1144 listadd2(templist,t.value,Long(rm.args[q+1]))
1145 ELSE
1146 rc:=18
1147 ENDIF
1148 DEFAULT; rc:=18 -> Invalid argument to function
1149 ENDSELECT
1150 EXIT rc<>0
1151 ENDFOR
1152 IF rc=0
1153 ListAdd(templist,[TAG_DONE])
1154 rc:=SetGadgetAttrsA(obj,wnd,NIL,templist)
1155 StringF(tempstr,'\d',rc)
1156 result:=CreateArgstring(tempstr,EstrLen(tempstr))
1157 rc:=0
1158 ENDIF
1159 ENDIF
1160 ELSEIF stricmp(funcname,'req')=0
1161 /* gad=bguireq(text,gadgets,[title],[refwin],[scrname])
1162 0 1 2 3 4 5 */
1163 -> RequestChoice/rtEZRequest() like requester. Use '|' to separate the gadgets.
1164 -> An asterisk adds return as a shortcut for the button it stands before and
1165 -> escape for the last one. Underscores can be used to prefix keyboard shortcuts.
1166 -> The window specified by refwin will automatically get a busypointer.
1167 -> Title defaults to refwin's title, or "BGUI Request" or its localized
1168 -> equivalent if wndobj is not given.
1169 -> Scrname does not work.
1170 -> gad: 1 for the first, 2 for the second, etc. and 0 for the last gadget.
1171 IF (n:=rm.action AND $F)<2
1172 rc:=17 -> Wrong number of arguments
1173 ELSE
1174 IF n>=5 AND rm.args[5]
1175 obj:=NIL
1176 obj:=LockPubScreen(rm.args[5])
1177 templist[]:=rm.args[1]
1178 rc:=bguireq(NIL,n>=3 AND rm.args[3],'\s',rm.args[2],templist,obj BUT NIL)
1179 IF obj THEN UnlockPubScreen(rm.args[5],obj)
1180 ELSE
1181 q:=NIL
1182 IF n>=4 AND rm.args[4]
1183 IF LengthArgstring(rm.args[4])=4
1184 obj:=Long(rm.args[4])
1185 GetAttr(WINDOW_Window,obj,{q})
1186 ENDIF
1187 ENDIF
1188 templist[]:=rm.args[1]
1189 rc:=bguireq(q,n>=3 AND rm.args[3],'\s',rm.args[2],templist)
1190 ENDIF
1191 StringF(tempstr,'\d',rc)
1192 result:=CreateArgstring(tempstr,EstrLen(tempstr))
1193 rc:=0
1194 ENDIF
1195 ELSEIF stricmp(funcname,'addmap')=0
1196 /* success=bguiaddmap(srcobj,dstobj,sattr,dattr)
1197 0 1 2 3 4 */
1198 -> This function connects two objects so srcobj will update dstobj's dattr
1199 -> when its sattr changes. This happens even without bguiwinevent().
1201 -> Example usages:
1202 -> Listview with connected string gadget:
1203 -> call bguiaddmap(obj.listv,obj.str,LISTV_Entry,STRINGA_TextVal)
1204 -> Listview to select a page (#of listview entries must be #of pages!!!):
1205 -> call bguiaddmap(obj.listv,obj.pages,LISTV_EntryNumber,PAGE_Active)
1207 -> The number of attributes that can cause notification (sattr) or be updated
1208 -> (dattr) is more limited than the number that can be used with bguiget() or
1209 -> bguiset(). If notification does not work, you'll have to fall back to the
1210 -> latter mechanism.
1212 -> There is no "initial" notification.
1214 -> Notification of LGO attributes may cause a crash. Using bguiset() is safer.
1215 IF rm.action AND $F<>4
1216 rc:=17 -> Wrong number of arguments
1217 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL) OR (rm.args[3]=NIL) OR (rm.args[4]=NIL)
1218 rc:=17 -> Wrong number of arguments
1219 ELSEIF LengthArgstring(rm.args[1])<>4
1220 rc:=18 -> Invalid argument to function
1221 ELSEIF LengthArgstring(rm.args[2])<>4
1222 rc:=18 -> Invalid argument to function
1223 ELSE
1224 ListCopy(templist,[BASE_ADDMAP])
1225 listadd1(templist,Long(rm.args[2]))
1226 listadd1(templist,templist+12)
1227 rc:=18 -> Invalid argument to function
1228 IF t:=findtag(rm.args[3])
1229 listadd1(templist,t.value)
1230 IF t:=findtag(rm.args[4])
1231 listadd1(templist,t.value)
1232 ListAdd(templist,[TAG_DONE])
1233 rc:=domethod(Long(rm.args[1]),templist)
1234 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1235 rc:=0
1236 ENDIF
1237 ENDIF
1238 ENDIF
1239 ELSEIF stricmp(funcname,'addcondit')=0
1240 /* success=bguiaddcondit(srcobj,dstobj,iftag,ifval,thtag,thval,eltag,elval)
1241 0 1 2 3 4 5 6 7 8 */
1242 -> This function connects two objects so srcobj will update dstobj depending
1243 -> on its ifattr. This is more or less equivalent to doing this when srcobj's
1244 -> iftag changes:
1245 -> IF bguiget(srcobj,iftag)=ifval THEN CALL bguiset(dstobj,thtag,thval),
1246 -> ELSE CALL bguiset(dstobj,eltag,elval)
1247 -> This happens even without bguiwinevent(). See also bguiaddmap().
1249 -> Integer tags only.
1251 -> Always test boolean tags for 0 and never for 1.
1253 -> Example usage:
1254 -> Yes/No setting that makes a choice impossible:
1255 -> call bguiaddcondit(obj.check,obj.mx,GA_Selected,0,MX_EnableButton,0,
1256 -> ,MX_DisableButton,0)
1258 -> MX_DisableButton,n will never change MX_Active. You have to check separately
1259 -> if the selection is still possible.
1261 -> If you init the checkbox to on, the first MX button will not be enabled
1262 -> initially. If you init the checkbox to off and set it to on after this call,
1263 -> it will be OK.
1264 IF rm.action AND $F<>8
1265 rc:=17 -> Wrong number of arguments
1266 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL) OR (rm.args[3]=NIL) OR (rm.args[4]=NIL)
1267 rc:=17 -> Wrong number of arguments
1268 ELSEIF rm.args[5]=NIL OR (rm.args[6]=NIL) OR (rm.args[7]=NIL) OR (rm.args[8]=NIL)
1269 rc:=17 -> Wrong number of arguments
1270 ELSEIF LengthArgstring(rm.args[1])<>4
1271 rc:=18 -> Invalid argument to function
1272 ELSEIF LengthArgstring(rm.args[2])<>4
1273 rc:=18 -> Invalid argument to function
1274 ELSE
1275 ListCopy(templist,[BASE_ADDCONDITIONAL])
1276 listadd1(templist,Long(rm.args[2]))
1277 rc:=18 -> Invalid argument to function
1278 IF t:=findtag(rm.args[3])
1279 listadd2(templist,t.value,Val(rm.args[4]))
1280 IF t:=findtag(rm.args[5])
1281 listadd2(templist,t.value,Val(rm.args[6]))
1282 IF t:=findtag(rm.args[7])
1283 listadd2(templist,t.value,Val(rm.args[8]))
1284 rc:=domethod(Long(rm.args[1]),templist)
1285 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1286 rc:=0
1287 ENDIF
1288 ENDIF
1289 ENDIF
1290 ENDIF
1291 ELSEIF stricmp(funcname,'listvgetentries')=0
1292 /* count=bguilistvgetentries(listvobj,stemname,[type])
1293 0 1 2 3 */
1294 -> type 'A' all
1295 -> 'S' selected only
1296 IF (n:=rm.action AND $F)<2 OR (rm.args[1]=NIL) OR (rm.args[2]=NIL)
1297 rc:=17 -> Wrong number of arguments
1298 ELSEIF LengthArgstring(rm.args[1])<>4
1299 rc:=18 -> Invalid argument to function
1300 ELSE
1301 rc:=0
1302 obj:=Long(rm.args[1])
1303 q:=rm.args[2]
1304 flags:=0
1305 IF rm.args[3] AND (n>=3)
1306 IF (c:=Char(rm.args[3]))="S" OR (c="s") THEN flags:=LVGEF_SELECTED
1307 ENDIF
1308 n:=0
1309 ListCopy(templist,[LVM_FIRSTENTRY,NIL])
1310 listadd1(templist,flags)
1311 i:=domethod(obj,templist)
1312 templist[]:=LVM_NEXTENTRY
1313 WHILE i
1314 StringF(tempstr,'\s.\d',q,n)
1315 UpperStr(tempstr)
1316 rc:=12
1317 EXIT setRexxVar(rm,tempstr,i,StrLen(i))
1318 rc:=0
1320 templist[1]:=i
1321 i:=domethod(obj,templist)
1322 ENDWHILE
1323 IF rc=0
1324 StringF(temp2str,'\s.COUNT',q)
1325 UpperStr(temp2str)
1326 IF setRexxVar(rm,temp2str,StringF(tempstr,'\d',n),EstrLen(tempstr))
1327 rc:=12
1328 ELSE
1329 rc:=0
1330 result:=CreateArgstring(tempstr,EstrLen(tempstr))
1331 ENDIF
1332 ENDIF
1333 ENDIF
1334 ELSEIF stricmp(funcname,'listvaddentry')=0
1335 /* success=bguilistvaddentry(listvobj,[refwin],entry,[where],[flags])
1336 0 1 2 3 4 5 */
1337 -> where 'H' head
1338 -> 'T' tail
1339 -> 'S' sorted
1340 -> number add before entry n
1341 -> flags 'S' select
1342 -> 'M' multiselect
1343 -> '+' make visible by scrolling list if necessary
1344 -> '-' do not make visible
1345 -> 'S' or 'M' makes visible automatically unless disabled with '-'
1346 IF (n:=rm.action AND $F)<3 OR (rm.args[1]=NIL) OR (rm.args[3]=NIL)
1347 rc:=17 -> Wrong number of arguments
1348 ELSEIF LengthArgstring(rm.args[1])<>4
1349 rc:=18 -> Invalid argument to function
1350 ELSE
1351 rc:=0
1352 wnd:=NIL
1353 IF rm.args[2]
1354 IF LengthArgstring(rm.args[2])=4
1355 GetAttr(WINDOW_Window,Long(rm.args[2]),{wnd})
1356 ENDIF
1357 ENDIF
1358 ListCopy(templist,[LVM_ADDSINGLE,NIL])
1359 listadd1(templist,rm.args[3])
1360 ListAdd(templist,[LVAP_TAIL])
1361 IF n>=4 AND rm.args[4]
1362 IF (c:=Char(rm.args[4]))>="0" AND (c<="9") OR (c="%") OR (c="$")
1363 ListCopy(templist,[LVM_INSERTSINGLE,NIL])
1364 listadd1(templist,Val(rm.args[4]))
1365 listadd1(templist,rm.args[3])
1366 ELSE
1367 ListCopy(templist,[LVM_ADDSINGLE,NIL])
1368 listadd1(templist,rm.args[3])
1369 IF c="H" OR (c="h")
1370 ListAdd(templist,[LVAP_HEAD])
1371 ELSEIF c="S" OR (c="s")
1372 ListAdd(templist,[LVAP_SORTED])
1373 ELSE
1374 ListAdd(templist,[LVAP_TAIL])
1375 ENDIF
1376 ENDIF
1377 ENDIF
1378 flags:=0
1379 IF n>=5 AND rm.args[5]
1380 IF (c:=Char(rm.args[5]))="s" OR (c="S")
1381 flags:=flags OR LVASF_SELECT
1382 ELSEIF c="m" OR (c="M")
1383 flags:=flags OR LVASF_MULTISELECT
1384 ENDIF
1385 IF strchr(rm.args[5],"+")
1386 flags:=flags OR LVASF_MAKEVISIBLE
1387 ELSEIF strchr(rm.args[5],"-")
1388 flags:=flags OR LVASF_NOT_VISIBLE
1389 ENDIF
1390 ENDIF
1391 listadd1(templist,flags)
1392 rc:=domethod(Long(rm.args[1]),templist)
1393 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1394 rc:=0
1395 IF wnd
1396 ListCopy(templist,[LVM_REFRESH,NIL])
1397 BgUI_DoGadgetMethodA(Long(rm.args[1]),wnd,NIL,templist)
1398 ENDIF
1399 ENDIF
1400 ELSEIF stricmp(funcname,'listvcommand')=0
1401 /* rc=bguilistvcommand(listvobj,[refwin],command)
1402 0 1 2 3 */
1403 -> command 'clear' delete all entries
1404 -> 'refresh' refresh listview and scroller
1405 -> 'sort'
1406 -> 'redraw' redraw all entries only
1407 -> 'remselected' also selects new entry
1408 IF (n:=rm.action AND $F)<>3 OR (rm.args[1]=NIL) OR (rm.args[3]=NIL)
1409 rc:=17 -> Wrong number of arguments
1410 ELSEIF LengthArgstring(rm.args[1])<>4
1411 rc:=18 -> Invalid argument to function
1412 ELSE
1413 rc:=0
1414 wnd:=NIL
1415 IF rm.args[2]
1416 IF LengthArgstring(rm.args[2])=4
1417 GetAttr(WINDOW_Window,Long(rm.args[2]),{wnd})
1418 ENDIF
1419 ENDIF
1420 c:=rm.args[3]
1421 IF stricmp(c,'clear')=0
1422 i:=LVM_CLEAR
1423 ELSEIF stricmp(c,'refresh')=0
1424 i:=LVM_REFRESH
1425 ELSEIF stricmp(c,'sort')=0
1426 i:=LVM_SORT
1427 ELSEIF stricmp(c,'redraw')=0
1428 i:=LVM_REDRAW
1429 ELSEIF stricmp(c,'remselected')=0
1430 i:=LVM_REMSELECTED
1431 ELSE
1432 rc:=33 -> Invalid keyword
1433 ENDIF
1434 IF rc=0
1435 SetList(templist,0)
1436 listadd2(templist,i,NIL)
1437 rc:=BgUI_DoGadgetMethodA(Long(rm.args[1]),wnd,NIL,templist)
1438 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1439 rc:=0
1440 ENDIF
1441 ENDIF
1442 ELSEIF stricmp(funcname,'listvreplacesel')=0
1443 /* success=bguilistvreplacesel(listvobj,[refwin],new)
1444 0 1 2 3 */
1445 -> Use this function to replace the first selected entry of a listview by another.
1446 -> If no entry is selected, a new one is added and selected.
1447 IF (n:=rm.action AND $F)<>3 OR (rm.args[1]=NIL) OR (rm.args[3]=NIL)
1448 rc:=17 -> Wrong number of arguments
1449 ELSEIF LengthArgstring(rm.args[1])<>4
1450 rc:=18 -> Invalid argument to function
1451 ELSE
1452 rc:=0
1453 wnd:=NIL
1454 IF rm.args[2]
1455 IF LengthArgstring(rm.args[2])=4
1456 GetAttr(WINDOW_Window,Long(rm.args[2]),{wnd})
1457 ENDIF
1458 ENDIF
1459 obj:=Long(rm.args[1])
1460 IF i:=domethod(obj,[LVM_FIRSTENTRY,NIL,LVGEF_SELECTED])
1461 ListCopy(templist,[LVM_REPLACE,NIL])
1462 listadd1(templist,i)
1463 listadd1(templist,rm.args[3])
1464 rc:=BgUI_DoGadgetMethodA(obj,wnd,NIL,templist)
1465 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1466 rc:=0
1467 ELSE
1468 ListCopy(templist,[LVM_ADDSINGLE,NIL])
1469 listadd1(templist,rm.args[3])
1470 ListAdd(templist,[LVAP_TAIL,LVASF_SELECT])
1471 rc:=domethod(obj,templist)
1472 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1473 rc:=0
1474 IF wnd
1475 ListCopy(templist,[LVM_REFRESH,NIL])
1476 BgUI_DoGadgetMethodA(Long(rm.args[1]),wnd,NIL,templist)
1477 ENDIF
1478 ENDIF
1479 ENDIF
1480 ELSEIF stricmp(funcname,'wintabcycleorder')=0
1481 /* success=bguiwintabcycleorder(winobj,objects)
1482 0 1 2 */
1483 -> RexxBGUI can only check the validity of the objects array to a limited
1484 -> extent: if a multiple of four spaces is intermixed wrong object pointers
1485 -> are used and a crash can be expected if tab is pressed in the first gadget.
1486 IF rm.action AND $F<>2
1487 rc:=17 -> Wrong number of arguments
1488 ELSEIF rm.args[1]=NIL
1489 rc:=17 -> Wrong number of arguments
1490 ELSEIF LengthArgstring(rm.args[1])<>4
1491 rc:=18 -> Invalid argument to function
1492 ELSEIF LengthArgstring(rm.args[2]) AND 3
1493 rc:=18 -> Invalid argument to function
1494 ELSE
1495 ListCopy(templist,[WM_TABCYCLE_ORDER])
1496 plong:=rm.args[2]
1497 n:=LengthArgstring(plong)/4
1498 FOR q:=0 TO n-1
1499 SetGadgetAttrsA(plong[q],NIL,NIL,[GA_TABCYCLE,TRUE,TAG_DONE])
1500 listadd1(templist,plong[q])
1501 ENDFOR
1502 ListAdd(templist,[NIL])
1503 obj:=Long(rm.args[1])
1504 rc:=domethod(obj,templist)
1505 StringF(tempstr,'\d',rc)
1506 result:=CreateArgstring(tempstr,EstrLen(tempstr))
1507 rc:=0
1508 ENDIF
1509 ELSEIF stricmp(funcname,'image')=0
1510 /* image=bguiimage(left,top,width,height,depth,data,planepick,planeonoff)
1511 0 1 2 3 4 5 6 7 8 */
1512 -> Creates an Image structure and returns the pointer. Use this for the idata
1513 -> parameter of bguiibutton() if itype='M'.
1515 -> Create these function calls with the MakeImage program.
1516 rc,result:=createimage(rm)
1517 ELSEIF stricmp(funcname,'menu')=0
1518 /* nm=bguimenu(type,[label],[commkey],[flags],[mutualexclude],[id])
1519 0 1 2 3 4 5 6 */
1520 -> Creates a NewMenu structure. Concatenate some of these and pass the result
1521 -> to bguiwindow(). If IDs (bguiwinevent()) are to be shared between gadgets
1522 -> and menuitems, create the gadgets first. Do not give a checkbox and a
1523 -> CHECKIT|TOGGLE item the same ID as it will be impossible to distinguish
1524 -> between them.
1526 -> type '1' menu title
1527 -> '2' item
1528 -> '3' subitem
1529 -> Omitting label gives a separator bar (automatically disabled).
1530 -> commkey: RAmiga-... shortcut
1531 -> flags 'DISABLED'
1532 -> 'CHECKIT' can be checked (not unchecked)
1533 -> 'CHECKED' has checkmark
1534 -> 'TOGGLE' specify CHECKIT too
1535 -> mutualexclude: selecting this CHECKIT item deselects these items
1536 -> (bit #x means item #x)
1537 -> id: may be either a number or a name of a variable
1538 -> number: selecting the item generates this ID
1539 -> variable: generate a new ID and store it in the variable
1540 -> Therefore you can write bguimenu(...,id.quit) and it will
1541 -> automatically share its ID with a gadget's, if it is present.
1543 -> Example:
1544 -> menu=bguimenu(1,'Project')||,
1545 -> bguimenu(2,'About...','?',,,id.about)||,
1546 -> bguimenu(2)||,
1547 -> bguimenu(2,'Quit','Q',,,id.quit)||,
1548 -> bguimenu(1,'Testing')||,
1549 -> bguimenu(2,'Have your cake',,'CHECKIT CHECKED','10'b,id.hyc)||,
1550 -> bguimenu(2,'Eat it too',,'CHECKIT','01'b,id.eit)||,
1551 -> bguimenu(2,'On or off???',,'CHECKIT TOGGLE',,id.ooo)||,
1552 -> bguimenu(2)||,
1553 -> bguimenu(2,'Subitems')||,
1554 -> bguimenu(3,'Subitem #1','1',,,id.sub1)||,
1555 -> bguimenu(3,'Subitem #2','2',,,id.sub2)||,
1556 -> bguimenu(3,'Subitem #3','3','DISABLED',,id.sub3)
1557 IF (n:=rm.action AND $F)>6 OR (n<1)
1558 rc:=17 -> Wrong number of arguments
1559 ELSEIF rm.args[1]=NIL
1560 rc:=17 -> Wrong number of arguments
1561 ELSE
1562 rc,result:=makenm(rm,tempstr)
1563 ENDIF
1564 ELSEIF stricmp(funcname,'windisablemenu')=0
1565 /* success=bguiwindisablemenu(winobj,id,state)
1566 0 1 2 3 */
1567 IF rm.action AND $F<>3
1568 rc:=17 -> Wrong number of arguments
1569 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL) OR (rm.args[3]=NIL)
1570 rc:=17 -> Wrong number of arguments
1571 ELSEIF LengthArgstring(rm.args[1])<>4
1572 rc:=18 -> Invalid argument to function
1573 ELSE
1574 ListCopy(templist,[WM_DISABLEMENU])
1575 listadd2(templist,Val(rm.args[2]),Val(rm.args[3]))
1576 rc:=domethod(Long(rm.args[1]),templist)
1577 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1578 rc:=0
1579 ENDIF
1580 ELSEIF stricmp(funcname,'wincheckitem')=0
1581 /* success=bguiwincheckitem(winobj,id,state)
1582 0 1 2 3 */
1583 IF rm.action AND $F<>3
1584 rc:=17 -> Wrong number of arguments
1585 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL) OR (rm.args[3]=NIL)
1586 rc:=17 -> Wrong number of arguments
1587 ELSEIF LengthArgstring(rm.args[1])<>4
1588 rc:=18 -> Invalid argument to function
1589 ELSE
1590 ListCopy(templist,[WM_CHECKITEM])
1591 listadd2(templist,Val(rm.args[2]),Val(rm.args[3]))
1592 rc:=domethod(Long(rm.args[1]),templist)
1593 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1594 rc:=0
1595 ENDIF
1596 ELSEIF stricmp(funcname,'winmenudisabled')=0
1597 /* rc=bguiwinmenudisabled(winobj,id)
1598 0 1 2 */
1599 -> rc 1 disabled
1600 -> 0 enabled
1601 -> -1 unknown menu/no menus at all attached to window
1602 IF rm.action AND $F<>2
1603 rc:=17 -> Wrong number of arguments
1604 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL)
1605 rc:=17 -> Wrong number of arguments
1606 ELSEIF LengthArgstring(rm.args[1])<>4
1607 rc:=18 -> Invalid argument to function
1608 ELSE
1609 ListCopy(templist,[WM_MENUDISABLED])
1610 listadd1(templist,Val(rm.args[2]))
1611 rc:=domethod(Long(rm.args[1]),templist)
1612 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1613 rc:=0
1614 ENDIF
1615 ELSEIF stricmp(funcname,'winitemchecked')=0
1616 /* rc=bguiwinitemchecked(winobj,id)
1617 0 1 2 */
1618 -> rc 1 checked
1619 -> 0 not checked
1620 -> -1 unknown menu/no menus at all attached to window
1621 IF rm.action AND $F<>2
1622 rc:=17 -> Wrong number of arguments
1623 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL)
1624 rc:=17 -> Wrong number of arguments
1625 ELSEIF LengthArgstring(rm.args[1])<>4
1626 rc:=18 -> Invalid argument to function
1627 ELSE
1628 ListCopy(templist,[WM_ITEMCHECKED])
1629 listadd1(templist,Val(rm.args[2]))
1630 rc:=domethod(Long(rm.args[1]),templist)
1631 result:=CreateArgstring(StringF(tempstr,'\d',rc),EstrLen(tempstr))
1632 rc:=0
1633 ENDIF
1634 ELSEIF stricmp(funcname,'activategadget')=0
1635 /* success=bguiactivategadget(gadget,refwin)
1636 0 1 2 */
1637 -> This call may fail, although that's usually not a severe problem...
1638 -> RexxBGUI can only check the validity of the objects to a limited extent.
1639 IF rm.action AND $F<>2
1640 rc:=17 -> Wrong number of arguments
1641 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL)
1642 rc:=17 -> Wrong number of arguments
1643 ELSEIF LengthArgstring(rm.args[1])<>4
1644 rc:=18 -> Invalid argument to function
1645 ELSEIF LengthArgstring(rm.args[2])<>4
1646 rc:=18 -> Invalid argument to function
1647 ELSE
1648 GetAttr(WINDOW_Window,Long(rm.args[2]),{wnd})
1649 rc:=ActivateGadget(Long(rm.args[1]),wnd,NIL)
1650 StringF(tempstr,'\d',rc)
1651 result:=CreateArgstring(tempstr,EstrLen(tempstr))
1652 rc:=0
1653 ENDIF
1654 ELSEIF stricmp(funcname,'close')=0
1655 /* x=bguiclose()
1656 0 */
1657 -> This MUST be called before exiting the script.
1658 freetasknode(rm,tasknode)
1659 rc:=0
1660 result:=CreateArgstring('1',STRLEN)
1661 ELSEIF stricmp(funcname,'readentries')=0
1662 /* success=bguireadentries(filename,stemname)
1663 0 1 2 */
1664 -> When using READLN(), EOF cannot be distinguished from an empty line.
1665 -> Therefore this function is present. It reads lines from a file to a stem
1666 -> in a format suitable for the listview gadget.
1667 IF (n:=rm.action AND $F)<>2 OR (rm.args[1]=NIL) OR (rm.args[2]=NIL)
1668 rc:=17 -> Wrong number of arguments
1669 ELSE
1670 rc:=0
1671 IF obj:=Open(rm.args[1],OLDFILE)
1672 q:=rm.args[2]
1673 n:=0
1674 WHILE Fgets(obj,tempstr,StrMax(tempstr))
1675 IF i:=strchr(tempstr,"\n") THEN i[]:=0
1676 StringF(temp2str,'\s.\d',q,n)
1677 UpperStr(temp2str)
1678 rc:=12
1679 EXIT setRexxVar(rm,temp2str,tempstr,StrLen(tempstr))
1680 rc:=0
1682 ENDWHILE
1683 Close(obj)
1684 IF rc=0
1685 StringF(temp2str,'\s.COUNT',q)
1686 UpperStr(temp2str)
1687 rc:=0
1688 IF setRexxVar(rm,temp2str,StringF(tempstr,'\d',n),EstrLen(tempstr))
1689 result:=CreateArgstring('0',1)
1690 ELSE
1691 result:=CreateArgstring('1',1)
1692 ENDIF
1693 ELSE
1694 rc:=0
1695 result:=CreateArgstring('0',1)
1696 ENDIF
1697 ELSE
1698 rc:=0
1699 result:=CreateArgstring('0',1)
1700 ENDIF
1701 ENDIF
1702 ELSEIF stricmp(funcname,'list')=0
1703 /* stemname=bguilist(stemname,entry0,[entry1],...)
1704 0 1 2 3 */
1705 -> This function allows you to place small lists (<=14 entries) for listviews
1706 -> directly in the gadget creation function, a bit like in E [e0,e1,...].
1707 -> It sets stemname.COUNT and stemname.x (0<=x<stemname.COUNT)
1709 -> Example:
1710 -> ...
1711 -> bguilistview('switcher',,bguilist('pnames','Single-Select','Multi-Select'))||,
1712 -> ...
1713 -> drop pnames. /* not really necessary */
1714 IF (n:=rm.action AND $F)<2 OR (rm.args[1]=NIL) OR (rm.args[2]=NIL)
1715 rc:=17 -> Wrong number of arguments
1716 ELSE
1717 FOR i:=0 TO n-2
1718 rc:=12
1719 EXIT rm.args[i]=NIL
1720 StringF(tempstr,'\s.\d',rm.args[1],i)
1721 UpperStr(tempstr)
1722 rc:=setRexxVar(rm,tempstr,rm.args[i+2],LengthArgstring(rm.args[i+2]))
1723 EXIT rc
1724 ENDFOR
1725 IF rc=0
1726 StringF(tempstr,'\s.COUNT',rm.args[1])
1727 UpperStr(tempstr)
1728 rc:=setRexxVar(rm,tempstr,StringF(temp2str,'\d',n-1),EstrLen(temp2str))
1729 IF rc=0 THEN result:=CreateArgstring(rm.args[1],LengthArgstring(rm.args[1]))
1730 ENDIF
1731 ENDIF
1732 ELSEIF stricmp(funcname,'listvcontrol')=0
1733 /* x=bguilistvcontrol([listvobj],[winobj],[arrows_id],[enter_id])
1734 0 1 2 3 4 */
1735 -> This function will cause the arrow keys up and down to control the the
1736 -> listview. They do only in the window specified. You can receive events for
1737 -> the arrow keys and for return and enter keys. You can specify either a number
1738 -> or a variable name which will receive a newly generated ID.
1739 -> Leaving out all arguments turns off this feature. If an argument is left out,
1740 -> (but there are arguments at all), that setting is not changed.
1741 -> Never ever set winobj if listvobj is invalid.
1742 -> Initially, winobj is zero and the other values are undefined.
1743 rc,result:=setlistvcontrol(rm,tempstr)
1744 ELSEIF stricmp(funcname,'filereq')=0
1745 /* path=bguifilereq([path],[title],[winobj],[flags],[patvar])
1746 0 1 2 3 4 5 */
1747 -> Subsequent calls will remember the path, the pattern and the requester's
1748 -> position and size, but not the title, the window object pointer and the flags.
1749 -> winobj: window object pointer. The requester will open on the same screen and
1750 -> the window will be locked like bguiwinbusy().
1751 -> flags 'DOSAVEMODE'
1752 -> 'DOPATTERNS' pattern gadget; a pattern may be used without it
1753 -> 'DRAWERSONLY'
1754 -> 'FILTERDRAWERS'
1755 -> 'REJECTICONS'
1756 -> patvar: name of a variable that contains the pattern. When the requester is
1757 -> closed, the possibly changed pattern is stored in it. If the variable does not
1758 -> exist, the argument is used literally as a pattern, but the changed pattern is
1759 -> not stored in any variable.
1760 -> If the requester was cancelled, the function returns the empty string, else it
1761 -> returns the path (the drawer and file concatenated with a slash in between if
1762 -> necessary).
1763 rc,result:=dofrq(rm,templist,tempstr)
1764 ELSEIF stricmp(funcname,'error')=0
1765 /* x=bguierror(code)
1766 0 1 */
1767 -> This function causes an ARexx error, e.g. bguierror(12) causes "Error return
1768 -> from function".
1769 IF rm.action AND $F<>1
1770 rc:=17 -> Wrong number of arguments
1771 ELSE
1772 rc:=Val(rm.args[1])
1773 ENDIF
1774 ELSEIF stricmp(funcname,'rexxversion')=0
1775 /* result=bguirexxversion([version],[revision])
1776 0 1 2 */
1777 -> Syntax #1: available=bguirexxversion(version,[revision])
1778 -> Syntax #2: version=bguirexxversion() /* could return '3.0' */
1779 IF rm.action AND $F>2
1780 rc:=17 -> Wrong number of arguments
1781 ELSE
1782 i:=-1; q:=0
1783 IF n>=1 AND rm.args[1] THEN i:=Val(rm.args[1])
1784 IF n>=2 AND rm.args[2] THEN q:=Val(rm.args[2])
1785 rc,result:=checkversion(rexxbguibase,i,q,tempstr)
1786 ENDIF
1787 ELSEIF stricmp(funcname,'version')=0
1788 /* result=bguiversion([version],[revision])
1789 0 1 2 */
1790 -> Syntax #1: available=bguiversion(version,[revision])
1791 -> Syntax #2: version=bguiversion() /* could return '41.8' */
1792 IF rm.action AND $F>2
1793 rc:=17 -> Wrong number of arguments
1794 ELSE
1795 i:=-1; q:=0
1796 IF n>=1 AND rm.args[1] THEN i:=Val(rm.args[1])
1797 IF n>=2 AND rm.args[2] THEN q:=Val(rm.args[2])
1798 rc,result:=checkversion(bguibase,i,q,tempstr)
1799 ENDIF
1800 ENDIF
1801 EXCEPT DO
1802 IF rc=-1 THEN rc:=12
1803 MOVEA.L result,A0
1804 ENDPROC rc
1806 PROC checkversion(lib:PTR TO lib,ver,rev,tempstr /* scratch */)
1807 IF ver<>-1
1808 IF ver<lib.version OR (ver=lib.version AND (rev<=lib.revision))
1809 RETURN 0,CreateArgstring('1',1)
1810 ELSE
1811 RETURN 0,CreateArgstring('0',1)
1812 ENDIF
1813 ELSE
1814 StringF(tempstr,'\d.\d',lib.version,lib.revision)
1815 RETURN 0,CreateArgstring(tempstr,EstrLen(tempstr))
1816 ENDIF
1817 ENDPROC
1819 PROC setlistvcontrol(rm:PTR TO rexxmsg,tempstr:PTR TO CHAR /* scratch */)
1820 DEF n,s,h:PTR TO idcmphook,i,r
1821 h:=tasknode.idcmphook
1822 IF (n:=rm.action AND $F)>4 THEN RETURN 17 -> Wrong number of arguments
1823 IF n=0 THEN h.window_object:=NIL
1824 IF n>=1 AND (s:=rm.args[1])
1825 IF LengthArgstring(s)=4
1826 h.listview:=Long(s)
1827 ENDIF
1828 ENDIF
1829 IF n>=2 AND (s:=rm.args[2])
1830 IF LengthArgstring(s)=4
1831 h.window_object:=Long(s)
1832 ENDIF
1833 ENDIF
1834 IF n>=3 AND (s:=rm.args[3])
1835 i,r:=Val(s)
1836 IF r=0
1837 tasknode.lastid:=tasknode.lastid+1
1838 i:=tasknode.lastid
1839 IF setRexxVar(rm,s,StringF(tempstr,'\d',i),EstrLen(tempstr)) THEN RETURN 12
1840 ENDIF
1841 h.doarrowmessages:=i
1842 ENDIF
1843 IF n>=4 AND (s:=rm.args[4])
1844 i,r:=Val(s)
1845 IF r=0
1846 tasknode.lastid:=tasknode.lastid+1
1847 i:=tasknode.lastid
1848 IF setRexxVar(rm,s,StringF(tempstr,'\d',i),EstrLen(tempstr)) THEN RETURN 12
1849 ENDIF
1850 h.enter_id:=i
1851 ENDIF
1852 ENDPROC 0,CreateArgstring('1',1)
1854 PROC dofrq(rm:PTR TO rexxmsg,templist:PTR TO LONG /* scratch */,
1855 tempstr:PTR TO CHAR /* scratch */)
1856 DEF rc,result,n,frq,obj,s,flags1,flags2,i,varexisted=FALSE,lockedwinobj=NIL
1857 IF tasknode.filereq=NIL
1858 tasknode.filereq:=BgUI_NewObjectA(BGUI_FILEREQ_OBJECT,NIL)
1859 IF tasknode.filereq=NIL THEN RETURN 12
1860 ENDIF
1861 frq:=tasknode.filereq
1862 n:=rm.action AND $F
1863 IF n>=2 AND rm.args[2]
1864 setattr(frq,ASLFR_TITLETEXT,rm.args[2])
1865 ELSE
1866 setattr(frq,ASLFR_TITLETEXT,NIL)
1867 ENDIF
1868 SetAttrsA(frq,[ASLFR_WINDOW,NIL,TAG_DONE])
1869 IF n>=3 AND rm.args[3]
1870 IF LengthArgstring(rm.args[3])=4
1871 IF lockedwinobj:=Long(rm.args[3])
1872 domethod(lockedwinobj,[WM_SLEEP])
1873 GetAttr(WINDOW_Window,lockedwinobj,{obj})
1874 setattr(frq,ASLFR_WINDOW,obj)
1875 ENDIF
1876 ENDIF
1877 ENDIF
1878 flags1:=0; flags2:=0
1879 IF s:=rm.args[4] AND (n>=4)
1880 WHILE s[]
1881 StrCopy(tempstr,'')
1882 WHILE s[]>="A" AND (s[]<="z") DO StrAdd(tempstr,s,1) BUT s++
1883 IF stricmp(tempstr,'dosavemode')=0
1884 flags1:=flags1 OR FRF_DOSAVEMODE
1885 ELSEIF stricmp(tempstr,'dopatterns')=0
1886 flags1:=flags1 OR FRF_DOPATTERNS
1887 ELSEIF stricmp(tempstr,'drawersonly')=0
1888 flags2:=flags2 OR FRF_DRAWERSONLY
1889 ELSEIF stricmp(tempstr,'filterdrawers')=0
1890 flags2:=flags2 OR FRF_FILTERDRAWERS
1891 ELSEIF stricmp(tempstr,'rejecticons')=0
1892 flags2:=flags2 OR FRF_REJECTICONS
1893 ENDIF
1894 WHILE s[]<"A" OR (s[]>"z") AND s[] DO s++
1895 ENDWHILE
1896 ENDIF
1897 setattr(frq,ASLFR_FLAGS1,flags1)
1898 setattr(frq,ASLFR_FLAGS2,flags2)
1899 IF n>=5 AND (s:=rm.args[5])
1900 StrCopy(tempstr,s); UpperStr(tempstr); i:=NIL
1901 IF getRexxVar(rm,tempstr,{i})=0 AND i
1902 setattr(frq,ASLFR_INITIALPATTERN,i)
1903 varexisted:=TRUE
1904 ELSE
1905 setattr(frq,ASLFR_INITIALPATTERN,s)
1906 ENDIF
1907 ENDIF
1908 IF n>=1 AND (s:=rm.args[1])
1909 IF flags2 AND FRF_DRAWERSONLY
1910 setattr(frq,FILEREQ_Drawer,s)
1911 ELSE
1912 setattr(frq,FILEREQ_File,FilePart(s))
1913 StrCopy(tempstr,s)
1914 PutChar(PathPart(tempstr),0)
1915 setattr(frq,FILEREQ_Drawer,tempstr)
1916 ENDIF
1917 ENDIF
1918 rc:=0
1919 IF domethod(frq,[ASLM_DOREQUEST])=ASLREQ_OK
1920 GetAttr(IF flags2 AND FRF_DRAWERSONLY THEN FILEREQ_Drawer ELSE FILEREQ_Path,frq,{s})
1921 result:=CreateArgstring(s,StrLen(s))
1922 ELSE
1923 result:=CreateArgstring('',0)
1924 ENDIF
1925 IF varexisted
1926 StrCopy(tempstr,rm.args[5]); UpperStr(tempstr)
1927 GetAttr(FILEREQ_Pattern,frq,{i})
1928 setRexxVar(rm,tempstr,i,StrLen(i))
1929 ENDIF
1930 IF lockedwinobj THEN domethod(lockedwinobj,[WM_WAKEUP])
1931 ENDPROC rc,result
1933 PROC setattr(obj,attr,val)
1934 DEF t[3]:ARRAY OF LONG
1935 t[0]:=attr
1936 t[1]:=val
1937 t[2]:=0
1938 SetAttrsA(obj,t)
1939 ENDPROC
1941 PROC createibutton(rm:PTR TO rexxmsg,tempstr /* stratch */,
1942 templist:PTR TO LONG /* scratch */)
1943 DEF rc,result,n,obj,c,i,temp2str[80]:STRING,im:PTR TO imagenode
1944 IF (n:=rm.action AND $F)<3 OR (n>5)
1945 RETURN 17 -> Wrong number of arguments
1946 ELSEIF rm.args[1]=NIL OR (rm.args[2]=NIL) OR (rm.args[3]=NIL)
1947 RETURN 17 -> Wrong number of arguments
1948 ENDIF
1949 SetList(templist,0)
1950 IF (c:=Char(rm.args[2]))="B" OR (c="b")
1951 i:=Val(rm.args[3])
1952 IF i=0
1953 c:=Char(rm.args[3])
1954 IF c="f" OR (c="F")
1955 i:=BUILTIN_GETFILE
1956 ELSEIF c="p" OR (c="P")
1957 i:=BUILTIN_POPUP
1958 ELSEIF c="d" OR (c="D")
1959 i:=BUILTIN_GETPATH
1960 ENDIF
1961 ENDIF
1962 listadd2(templist,VIT_BuiltIn,i)
1963 ELSEIF c="I" OR (c="i")
1964 IF (im:=addicon(rm.args[3]))=NIL THEN RETURN 12
1965 listadd2(templist,BUTTON_Image,im.dobj.gadget.gadgetrender)
1966 IF i:=im.dobj.gadget.selectrender
1967 listadd2(templist,BUTTON_SelectedImage,i)
1968 ENDIF
1969 ELSEIF c="M" OR (c="m")
1970 IF (i:=LengthArgstring(rm.args[3]))=4
1971 listadd2(templist,BUTTON_Image,Long(rm.args[3]))
1972 ELSEIF i=8
1973 listadd2(templist,BUTTON_Image,Long(rm.args[3]))
1974 listadd2(templist,BUTTON_SelectedImage,Long(rm.args[3]+4))
1975 ELSE
1976 ENDIF
1977 ELSEIF c="V" OR (c="v")
1978 RETURN 12
1979 ELSE
1980 RETURN 12
1981 ENDIF
1982 IF strchr(rm.args[2],"-")
1983 ListAdd(templist,[FRM_Type,FRTYPE_NONE,BUTTON_EncloseImage,TRUE,FRM_EdgesOnly,TRUE])
1984 ENDIF
1985 IF strchr(rm.args[2],"*")
1986 ListAdd(templist,[BUTTON_EncloseImage,TRUE])
1987 ENDIF
1988 IF n>=4 AND rm.args[4]
1989 listadd2(templist,LAB_Label,addstring(rm.args[4]))
1990 i:=PLACE_LEFT
1991 IF n>=5 AND rm.args[5]
1992 IF (c:=Char(rm.args[5]))="l" OR (c="L")
1993 i:=PLACE_LEFT
1994 ELSEIF c="r" OR (c="R")
1995 i:=PLACE_RIGHT
1996 ELSEIF c="a" OR (c="A")
1997 i:=PLACE_ABOVE
1998 ELSEIF c="b" OR (c="B")
1999 i:=PLACE_BELOW
2000 ENDIF
2001 ENDIF
2002 listadd2(templist,LAB_Place,i)
2003 ENDIF
2004 StringF(tempstr,'ID.\s',rm.args[1])
2005 UpperStr(tempstr)
2006 tasknode.lastid:=tasknode.lastid+1
2007 i:=tasknode.lastid
2008 setRexxVar(rm,tempstr,StringF(temp2str,'\d',i),EstrLen(temp2str))
2009 listadd2(templist,GA_ID,i)
2010 ListAdd(templist,[TAG_DONE])
2011 IF obj:=BgUI_NewObjectA(BGUI_BUTTON_GADGET,templist)
2012 addobjnode(obj)
2013 StringF(tempstr,'OBJ.\s',rm.args[1])
2014 UpperStr(tempstr)
2015 rc:=setRexxVar(rm,tempstr,{obj},4)
2016 result:=CreateArgstring({obj},4)
2017 ELSE
2018 rc:=12
2019 ENDIF
2020 ENDPROC rc,result
2022 PROC createindicator(rm:PTR TO rexxmsg,templist:PTR TO LONG /* scratch */)
2023 DEF n,c,q,obj,rc=1,result
2024 IF (n:=rm.action AND $F)<4 OR (n>7)
2025 rc:=17 -> Wrong number of arguments
2026 ELSEIF rm.args[1]=NIL OR (rm.args[3]=NIL) OR (rm.args[4]=NIL)
2027 rc:=17 -> Wrong number of arguments
2028 ELSE
2029 ListCopy(templist,[FRM_Type,FRTYPE_NONE])
2030 IF rm.args[2] THEN listadd2(templist,LAB_Label,addstring(rm.args[2]))
2031 listadd2(templist,INDIC_Min,Val(rm.args[3]))
2032 listadd2(templist,INDIC_Max,Val(rm.args[4]))
2033 IF n>=5 AND rm.args[5]
2034 listadd2(templist,INDIC_Level,Val(rm.args[5]))
2035 ENDIF
2036 c:=0
2037 IF n>=6 AND rm.args[6]
2038 IF (c:=Char(rm.args[6]))="l" OR (c="L")
2039 ListAdd(templist,[INDIC_Justification,IDJ_LEFT])
2040 ELSEIF c="c" OR (c="C")
2041 ListAdd(templist,[INDIC_Justification,IDJ_CENTER])
2042 ELSEIF c="r" OR (c="R")
2043 ListAdd(templist,[INDIC_Justification,IDJ_RIGHT])
2044 ENDIF
2045 ENDIF
2046 q:=NIL
2047 IF n>=7 AND rm.args[7]
2048 listadd2(templist,INDIC_FormatString,q:=addstring(rm.args[7]))
2049 ENDIF
2050 ListAdd(templist,[TAG_DONE])
2051 IF obj:=BgUI_NewObjectA(BGUI_INDICATOR_GADGET,templist)
2052 IF q
2053 /* 41.10: INDIC_FormatString -S--U */
2054 ListCopy(templist,[INDIC_FormatString])
2055 listadd1(templist,q)
2056 /* OM_SET INDIC_FormatString loses INDIC_Justification */
2057 IF c="l" OR (c="L")
2058 ListAdd(templist,[INDIC_Justification,IDJ_LEFT])
2059 ELSEIF c="c" OR (c="C")
2060 ListAdd(templist,[INDIC_Justification,IDJ_CENTER])
2061 ELSEIF c="r" OR (c="R")
2062 ListAdd(templist,[INDIC_Justification,IDJ_RIGHT])
2063 ENDIF
2064 ListAdd(templist,[TAG_DONE])
2065 SetGadgetAttrsA(obj,NIL,NIL,templist)
2066 ENDIF
2067 addobjnode(obj)
2068 StringF(tempstr,'OBJ.\s',rm.args[1])
2069 UpperStr(tempstr)
2070 rc:=setRexxVar(rm,tempstr,{obj},4)
2071 result:=CreateArgstring({obj},4)
2072 ELSE
2073 rc:=12
2074 ENDIF
2075 ENDIF
2076 ENDPROC rc,result
2078 PROC createwindow(
2079 rm:PTR TO rexxmsg,
2080 templist:PTR TO LONG /* scratch */,
2081 tempstr:PTR TO LONG /* scratch */
2083 DEF rc=1,result,lock,obj,n,q,c,i,plong:PTR TO LONG,pint:PTR TO INT,
2084 wnd:PTR TO window
2085 IF (n:=rm.action AND $F)<2
2086 rc:=17 -> Wrong number of arguments
2087 ELSE
2088 SetList(templist,0)
2089 obj:=Long(rm.args[2])
2090 IF removeobjnode(obj)=0 THEN RETURN 12
2091 listadd2(templist,WINDOW_MasterGroup,obj)
2092 listadd2(templist,WINDOW_Title,addstring(rm.args[1]))
2093 listadd2(templist,WINDOW_AutoAspect,TRUE)
2094 listadd2(templist,WINDOW_CloseOnEsc,TRUE)
2095 listadd2(templist,WINDOW_AutoKeyLabel,TRUE)
2096 listadd2(templist,WINDOW_IDCMPHookBits,IDCMP_RAWKEY)
2097 listadd2(templist,WINDOW_IDCMPHook,tasknode.idcmphook)
2098 lock:=0
2099 IF n>=3 AND (q:=rm.args[3])
2100 rc:=Abs(Val(q))
2101 IF q[]<>"-"
2102 IF rc THEN listadd2(templist,WINDOW_ScaleWidth,rc)
2103 ELSE
2104 IF rc THEN listadd2(templist,WINDOW_ScaleWidth,rc)
2105 listadd2(templist,WINDOW_LockWidth,TRUE)
2106 lock:=lock OR 1
2107 ENDIF
2108 ENDIF
2109 IF n>=4 AND (q:=rm.args[4])
2110 rc:=Abs(Val(q))
2111 IF q[]<>"-"
2112 IF rc THEN listadd2(templist,WINDOW_ScaleHeight,rc)
2113 ELSE
2114 IF rc THEN listadd2(templist,WINDOW_ScaleHeight,rc)
2115 listadd2(templist,WINDOW_LockHeight,TRUE)
2116 lock:=lock OR 2
2117 ENDIF
2118 ENDIF
2119 IF lock=3 THEN ListAdd(templist,[WINDOW_SizeGadget,FALSE,WINDOW_TitleZip,TRUE])
2120 wnd:=NIL; obj:=NIL
2121 IF rm.args[5] AND (n>=5)
2122 IF LengthArgstring(rm.args[5])=4
2123 obj:=Long(rm.args[5])
2124 GetAttr(WINDOW_Window,obj,{wnd})
2125 listadd2(templist,WINDOW_Screen,wnd.wscreen)
2126 ENDIF
2127 ELSEIF rm.args[6] AND (n>=6)
2128 listadd2(templist,WINDOW_PubScreenName,addstring(rm.args[6]))
2129 ENDIF
2130 IF n>=7 AND rm.args[7]
2131 c:=Char(rm.args[7])
2132 IF c="S" OR (c="s")
2133 ListAdd(templist,[WINDOW_Position,POS_CENTERSCREEN])
2134 ELSEIF c="m" OR (c="M")
2135 ListAdd(templist,[WINDOW_Position,POS_CENTERMOUSE])
2136 ELSEIF c="t" OR (c="T")
2137 ListAdd(templist,[WINDOW_Position,POS_TOPLEFT])
2138 ELSEIF c="w" OR (c="W") AND wnd
2139 listadd2(templist,WINDOW_PosRelBox,wnd+4)
2140 ELSEIF c="b" OR (c="B")
2141 q:=rm.args[7]+1
2142 WHILE q[]>"9" OR (q[]<"0") AND (q[]) DO q++
2143 pint:=tempstr; i:=0
2144 PutLong(tempstr,0); PutLong(tempstr+4,0)
2145 WHILE c
2146 pint[]:=Val(q,{c})
2147 EXIT c=0
2148 q:=q+c
2149 IF q[]>"9" OR (q[]<"0") THEN q++
2150 pint++; i++
2151 ENDWHILE
2152 pint:=alloceven(8); CopyMem(tempstr,pint,8)
2153 listadd2(templist,WINDOW_Bounds,pint)
2154 ELSEIF c="r" OR (c="R")
2155 q:=rm.args[7]+1
2156 WHILE q[]>"9" OR (q[]<"0") AND (q[]) DO q++
2157 pint:=tempstr; i:=0
2158 PutLong(tempstr,0); PutLong(tempstr+4,0)
2159 WHILE c
2160 pint[]:=Val(q,{c})
2161 EXIT c=0
2162 q:=q+c
2163 IF q[]>"9" OR (q[]<"0") THEN q++
2164 pint++; i++
2165 ENDWHILE
2166 pint:=alloceven(8); CopyMem(tempstr,pint,8)
2167 listadd2(templist,WINDOW_PosRelBox,pint)
2168 ENDIF
2169 IF strchr(rm.args[7],"*")
2170 ListAdd(templist,[WINDOW_Activate,FALSE])
2171 ENDIF
2172 ENDIF
2173 IF rm.action AND $F>=8 AND (q:=rm.args[8])
2174 IF LengthArgstring(q)>SIZEOF newmenu AND Char(q)=1 THEN listadd2(templist,WINDOW_MenuStrip,q)
2175 ENDIF
2176 listadd1(templist,TAG_DONE)
2177 rc:=12
2178 IF obj:=BgUI_NewObjectA(BGUI_WINDOW_OBJECT,templist)
2179 addobjnode(obj)
2180 rc:=0
2181 result:=CreateArgstring({obj},4)
2182 ELSE
2183 rc:=12
2184 ENDIF
2185 ENDIF
2186 ENDPROC rc,result
2188 PROC createimage(rm:PTR TO rexxmsg)
2189 DEF n,i,w,h,d,sz,data,im:PTR TO image
2190 IF (n:=rm.action AND $F)<>8 THEN RETURN 17
2191 FOR i:=1 TO 8 DO IF rm.args[i]=NIL THEN RETURN 17
2192 w:=Val(rm.args[3])
2193 h:=Val(rm.args[4])
2194 d:=Val(rm.args[5])
2195 sz:=w+15/16*2*h*d
2196 IF LengthArgstring(rm.args[6])<>sz THEN RETURN 12
2197 data:=allocchip(sz)
2198 IF data=NIL THEN RETURN 12
2199 CopyMem(rm.args[6],data,sz)
2200 IF (im:=alloceven(SIZEOF image))=NIL THEN RETURN 12
2201 im.leftedge:=Val(rm.args[1])
2202 im.topedge:=Val(rm.args[2])
2203 im.width:=w
2204 im.height:=h
2205 im.depth:=d
2206 im.imagedata:=data
2207 im.planepick:=Val(rm.args[7])
2208 im.planeonoff:=Val(rm.args[8])
2209 im.nextimage:=NIL
2210 ENDPROC 0,CreateArgstring({im},SIZEOF LONG)
2212 PROC makenm(rm:PTR TO rexxmsg,tempstr /* scratch */)
2213 DEF i,s,nm:newmenu,n,len
2214 /* 1<=Nargs<=6, rm.args[1]<>NIL */
2215 n:=rm.action AND $F
2216 i:=Val(rm.args[1]); IF i<=0 OR (i>3) THEN RETURN 18 -> Invalid argument to function
2217 nm.type:=i
2219 nm.flags:=0
2220 IF s:=rm.args[4] AND (n>=4)
2221 WHILE s[]
2222 StrCopy(tempstr,'')
2223 WHILE s[]>="A" AND (s[]<="z") DO StrAdd(tempstr,s,1) BUT s++
2224 IF stricmp(tempstr,'disabled')=0
2225 nm.flags:=nm.flags OR (IF i=1 THEN NM_MENUDISABLED ELSE NM_ITEMDISABLED)
2226 ELSEIF stricmp(tempstr,'checkit')=0
2227 nm.flags:=nm.flags OR CHECKIT
2228 ELSEIF stricmp(tempstr,'checked')=0
2229 nm.flags:=nm.flags OR CHECKED
2230 ELSEIF stricmp(tempstr,'toggle')=0
2231 nm.flags:=nm.flags OR MENUTOGGLE
2232 ENDIF
2233 WHILE s[]<"A" OR (s[]>"z") AND s[] DO s++
2234 ENDWHILE
2235 ENDIF
2236 i:=0
2237 IF s:=rm.args[5] AND (n>=5)
2238 IF (len:=LengthArgstring(s))<=4
2239 IF len
2240 CopyMem(s,{i}+4-len,len)
2241 ENDIF
2242 ELSE
2243 RETURN 18
2244 ENDIF
2245 ENDIF
2246 nm.mutualexclude:=i
2247 IF s:=rm.args[6] AND (n>=6)
2248 IF (i:=Val(s))=0
2249 tasknode.lastid:=tasknode.lastid+1
2250 i:=tasknode.lastid
2251 IF setRexxVar(rm,s,StringF(tempstr,'\d',i),EstrLen(tempstr)) THEN RETURN 12
2252 ENDIF
2253 ENDIF
2254 nm.userdata:=i
2255 nm.label:=NIL
2256 IF rm.args[2] AND (n>=2)
2257 nm.label:=addstring(rm.args[2])
2258 ENDIF
2259 IF nm.label=NIL THEN nm.label:=NM_BARLABEL
2260 IF rm.args[3] AND (n>=3)
2261 nm.commkey:=addstring(rm.args[3])
2262 ELSE
2263 nm.commkey:=NIL
2264 ENDIF
2265 s:=CreateArgstring(nm,SIZEOF newmenu)
2266 IF s=NIL THEN RETURN 12 ELSE RETURN 0,s
2267 ENDPROC
2269 PROC bguireq(wnd,title,text,gadgets,args=NIL,screen=NIL)
2270 DEF rq:bguiRequest
2271 rq.flags:=BREQF_AUTO_ASPECT OR
2272 (IF wnd THEN BREQF_LOCKWINDOW ELSE 0) OR
2273 (IF InStr(gadgets,'*')<>-1 THEN BREQF_FAST_KEYS ELSE 0) OR
2274 (IF gadgets[0]="%" AND (gadgets[1]="[") THEN BREQF_XEN_BUTTONS ELSE 0) OR
2275 (IF gadgets[0]="%" AND (gadgets[1]="]") THEN BREQF_FUZZ_BUTTONS ELSE 0)
2276 rq.title:=title
2277 rq.gadgetFormat:=IF gadgets[0]<>"%" OR
2278 (gadgets[1]<>"[" AND (gadgets[1]<>"]")) THEN gadgets ELSE gadgets+2
2279 rq.textFormat:=text
2280 rq.reqPos:=POS_CENTERMOUSE
2281 rq.textAttr:=NIL
2282 rq.underscore:="_"
2283 rq.reserved0:=0
2284 rq.screen:=screen
2285 rq.reserved1:=0
2286 ENDPROC BgUI_RequestA(wnd,rq,args)
2288 PROC findtag(name)
2289 DEF first[10]:STRING,q,next,t=NIL:PTR TO taginfo
2290 StrCopy(first,name,q:=InStr(name,'_'))
2291 IF q<=1 THEN RETURN 0
2292 IF q>=10 THEN RETURN 0
2293 next:=name+q+1
2295 IF FALSE
2296 /* TAGS: General information
2298 -> Types:
2299 -> INT=integer, may be boolean (0 means false, anything else means true)
2300 -> STRING=string
2301 -> OBJECT=4-byte pointer
2303 -> Applicability: ISGNU
2304 -> I=Init (not applicable for RexxBGUI)
2305 -> S=Set (bguiset())
2306 -> G=Get (bguiget())
2307 -> N=Notify (bguiaddmap() sattr/bguiaddcondit() ifattr)
2308 -> U=Update (bguiaddmap() dattr/bguiaddcondit() thattr/elattr)
2309 -> -=not possible
2310 -> ?=not known to me, try it
2311 ELSEIF stricmp(first,'WINDOW')=0
2312 t:=[
2313 -> 'Activate',$800F06F1,TAG_INT,
2314 -> 'AutoAspect',$800F0718,TAG_INT,
2315 -> 'AutoKeyLabel',$800F0725,TAG_INT,
2316 -> 'Backdrop',$800F06F6,TAG_INT,
2317 -> 'Borderless',$800F06F5,TAG_INT,
2318 -> 'CloseGadget',$800F06ED,TAG_INT,
2319 -> 'CloseOnEsc',$800F071A,TAG_INT,
2320 -> 'DepthGadget',$800F06EE,TAG_INT,
2321 -> 'DragBar',$800F06EB,TAG_INT,
2322 -> 'HelpFile',$800F070F,TAG_STRING,
2323 -> 'HelpLine',$800F0711,TAG_INT,
2324 -> 'HelpNode',$800F0710,TAG_STRING,
2325 -> 'HelpText',$800F0716,TAG_STRING,
2326 -> 'LockHeight',$800F06E5,TAG_INT,
2327 -> 'LockWidth',$800F06E4,TAG_INT,
2328 -> 'MenuStrip',$800F0703,TAG_MENU,
2329 -> 'NoBufferRP',$800F0717,TAG_INT,
2330 -> 'NoVerify',$800F071D,TAG_INT,
2331 -> 'Position',$800F06E1,TAG_INT,
2332 -> 'PreBufferRP',$800F072B,TAG_INT,
2333 -> 'PubScreenName',$800F0706,TAG_STRING,
2334 -> 'RMBTrap',$800F06F2,TAG_INT,
2335 -> 'ReportMouse',$800F06F4,TAG_INT,
2336 -> 'ScaleHeight',$800F06E3,TAG_INT,
2337 -> 'ScaleWidth',$800F06E2,TAG_INT,
2338 -> 'ScreenTitle',$800F0702,TAG_STRING,
2339 -> 'ShowTitle',$800F06F7,TAG_INT,
2340 -> 'SizeBottom',$800F06EF,TAG_INT,
2341 -> 'SizeGadget',$800F06EC,TAG_INT,
2342 -> 'SizeRight',$800F06F0,TAG_INT,
2343 -> 'SmartRefresh',$800F06F3,TAG_INT,
2344 -> 'Title',$800F0701,TAG_STRING,
2345 -> 'TitleZip',$800F0724,TAG_INT,
2346 -> 'ToolTicks',$800F071F,TAG_INT,
2347 -> 'UniqueID',$800F0714,TAG_INT,
2348 'Window',$800F0715,TAG_OBJECT, -> --G--
2349 0,$0,0
2350 ]:taginfo
2351 ELSEIF stricmp(first,'INFO')=0
2352 t:=[
2353 'TextFormat',$800F0281,TAG_STRING, -> IS--U
2354 'MinLines',$800F0283,TAG_INT,
2355 'FixTextWidth',$800F0284,TAG_INT,
2356 0,$0,0
2357 ]:taginfo
2358 ELSEIF stricmp(first,'STRINGA')=0
2359 t:=[
2360 'TextVal',STRINGA_TEXTVAL,TAG_STRING, -> ISGNU makes string gadget
2361 'LongVal',STRINGA_LONGVAL,TAG_INT, -> ISGNU makes integer gadget
2362 'MaxChars',STRINGA_MAXCHARS,TAG_INT, -> I-?--
2363 'BufferPos',STRINGA_BUFFERPOS,TAG_INT, -> IS??? cursor position
2364 'DispPos',STRINGA_DISPPOS,TAG_INT, -> IS??? first char visible
2365 0,$0,0
2366 ]:taginfo
2367 ELSEIF stricmp(first,'LGO')=0
2368 t:=[
2369 'FixWidth',LGO_FixWidth,TAG_INT,
2370 'FixHeight',LGO_FixHeight,TAG_INT,
2371 'Weight',LGO_Weight,TAG_INT,
2372 'FixMinWidth',LGO_FixMinWidth,TAG_INT,
2373 'FixMinHeight',LGO_FixMinHeight,TAG_INT,
2374 'Align',LGO_Align,TAG_INT,
2375 'NoAlign',LGO_NoAlign,TAG_INT,
2376 'FixAspect',LGO_FixAspect,TAG_INT, -> 65536*x+y 41.8 only
2377 'Visible',LGO_Visible,TAG_INT,
2378 0,$0,0
2379 ]:taginfo
2380 ELSEIF stricmp(first,'LISTV')=0
2381 t:=[
2382 'Top',LISTV_Top,TAG_INT, -> ISG-U
2383 'ReadOnly',LISTV_ReadOnly,TAG_INT, -> ISG?? S/U will not change frame
2384 'MultiSelect',LISTV_MultiSelect,TAG_INT, -> IS?-U
2385 'Select',LISTV_Select,TAG_INT, -> -S--U
2386 'MakeVisible',LISTV_MakeVisible,TAG_INT, -> -S--U
2387 'Entry',LISTV_Entry,TAG_STRING, -> ---N-
2388 'EntryNumber',LISTV_EntryNumber,TAG_INT, -> ---N-
2389 'LastClicked',LISTV_LastClicked,TAG_STRING, -> --G--
2390 'LastClickedNum',LISTV_LastClickedNum,TAG_INT, -> --G--
2391 'NewPosition',LISTV_NewPosition,TAG_INT, -> ---N-
2392 'NumEntries',LISTV_NumEntries,TAG_INT, -> --G--
2393 'MinEntriesShown',LISTV_MinEntriesShown,TAG_INT, -> ISG??
2394 'SelectMulti',LISTV_SelectMulti,TAG_INT, -> -S--U
2395 'SelectNotVisible',LISTV_SelectNotVisible,TAG_INT, -> -S--U
2396 'SelectMultiNotVisible',LISTV_SelectMultiNotVisible,TAG_INT, -> -S--U
2397 'MultiSelectNoShift',LISTV_MultiSelectNoShift,TAG_INT, -> IS--U
2398 'Deselect',LISTV_Deselect,TAG_INT, -> -S--U
2399 'DropSpot',LISTV_DropSpot,TAG_INT, -> --G--
2400 'ShowDropSpot',LISTV_ShowDropSpot,TAG_INT, -> IS---
2401 'Columns',LISTV_Columns,TAG_INT, -> I-G--
2402 'DragColumns',LISTV_DragColumns,TAG_INT, -> ISG-U
2403 'Titles',LISTV_Titles,TAG_STRING, -> I-G-U 41.8 Enforcer hits
2404 'Titles!',LISTV_Titles,TAG_OBJECT, -> ISG-U static string problem
2405 'PreClear',LISTV_PreClear,TAG_INT, -> ISG--
2406 'LastColumn',LISTV_LastColumn,TAG_INT, -> --G--
2407 0,$0,0
2408 ]:taginfo
2409 ELSEIF stricmp(first,'GA')=0
2410 t:=[
2411 'Disabled',GA_DISABLED,TAG_INT, -> IS?-U
2412 'Selected',GA_SELECTED,TAG_INT, -> ISGNU toggles/checkboxes only
2413 0,$0,0
2414 ]:taginfo
2415 ELSEIF stricmp(first,'BT')=0
2416 t:=[
2417 'LabelClick',BT_LabelClick,TAG_INT, -> IS---
2418 'DragObject',BT_DragObject,TAG_INT, -> ISG--
2419 'DropObject',BT_DropObject,TAG_INT, -> ISG--
2420 'Key',BT_Key,TAG_STRING, -> ISG-- set after creating window object only
2421 'RawKey',BT_RawKey,TAG_INT, -> ISG-- set after creating window object only
2422 'Qualifier',BT_Qualifier,TAG_INT, -> ISG-- set after creating window object only
2423 0,$0,0
2424 ]:taginfo
2425 ELSEIF stricmp(first,'PAGE')=0
2426 t:=[
2427 'Active',PAGE_Active,TAG_INT, -> ISG?U
2428 0,$0,0
2429 ]:taginfo
2430 ELSEIF stricmp(first,'MX')=0
2431 t:=[
2432 'Active',MX_Active,TAG_INT, -> ISGNU
2433 'DisableButton',MX_DisableButton,TAG_INT, -> IS--U
2434 'EnableButton',MX_EnableButton,TAG_INT, -> IS--U
2435 0,$0,0
2436 ]:taginfo
2437 ELSEIF stricmp(first,'CYC')=0
2438 t:=[
2439 'Active',CYC_Active,TAG_INT, -> ISGNU
2440 0,$0,0
2441 ]:taginfo
2442 ELSEIF stricmp(first,'PROGRESS')=0
2443 t:=[
2444 'Min',PROGRESS_Min,TAG_INT, -> IS---
2445 'Max',PROGRESS_Max,TAG_INT, -> IS---
2446 'Done',PROGRESS_Done,TAG_INT, -> ISGNU
2447 0,$0,0
2448 ]:taginfo
2449 ELSEIF stricmp(first,'INDIC')=0
2450 t:=[
2451 'Level',INDIC_Level,TAG_INT, -> IS--U
2452 0,$0,0
2453 ]:taginfo
2454 ELSEIF stricmp(first,'TAG')=0
2455 t:=[
2456 'IGNORE',1,TAG_INT, -> IS--U does nothing!
2457 0,$0,0
2458 ]:taginfo
2459 ENDIF
2460 IF t=NIL THEN RETURN NIL
2461 WHILE t[].name
2462 IF stricmp(t[].name,next)=0
2463 RETURN t
2464 ENDIF
2466 ENDWHILE
2467 ENDPROC NIL
2469 PROC listadd1(list,e)
2470 DEF l[1]:LIST
2471 ListCopy(l,[0])
2472 l[]:=e
2473 ListAdd(list,l)
2474 ENDPROC
2476 PROC listadd2(list,e1,e2)
2477 DEF l[2]:LIST
2478 ListCopy(l,[0,0])
2479 l[]:=e1
2480 l[1]:=e2
2481 ListAdd(list,l)
2482 ENDPROC
2484 PROC addobjnode(obj)
2485 DEF on=NIL:PTR TO objnode
2486 on:=AllocVec(SIZEOF objnode,0)
2487 IF on=NIL THEN RETURN NIL
2488 on.obj:=obj
2489 AddTail(tasknode.objects,on)
2490 ENDPROC on
2492 PROC removeobjnode(obj)
2493 DEF on:PTR TO objnode
2494 on:=tasknode.objects.head
2495 WHILE on::mln.succ
2496 IF on.obj=obj
2497 Remove(on)
2498 FreeVec(on)
2499 RETURN TRUE
2500 ENDIF
2501 on:=on::mln.succ
2502 ENDWHILE
2503 ENDPROC FALSE
2505 PROC findtasknode(rm:PTR TO rexxmsg)
2506 DEF p=NIL,tn:PTR TO tasknode
2507 IF getRexxVar(rm,'bguitasknode',{p}) THEN RETURN NIL
2508 IF p=NIL THEN RETURN NIL
2509 IF tn:=Long(p)
2510 bguibase:=tn.bguibase
2511 RETURN tn
2512 ELSE
2513 RETURN NIL
2514 ENDIF
2515 ENDPROC
2517 PROC addtasknode(rm:PTR TO rexxmsg,name) HANDLE
2518 DEF tn=NIL:PTR TO tasknode,tc:PTR TO tc,oldname,cli
2519 tc:=FindTask(NIL)
2520 IF name=NIL THEN name:=tc::ln.name
2521 oldname:=tc::ln.name
2522 tc::ln.name:=name
2524 cli:=tc::process.cli
2525 tc::process.cli:=0
2526 bguibase:=OpenLibrary('bgui.library',41)
2527 tc::process.cli:=cli
2529 tc::ln.name:=oldname
2530 IF bguibase=NIL THEN Raise("LIB")
2531 tn:=AllocVec(SIZEOF tasknode,MEMF_PUBLIC)
2532 IF tn=NIL THEN Raise("MEM")
2533 tn.task:=tc
2534 tn.bguibase:=bguibase
2535 tn.lastid:=0
2536 newList(tn.stringspace)
2537 newList(tn.objects)
2538 newList(tn.images)
2539 tn.filereq:=NIL
2540 tn.chipmem:=NIL
2541 tn.idcmphook.window_object:=NIL
2542 IF setRexxVar(rm,'bguitasknode',{tn},4) THEN Raise(1)
2543 rexxbguibase.opencnt:=rexxbguibase.opencnt+1
2544 RETURN tn
2545 EXCEPT DO
2546 IF tn THEN FreeVec(tn)
2547 IF bguibase THEN CloseLibrary(bguibase)
2548 bguibase:=NIL
2549 ENDPROC NIL
2551 PROC freetasknode(rm:PTR TO rexxmsg,tn:PTR TO tasknode)
2552 DEF o:PTR TO objnode,n:PTR TO stringbuffer,im:PTR TO imagenode
2553 DEF head
2554 WHILE n:=RemHead(tn.stringspace) DO FreeVec(n)
2555 WHILE o:=RemHead(tn.objects)
2556 DisposeObject(o.obj)
2557 FreeVec(o)
2558 ENDWHILE
2559 IF iconbase:=OpenLibrary('icon.library',0)
2560 WHILE im:=RemHead(tn.images)
2561 FreeDiskObject(im.dobj)
2562 FreeVec(im)
2563 ENDWHILE
2564 CloseLibrary(iconbase); iconbase:=NIL
2565 ENDIF
2566 IF tn.filereq THEN DisposeObject(tn.filereq)
2567 head:=tn.chipmem
2568 o:=head
2569 WHILE head
2570 head:=o::mln.succ
2571 FreeVec(o)
2572 o:=head
2573 ENDWHILE
2574 CloseLibrary(tn.bguibase)
2575 FreeVec(tn)
2576 rexxbguibase.opencnt:=rexxbguibase.opencnt-1
2577 setRexxVar(rm,'bguitasknode',[0],4)
2578 ENDPROC
2580 PROC addicon(filename) HANDLE
2581 DEF im=NIL:PTR TO imagenode,dobj=NIL
2582 im:=AllocVec(SIZEOF imagenode,0)
2583 IF im=NIL THEN RETURN NIL
2584 IF iconbase:=OpenLibrary('icon.library',0)
2585 dobj:=GetDiskObject(filename)
2586 CloseLibrary(iconbase); iconbase:=NIL
2587 ENDIF
2588 IF dobj=NIL THEN Raise(1)
2589 im.dobj:=dobj
2590 AddTail(tasknode.images,im)
2591 RETURN im
2592 EXCEPT DO
2593 IF im THEN FreeVec(im)
2594 ENDPROC NIL
2596 PROC addstring(old)
2597 DEF n:PTR TO stringbuffer,len,end,p
2598 len:=StrLen(old)
2599 IF len>=QUANTUM THEN RETURN NIL
2600 n:=tasknode.stringspace.head
2601 WHILE n.node.succ
2602 end:=n.space+QUANTUM
2603 IF (p:=n.ptr)+len+1<end
2604 CopyMem(old,p,len+1)
2605 n.ptr:=p+len+1
2606 RETURN p
2607 ENDIF
2608 n:=n.node.succ
2609 ENDWHILE
2610 IF (n:=AllocVec(SIZEOF stringbuffer,MEMF_PUBLIC))=NIL THEN RETURN NIL
2611 p:=n.space
2612 CopyMem(old,p,len+1)
2613 n.ptr:=n.space+len+1
2614 AddTail(tasknode.stringspace,n)
2615 ENDPROC p
2617 PROC alloceven(len)
2618 DEF n:PTR TO stringbuffer,end,p
2619 len++
2620 IF len>=QUANTUM THEN RETURN NIL
2621 n:=tasknode.stringspace.head
2622 WHILE n.node.succ
2623 end:=n.space+QUANTUM
2624 IF (p:=n.ptr)+len<end
2625 n.ptr:=p+len
2626 RETURN p+1 AND $FFFFFFFE
2627 ENDIF
2628 n:=n.node.succ
2629 ENDWHILE
2630 IF (n:=AllocVec(SIZEOF stringbuffer,MEMF_PUBLIC))=NIL THEN RETURN NIL
2631 p:=n.space
2632 n.ptr:=n.space+len
2633 AddTail(tasknode.stringspace,n)
2634 ENDPROC p
2636 PROC allocchip(len)
2637 DEF m:PTR TO memblock
2638 m:=AllocVec(len+4,MEMF_CHIP OR MEMF_PUBLIC) /* SIZEOF memblock */
2639 m.next:=tasknode.chipmem
2640 tasknode.chipmem:=m
2641 ENDPROC m+4
2643 PROC main() IS 0
2645 /* PROC close() IS 0 */