home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / tcl / tcl_1 / !wtest_tasktest < prev    next >
Encoding:
Text File  |  1996-03-26  |  2.3 KB  |  94 lines

  1. # Test of the w_task and w_send communication facilities
  2.  
  3.  
  4. #These global variables determine which entries on the task submenu are grey.
  5.  
  6. set taskup 0
  7. set taskdown 1
  8.  
  9. #This is a the menu entry for the iconbar menu. It gives a submenu, one of 
  10. #whose entries is a submenu.
  11.  
  12. set commsentry\
  13. {{Comms -sub\
  14.    {Comms {Send -click sendtest}
  15.           {Info -click infowtest}
  16.           {Task -sub {Task {Create -grey taskup -click tasktest}
  17.                            {Send -grey taskdown\
  18.                               -click {w_task testtask send [date]\n}
  19.                            }
  20.                            {Suspend -grey taskdown\
  21.                                -click {w_task testtask suspend}}
  22.                            {Resume -grey taskdown\
  23.                                -click {w_task testtask resume}}
  24.                            {Kill -grey taskdown -click taskkill}
  25.                            {Info -click infotest}
  26.                      }
  27.           }
  28.    }
  29. }}
  30.  
  31. #This tests the w_send command. We will send to ourself as we don't know
  32. #what else is avaliable.
  33.  
  34. proc sendtest {}\
  35.  { if {[catch {w_send wtest {info globals}} wvars]}\
  36.           { w_error "Send to self failed"
  37.             return
  38.           }
  39.    show {Sent "info globals" to self} $wvars
  40.  }
  41.  
  42. #Test the info wimptasks command
  43.  
  44. proc infowtest {}\
  45.  { 
  46.    show "Wimp task list" [w_info wimptasks]
  47.  }
  48.  
  49.  
  50. #Test the info tasks command
  51.  
  52. proc infotest {}\
  53.  { 
  54.    show "w Task list" [w_info tasks]
  55.  }
  56.  
  57.  
  58. #This starts up a taskwindow task. It runs a shade program called sortstr
  59. #that returns a sorted string. It greys out the Create menu entry by
  60. #setting taskup=1, so that only one task can be run.
  61. #It ungreys the other entries by setting taskdown=0.
  62.  
  63. proc tasktest {}\
  64.  { global taskup taskdown
  65.    w_task testtask create\
  66.           -receive {taskreceive {%o} %n}\
  67.           -quit    {taskquit %n}\
  68.           -command {"<Tcl$dir>.tclsh -b~c <wtest$dir>.sortstr"}
  69.    set taskup 1
  70.    set taskdown 0
  71.  }
  72.  
  73. #Kill the task. Reset the grey entries.
  74.  
  75. proc taskkill {}\
  76.  { global taskup taskdown
  77.    w_task testtask kill
  78.    set taskup 0
  79.    set taskdown 1
  80.  }
  81.  
  82.  
  83. #Display the result returned from the task.
  84.  
  85. proc taskreceive {out name}\
  86.  { show "Task output" "Output (%o) = $out" "Name (%n) = $name"
  87.  }
  88.  
  89.  
  90. #Called when the task quits.
  91.  
  92. proc taskquit {name}\
  93.  { show "Task quitting" "Name (%n) = $name"
  94.  }