Bringing ChocolateCaste-0.7 into the main branch.
[AROS-Contrib.git] / bgui / RexxBGUI / progress.rexx
blob7dbe97e572c7138d8a5986160b324c28aab04125
1 /* REXX script for rexxbgui.library: progress bar */
3 if ~show('l','rexxbgui.library') then do
4 if ~addlib('rexxbgui.library',0,-30) then do
5 exit(20)
6 end
7 else nop
8 end
9 else nop
11 call bguiopen() /* causes error 12 if it did not work */
12 /* supply a second argument for a '0' return code instead of an ARexx
13 error */
15 signal on syntax /* important: bguiclose() MUST be called */
16 signal on halt
17 signal on break_c
19 esc='1B'x
20 lf='0A'x
21 grspace.narrow=-1
22 grspace.normal=-2
23 grspace.wide=-3
24 FixMinWidth=bguilayout(LGO_FixMinWidth,1)
26 /* using ARexx feature: ,<newline> is translated to nothing */
27 /* the || are essential - any added space will cause trouble */
28 /* redefining the same ID makes previous gadgets inaccessible */
29 /* do not redefine winclose etc. */
31 text=esc'cNew features demonstrated'lf'in this example:'lf||,
32 '· Progress bar'lf'· Indicator'lf'· Opening a window'lf||,
33 'inactive'
35 g=bguivgroup(,
36 bguiinfo('inf',,text)||,
37 bguiprogress('prog1',,0,100,'%ld%%')||,
38 bguihgroup(,
39 bguiprogress('prog2','Progress',0,100)||,
40 bguiindicator('indic2',,0,100,0,'C','%ld%%')||FixMinWidth,
41 )||,
42 bguihgroup(,
43 bguibutton('do','_Do something')||,
44 bguivarspace(50)||,
45 bguibutton('abort','_Abort'),
46 ,/*spc*/,/*offs*/,/*title*/,'W'),
47 ,,grspace.normal)
49 call bguiaddmap(obj.prog2,obj.indic2,PROGRESS_Done,INDIC_Level)
51 a=bguiwindow('RexxBGUI new 2.0 features',g,50,'-0',,arg(1),'*')
52 if bguiwinopen(a)=0 then bguierror(12)
53 id=0
54 do while bguiwinwaitevent(a,'ID')~=id.winclose
55 select
56 when id=id.winactive then nop
57 when id=id.wininactive then nop
58 when id=id.do then do
59 p=bguiget(obj.prog1,PROGRESS_Done)+10
60 call bguiset(obj.prog1,a,PROGRESS_Done,p)
61 call bguiset(obj.prog2,a,PROGRESS_Done,p)
62 if p=100 then do; call bguiwinbusy(a); address command wait 1; leave; end; else nop
63 end
64 when id=id.abort then leave
65 when id=id.winclose then nop
66 otherwise
67 end
68 end
69 rc=0
71 syntax:
72 if rc~=0 then say '+++ ['rc']' errortext(rc) 'at line' sigl
73 call bguiclose()
74 exit 0
76 break_c:
77 halt:
78 rc=0
79 say '+++ Break at line' sigl
80 signal syntax