From: tom.rmadilo on 4 Sep 2009 11:46 On Sep 4, 2:47 am, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> wrote: > If I were in your shoes, I would simply distribute two files: > > - a.tcl containing the bulk of the code, no vwait > - b.tcl containing "source a.tcl;vwait forever" > > and then let the programmer use his brains and fingers. > > Bottom line: when situations are clearly different in the caller's > site, it is not a good idea to make the API lose the info and > rediscover it afterwards. This is excellent advice, I recommend a front-end script, one for each situation: myhttpserver-for-wish.tcl myhttpserver-for-tclsh.tcl In fact, I like to abstract the entire "http server" functionality away from the socket code, so I can use stdin/stdout/pipes as well as socket or add tcl threads: http://www.junom.com/gitweb/gitweb.perl?p=tnt.git;a=tree;f=packages/nsd/tcl
From: APN on 6 Sep 2009 09:28 What does the catch do? On my XP box, tcl 8.6, vwait never errors, irrespective of being run in tclsh (no event loop) or wish (with event loop) /Ashok On Sep 4, 2:47 pm, Uwe Klein <uwe_klein_habertw...(a)t-online.de> wrote: > APN wrote: > > What checks should I have in myhttpserver.tcl to meet all three > > objectives above? > > At the end your "started with eventloop" script will linger > at the file end ( doing an implicit "vwait forever" ). > > As far as I can see you can have a catch {vwait forever} > in that position ( and in all cases ) without detrimental > effects? > > uwe
From: APN on 6 Sep 2009 09:29 On Sep 4, 4:52 pm, Neil Madden <n...(a)cs.nott.ac.uk> wrote: > To check if your script is the main application, you can use the {$argv0 > eq [info script]} check. There is no reliable way to determine if the > event loop is running, short of creating an event and seeing if it > occurs or your script exits :-) > > -- Neil That's what I currently do and I guess I'll stick with it. /Ashok
From: APN on 6 Sep 2009 09:48 On Sep 4, 2:47 pm, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com> wrote: > On Sep 4, 11:16 am, APN <palm...(a)yahoo.com> wrote: > Why would one do that ? What's the purpose of starting a GUI-less app > with wish ? > Do you try to open pdf files with Audacity ??? I assume that's something foolish to do? If so, I'm quite likely to do it :-) Jokes apart, my use case is a hotkey utility I run. When run from tclsh, it simply executes systemwide hotkeys, else it also has a configuration gui. I *think* tclhttpd behaves the same way. The other issue is there are many scripts I run simply by double clicking the script in explorer. I don't want to care whether the .tcl is associated with tclsh and wish. > > If I were in your shoes, I would simply distribute two files: > > - a.tcl containing the bulk of the code, no vwait > - b.tcl containing "source a.tcl;vwait forever" > > and then let the programmer use his brains and fingers. > > Bottom line: when situations are clearly different in the caller's > site, it is not a good idea to make the API lose the info and > rediscover it afterwards. Well, yes and no. There is some validity to what you say. But there is also some desirability to have the software figure out the environment and Do The Right Thing without bothering the programmer, *if possible*. /Ashok
From: Uwe Klein on 6 Sep 2009 10:50 APN wrote: > What does the catch do? On my XP box, tcl 8.6, vwait never errors, > irrespective of being run in tclsh (no event loop) or wish (with event > loop) > /Ashok I have made it a rule not to touch any version of Windows if possible ;-) On unix [vwait] errors out when no further events _can_ possibly be generated. i.e. no eventloop for X, no pending [after] and no [filevent] for open files waiting for IO ( or anything similar ). The (uncaught) generated error will reflect into program exit status. uwe
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: disabling/ignoring ctrl+c Next: passing variable as default value to procedure parameter |