• How to determine if a script is running uder TKCon?

    From Helmut Giese@21:1/5 to All on Wed May 24 02:46:15 2023
    Hello out there,
    I am using TKCon a lot e.g. by using its debug feature 'idebug'. But
    sometimes I want to have a script run by itself or under a different
    debugger - and then I want to replace the 'idebug' proc by a 'do
    nothing' dummy.
    Looking at TKCon's sources I see that it creates a namespace 'tkcon' -
    but looking for that namespace leads to nothing, as evidenced by the
    following dump rigth from a start of TKCon:
    ----
    loading history file ... 40 events added
    buffer line limit: 512 max line length: unlimited
    Main console display active (Tcl8.6.10 / Tk8.6.10)
    (GUI) 41 % lsort [namespace children]
    ::baltip ::nsf ::oo ::pkg ::poImgUtil ::tcl ::tkpath ::twapi ::zlib
    (GUI) 42 % lsort [namespace children ::]
    ::baltip ::nsf ::oo ::pkg ::poImgUtil ::tcl ::tkpath ::twapi ::zlib
    (GUI) 43 %
    ----
    So what is a way to find out what I want?
    I'm running TKCon 2.7 under Tcl8.10 on Windows 10.
    Any help will be greatly appreciated
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Helmut Giese on Tue May 23 22:33:28 2023
    On Wed, 24 May 2023 02:46:15 +0200, Helmut Giese wrote:

    Hello out there,
    I am using TKCon a lot e.g. by using its debug feature 'idebug'. But sometimes I want to have a script run by itself or under a different
    debugger - and then I want to replace the 'idebug' proc by a 'do
    nothing' dummy.
    Looking at TKCon's sources I see that it creates a namespace 'tkcon' -
    but looking for that namespace leads to nothing, as evidenced by the following dump rigth from a start of TKCon:
    ----
    loading history file ... 40 events added
    buffer line limit: 512 max line length: unlimited
    Main console display active (Tcl8.6.10 / Tk8.6.10)
    (GUI) 41 % lsort [namespace children]
    ::baltip ::nsf ::oo ::pkg ::poImgUtil ::tcl ::tkpath ::twapi ::zlib
    (GUI) 42 % lsort [namespace children ::]
    ::baltip ::nsf ::oo ::pkg ::poImgUtil ::tcl ::tkpath ::twapi ::zlib
    (GUI) 43 %
    ----
    So what is a way to find out what I want?
    I'm running TKCon 2.7 under Tcl8.10 on Windows 10.
    Any help will be greatly appreciated
    Helmut


    Parsing your message is difficult for me because I am slow to pick
    certain things up, but in your place I would have the script set
    some variable right in the beginning then unset that variable whenever
    it exits, before it exits of course.

    Then you can always check if that variable exists. If it does, the
    script is running.

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Helmut Giese on Tue May 23 18:59:53 2023
    On 5/23/2023 5:46 PM, Helmut Giese wrote:
    Hello out there,
    I am using TKCon a lot e.g. by using its debug feature 'idebug'. But sometimes I want to have a script run by itself or under a different
    debugger - and then I want to replace the 'idebug' proc by a 'do
    nothing' dummy.
    Looking at TKCon's sources I see that it creates a namespace 'tkcon' -
    but looking for that namespace leads to nothing, as evidenced by the following dump rigth from a start of TKCon:
    ----
    loading history file ... 40 events added
    buffer line limit: 512 max line length: unlimited
    Main console display active (Tcl8.6.10 / Tk8.6.10)
    (GUI) 41 % lsort [namespace children]
    ::baltip ::nsf ::oo ::pkg ::poImgUtil ::tcl ::tkpath ::twapi ::zlib
    (GUI) 42 % lsort [namespace children ::]
    ::baltip ::nsf ::oo ::pkg ::poImgUtil ::tcl ::tkpath ::twapi ::zlib
    (GUI) 43 %
    ----
    So what is a way to find out what I want?
    I'm running TKCon 2.7 under Tcl8.10 on Windows 10.
    Any help will be greatly appreciated
    Helmut

    Would this help:

    if {"tkcon" in [interp aliases]} "puts yes"

    This outputs a yes if I'm running with tkcon, otherwise
    not. My tkcon is from magicsplat's install on windows.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Wed May 24 04:27:29 2023
    Hi Luc,
    Parsing your message is difficult for me because I am slow to pick
    certain things up, but in your place I would have the script set
    some variable right in the beginning then unset that variable whenever
    it exits, before it exits of course.

    Then you can always check if that variable exists. If it does, the
    script is running.
    thanks for the attempt, but I want to know whether my script is
    running under a certain environment and this environment cannot be
    recognized by checking for a certain variable. But luckily et99 knows
    of a way to find out.
    Thank you anyway
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Wed May 24 04:29:55 2023
    Hi et99,
    your're the greatest :)
    Would this help:

    if {"tkcon" in [interp aliases]} "puts yes"

    This outputs a yes if I'm running with tkcon, otherwise
    not. My tkcon is from magicsplat's install on windows.

    This is exactly an answer to my problem.
    May I ask how you happen to know this?
    Many thanks to you
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Helmut Giese on Wed May 24 10:46:54 2023
    On 5/23/2023 7:29 PM, Helmut Giese wrote:
    Hi et99,
    your're the greatest :)
    Would this help:

    if {"tkcon" in [interp aliases]} "puts yes"

    This outputs a yes if I'm running with tkcon, otherwise
    not. My tkcon is from magicsplat's install on windows.

    This is exactly an answer to my problem.
    May I ask how you happen to know this?
    Many thanks to you
    Helmut

    I knew that each interpreter gets it's own set of namespaces,
    globals, etc. and if you weren't able to see any tkcon
    namespaces, yet you saw them creating one in the source code,
    I figured that was why.

    So, I looked at the manual entry on interp and tried a few of
    the introspection commands until I found one that was
    different when running under tkcon.

    I think you can also use [info command tkcon] as well.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to All on Wed May 24 17:23:29 2023
    On Wed, 24 May 2023 10:46:54 -0700, et99 wrote:

    I think you can also use [info command tkcon] as well.


    So I decided to run [info command tkcon] on Tkcon for the heck of it
    and the output was 'tkcon.'

    So I tried [info command ss] and the output was 'ss.'

    Uh?

    So I tried [info command dfg] and the output was empty.

    Then 'ss' really exists. What is it? Must be a proc.

    % info body ss

    catch {unset ::stepsource::watchLevel}
    catch {unset ::stepsource::currentBreakPoint}
    catch {array unset ::stepsource::varValues}
    uplevel 1 $args


    What is that? I searched Tkcon's source, my ~/.tkconrc file, ande two
    other files I always load/source with Tkcon and and couldn't find that
    code anywhere. Do you people have it?

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Luc on Wed May 24 14:27:51 2023
    On 5/24/2023 1:23 PM, Luc wrote:
    On Wed, 24 May 2023 10:46:54 -0700, et99 wrote:

    I think you can also use [info command tkcon] as well.


    So I decided to run [info command tkcon] on Tkcon for the heck of it
    and the output was 'tkcon.'



    The [info command ?pattern?] ordinarily takes either no arguments, and
    returns all commands visible, or a pattern, and returns all
    that match that pattern. In the case of [info command tkcon]
    the pattern will match only the one, tkcon, if it's a command
    or nothing, so it's easy to test for any specific command
    being available.

    It also returns all procs and aliases as well. In the case of
    tkcon, I think that it is created using the [interp alias]
    command which usually gives you an alias in the main
    interpreter to a command inside another interpreter.

    However, it's also handy for just an alias in the one
    interpreter, for example,

    % info command dis ;# doesn't exist yet, so null return
    % interp alias {} dis {} {tcl::unsupported::disassemble}
    dis
    % info command dis ;# now an alias
    dis
    % dis script {incr i}
    ... snip ...
    Command 1: "incr i"
    (0) push1 0 # "i"
    (2) incrStkImm +1
    (4) done

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Gollwitzer@21:1/5 to All on Thu May 25 07:58:09 2023
    Am 24.05.23 um 23:27 schrieb et99:
    On 5/24/2023 1:23 PM, Luc wrote:
    On Wed, 24 May 2023 10:46:54 -0700, et99 wrote:

    I think you can also use [info command tkcon] as well.


    https://core.tcl-lang.org/tips/doc/trunk/tip/426.md

    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Helmut Giese on Thu May 25 14:08:30 2023
    On 5/25/2023 1:50 PM, Helmut Giese wrote:
    Hi et99,
    I knew that each interpreter gets it's own set of namespaces,
    globals, etc. and if you weren't able to see any tkcon
    namespaces, yet you saw them creating one in the source code,
    I figured that was why.

    So, I looked at the manual entry on interp and tried a few of
    the introspection commands until I found one that was
    different when running under tkcon.
    whow, that is really smart. As I said earlier: Your're the greatest
    :)
    Thanks again
    Helmut

    Thanks for the kind words. If I seem to be knowledgeable,
    it's because I've read this great book:

    https://www.magicsplat.com/ttpl/index.html

    I highly recommend it and I have both the paper edition and
    the searchable pdf edition.

    Also, the author provides this excellent resource:

    https://www.magicsplat.com/tcl-docs/docindex.html

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to that is really smart. As I on Thu May 25 22:50:09 2023
    Hi et99,
    I knew that each interpreter gets it's own set of namespaces,
    globals, etc. and if you weren't able to see any tkcon
    namespaces, yet you saw them creating one in the source code,
    I figured that was why.

    So, I looked at the manual entry on interp and tried a few of
    the introspection commands until I found one that was
    different when running under tkcon.
    whow, that is really smart. As I said earlier: Your're the greatest
    :)
    Thanks again
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)