I have come up with this to allow multiple progress bars. I can't work
out how to make the close window button ( the cross) make the window
disappear and destroy the progress object.

------------------------------------
coclass 'progress'

def =: 0 : 0
xywh 6 16 172 11;cc ccprogress progress ws_border;
xywh 6 3 173 10;cc info static;cn "";
pas 6 6;pcenter;
rem form end;
pshow
)

create =: 3 : 0
'wname start end' =: y
uname =: wname , > coname '' NB. unique name for wd
wd def ,~ 'pc ', uname, ';'
)

destroy =: 3 : 0
        wd 'psel ', uname, '; pclose'
        codestroy ''
)


update =: 3 : 0
pos =. ": 100 <. <. 100 * (y - start) % end - start
wd 'psel ', uname,' ; set info ', pos,'; set ccprogress ', pos ,';'
)
--------------------------------------

Example use:
load jpath , '~user/classes/progress.ijs'
p1 =. ('FirstBar';0;3) conew 'progress' NB. new progress bar scale 0 to 3
p2 =. ('SecondBar';0;9) conew 'progress' NB. new progress bar scale 0 to 9

update__p1 0
update__p2 0
update__p1 1
update__p2 5
update__p1 2
update__p1 3
update__p2 9

destroy__p1 ''
destroy__p2 ''



2009/11/11 David Mitchell <[email protected]>:
> This guarantees that the correct parent form is active for subsequent 
> commands.
>  If you have multiple forms in your script (or are debugging a new form using
> the J GUI, which has its own forms), the last form used is the active one.
>
> --
> David Mitchell
>
> Matthew Brand wrote:
>> Looks like you have to put the psel in the same call as the command
>> you want to send to the control:
>>
>> wd 0 : 0
>> psel proge;
>> set info 40
>> )
>>
>>
>>
>>
>>
>> 2009/11/10 Don Guinn <[email protected]>:
>>> I tried your foo1 and I couldn't get it to fail. I'm running VISTA. If you
>>> are running under Windows you might want to look at
>>> http://www.jsoftware.com/jwiki/Guides/Windows%20Progress%20Dialog as it
>>> gives you a way to interrupt a long running task.
>>>
>>> On Tue, Nov 10, 2009 at 6:35 AM, David Mitchell 
>>> <[email protected]>wrote:
>>>
>>>> psel is what I use:
>>>>
>>>>    foo1=: 3 : 0
>>>> wd 'psel proge'
>>>> wd 'set info ',": y
>>>> wd 'set ccprogress ',": y
>>>> )
>>>>
>>>> --
>>>> David Mitchell
>>>>
>>>> Matthew Brand wrote:
>>>>> "I am trying to understand how it works so I wrote this" ... well
>>>>> actually I mainly copy/pasted it from pASepProgressBar :-).
>>>>>
>>>>> 2009/11/10 Matthew Brand <[email protected]>:
>>>>>> I can't get the pASepProgressBar class to work.
>>>>>> I am trying to understand how it works so I wrote this:
>>>>>> wd 0 : 0
>>>>>> pc proge;
>>>>>> xywh 6 16 172 11;cc ccprogress progress ws_border;
>>>>>> xywh 6 3 173 10;cc info static;cn "";
>>>>>> pas 6 6;pcenter;
>>>>>> rem form end;
>>>>>> pshow;
>>>>>> set info 50
>>>>>> )
>>>>>> wd 'set info 40'
>>>>>> If I highlight it all and press ctrl-R then it works as expected with
>>>> the
>>>>>> info label set to 40.
>>>>>> But if I try to run  wd 'set info 40' after that, I get an error:
>>>>>>    wd 'set info 40'
>>>>>> |domain error: wd
>>>>>> |       wd'set info 40'
>>>>>> |[-0]
>>>>>>    wd 'qer'
>>>>>> bad id : 0
>>>>>> How do I tell the wd command that I am referring to the info control
>>>> inside
>>>>>> the window (parent?)  proge?
>>>>>> What should I write instead of:
>>>>>>    wd 'set info 40'
>>>>>> Thanks,
>>>>>> Matthew.
>>>>>>
>>>>>> 2009/10/11 David Mitchell <[email protected]>
>>>>>>> For Windows, there is this:
>>>>>>>
>>>>>>> http://www.jsoftware.com/jwiki/Guides/Windows%20Progress%20Dialog
>>>>>>>
>>>>>>> or the WD object progressbar:
>>>>>>>
>>>>>>> http://www.jsoftware.com/help/user/wd_commands.htm
>>>>>>>
>>>>>>> You can see the WD progress bar in action in the "controls" demo on the
>>>>>>> bottom
>>>>>>> of the "selects" tab.
>>>>>>> --
>>>>>>> David Mitchell
>>>>>>>
>>>>>>> Matthew Brand wrote:
>>>>>>>> Is there a library of "widgets" or does anybody have any code that can
>>>>>>>> display some kind of progress bar.
>>>>>>>> E.g.
>>>>>>>>
>>>>>>>> init_progressBar_ 10 NB. there will be 10 steps to 100% completion
>>>>>>>>
>>>>>>>> for_i i.10 do.
>>>>>>>>   NB. do calculation step here...
>>>>>>>>   update_progressBar_ i NB. alter progress bar to position i
>>>>>>>> end.
>>>>>>>>
>>>>>>>> end_progressBar_ '' NB. stop displaying the progress bar.
>>>>>>>>
>>>>>>>> Just thought I would ask if this already exists before trying to write
>>>>>>>> something to do it.
>>>>>>>> ----------------------------------------------------------------------
>>>>>>>> For information about J forums see
>>>> http://www.jsoftware.com/forums.htm
>>>>>>> ----------------------------------------------------------------------
>>>>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>> ----------------------------------------------------------------------
>>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to