Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Need mouse move??? for Tk, Windows, Excel, system, start

by ff (Hermit)
on Jan 12, 2006 at 16:17 UTC ( [id://522728]=note: print w/replies, xml ) Need Help??


in reply to Re: Need mouse move??? for Tk, Windows, Excel, system, start
in thread Need mouse move??? for Tk, Windows, Excel, system, start

Thanks JamesNC, that's a good suggestion and it creates the behavior I want. I have rewritten the code as below to use the '1' when using 'start' and to dispatch directly (without the '1') when not using start (i.e. for when I provide the absolute path name of an executable for this routine to run for me.) However, :-(

When I go to check for the success of running the process by 'system' and 'start' (as seen below by the value printed in 'prob_foundA'), I no longer get a simple-to-check "0-if-OK, non-zero-if-problem" type of return. For example, if the spreadsheet is already in use and I then try running this program, I get the following response:

prob_foundA: '1608' The process cannot access the file because it is being used by another + process.

A normal/successful run produces:

prob_foundA: '756'

And the number back upon success is not even consistently '756', it might be '1632', '528', '408' such that the '1608' above is also likely unrelated to the failure to run the command via 'system'.

So, my next question becomes "How do I know whether 'system' ran the command successfully if I use this '1' trick?" (Trying 'perldoc -f system' and 'perldoc -f exec' tells me a lot but I can't see it mentioning the '1' behavior)

Modified code:

package gs; sub system_start_file { my ( $file_to_run, $dont_use_start ) = @_; unless ( -f $file_to_run ) { my $warn_msg = "red_915ssf Failed to build a proper path name for\n" . "'$file_to_run'\n"; warn $warn_msg; custTk::open_unique_tk_n_ask_question( $warn_msg, [ 'Ok' ] ); return (); } #warn "path537: '$ENV{PATH}'\n"; #my $prob_found #= $dont_use_start #? system $file_to_run #: system 1, 'start', $file_to_run; my $prob_found; if ( $dont_use_start ) { $prob_found = system $file_to_run; $prob_found = $prob_found == 0 ? 'no' : 'yes'; } else { $prob_found = system 1, 'start', $file_to_run; warn "prob_foundA: '$prob_found'\n"; $prob_found = $prob_found ne 0 ? 'no' : 'yes'; } #if ( $prob_found ) if ( $prob_found eq 'yes' ) { my $warn_msg = "red_915ssfpf '$prob_found' There was a problem in trying +to open\n" . "'$file_to_run'\n"; warn $warn_msg; custTk::open_unique_tk_n_ask_question( $warn_msg, [ 'Ok' ] ); #return (); } return (); }

Replies are listed 'Best First'.
Re^3: Need mouse move??? for Tk, Windows, Excel, system, start
by JamesNC (Chaplain) on Jan 12, 2006 at 19:44 UTC
    Well, I can clear up one issue, the number you are seeing is the process id. Checking for success beyond that depends on how you determine success :^)
    JamesNC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://522728]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-24 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found