Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asynchronous Processing of Perl/Tk Entry Box - How Do I

Status
Not open for further replies.

cartw19

Programmer
Feb 11, 2003
8
GB

My objective: To read through a file & check for anomalies, if anomaly found, query user if a change is required; if yes, get the change and update the file record.

Process used:
1. Read the file into an array
2. Check the records in the array
3. If anomaly found in record
4. Query user with Tk Dialogue box
5 get users answer to query
6 if user wants a change, activate a Tk entry box
7 get users change from entry box, via the Tk associated subroutine
8 update the record in the array
9 back to 2. for next record in the array
10 at end of array rewrite file from array.

My problem is that Step 9 processes before steps 7 & 8 complete, (or even start).

How can I force steps 7 & 8 to process before step 9.

TIA,
Colin
 
look at "vwait". Here's what it says in the Help file:
"This command enters the Tcl event loop to process events, blocking the application if no events are ready. It continues processing events until some event handler sets the value of variable varName. Once varName has been set, the vwait command will return as soon as the event handler that modified varName completes. varName must globally scoped (either with a call to global for the varName, or with the full namespace path specification)."
So you might have a step, 6.1 that sets a flag, "set flag 0", then waits for the flag to change, "vwait flag". Then the last thing in step 8 is, "set flag 1".

Also, I think for file handling, a list would be better than an array. Just my own preference.

Bob Rashkin
rrashkin@csc.com
 
Bob,
Thanks for the 'vwait' suggestion, but I am working with Tk not TCL.

I can't get vwait to work in Tk, I get messages like ' Can't locate object method "set" via package "masticman::flag"'

Colin
 
OK. How about "tkwait"?
tkwait variable name
tkwait visibility name
tkwait window name


DESCRIPTION
The tkwait command waits for one of several things to happen, then it returns without taking any other actions. The return value is always an empty string. If the first argument is variable (or any abbreviation of it) then the second argument is the name of a global variable and the command waits for that variable to be modified. If the first argument is visibility (or any abbreviation of it) then the second argument is the name of a window and the tkwait command waits for a change in its visibility state (as indicated by the arrival of a VisibilityNotify event). This form is typically used to wait for a newly-created window to appear on the screen before taking some action. If the first argument is window (or any abbreviation of it) then the second argument is the name of a window and the tkwait command waits for that window to be destroyed. This form is typically used to wait for a user to finish interacting with a dialog box before using the result of that interaction.



Bob Rashkin
rrashkin@csc.com
 
Bob,
Tkwait doesn't work either.

Having done some research I found waitVariable - an inbuilt Tk method, and this works fine.

e.g.
After calling the sub-routine which dives off into Tk, code
$mw->waitVariable(\$wait_flag);

and in the Tk routines, after all the Tk stuff is finished,
$wait_flag++;

Thanks for your suggestions.
Colin

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top