Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
command queue

Posted by ardikus (ardikus), 7 July 2004
Hi everyone, I've been having some difficulty modifying the order in which commands are processed. What I am trying to create is a FIFO queue, that takes commands from the user via a button click, and spaces the commands 1 second apart each.

I tried doing this using the vwait command, so that each time the button is clicked, it waits an additional second to execute the command.

When a button is clicked, it runs a proc called SendCommand.

In SendCommand, I have:

incr CQ 1

set placeinline $CQ

set n 0
after 1000 {set n 1}
vwait n

while {$placeinline > 1} {

set m 0
after 1000 {set m 1}
vwait m
incr placeinline -1

}

exec command x

incr $CQ -1

Unfortunately if I click Button A, and then Button B before before command A  is complete, the vwait in command B takes precedence and completes first. I need the commands to be executed in the order in which the buttons are clicked.

Does anyone have any possible suggestions for how to set this up in TCL so that I can evenly space the execution of commands no matter how quickly I click the buttons? Any help is appreciated, and if further clarification is needed please let me know. Thanks in advance. Code:
Code:


Posted by admin (Graham Ellis), 8 July 2004
I guess you're using Tk?

Suggested scheme ...

a) when a request comes in, add it on to a global list.
b) In your main code (before you enter your main event handling loop), register an event to happen after one second.
c) When your 1 second event happens, have it
 1) Start the first process in your global list, if any
 2) Move your global list up if necessary
 3) Reset the event trigger

Not something I've done, but have a look at "event generate" which I suspect has the facilities you need.

Posted by ardikus (ardikus), 8 July 2004
Thanks a TON for your response, I finally got this thing figured out. Your suggestion was just what I needed. I used the FIFO queue suggested at this wiki site: http://wiki.tcl.tk/9552 and then drew my commands off of this queue in a main loop every one second. Once again thanks, this has been bugging me for days  

Posted by admin (Graham Ellis), 8 July 2004
Delighted to be of service ... and thanks for the onwards link too.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho