home *** CD-ROM | disk | FTP | other *** search
- # Test of the w_task and w_send communication facilities
-
-
- #These global variables determine which entries on the task submenu are grey.
-
- set taskup 0
- set taskdown 1
-
- #This is a the menu entry for the iconbar menu. It gives a submenu, one of
- #whose entries is a submenu.
-
- set commsentry\
- {{Comms -sub\
- {Comms {Send -click sendtest}
- {Info -click infowtest}
- {Task -sub {Task {Create -grey taskup -click tasktest}
- {Send -grey taskdown\
- -click {w_task testtask send [date]\n}
- }
- {Suspend -grey taskdown\
- -click {w_task testtask suspend}}
- {Resume -grey taskdown\
- -click {w_task testtask resume}}
- {Kill -grey taskdown -click taskkill}
- {Info -click infotest}
- }
- }
- }
- }}
-
- #This tests the w_send command. We will send to ourself as we don't know
- #what else is avaliable.
-
- proc sendtest {}\
- { if {[catch {w_send wtest {info globals}} wvars]}\
- { w_error "Send to self failed"
- return
- }
- show {Sent "info globals" to self} $wvars
- }
-
- #Test the info wimptasks command
-
- proc infowtest {}\
- {
- show "Wimp task list" [w_info wimptasks]
- }
-
-
- #Test the info tasks command
-
- proc infotest {}\
- {
- show "w Task list" [w_info tasks]
- }
-
-
- #This starts up a taskwindow task. It runs a shade program called sortstr
- #that returns a sorted string. It greys out the Create menu entry by
- #setting taskup=1, so that only one task can be run.
- #It ungreys the other entries by setting taskdown=0.
-
- proc tasktest {}\
- { global taskup taskdown
- w_task testtask create\
- -receive {taskreceive {%o} %n}\
- -quit {taskquit %n}\
- -command {"<Tcl$dir>.tclsh -b~c <wtest$dir>.sortstr"}
- set taskup 1
- set taskdown 0
- }
-
- #Kill the task. Reset the grey entries.
-
- proc taskkill {}\
- { global taskup taskdown
- w_task testtask kill
- set taskup 0
- set taskdown 1
- }
-
-
- #Display the result returned from the task.
-
- proc taskreceive {out name}\
- { show "Task output" "Output (%o) = $out" "Name (%n) = $name"
- }
-
-
- #Called when the task quits.
-
- proc taskquit {name}\
- { show "Task quitting" "Name (%n) = $name"
- }