• Does [$widget insert] escape characters?

    From Luc@21:1/5 to All on Sun Apr 23 18:00:34 2023
    puts "_string is $_string"
    $argW delete "insert -$_lastWordSize c" insert
    $argW insert insert $_string


    The output of puts:

    # ==============================================\n\n


    What is inserted into the text widget:

    # ==============================================\\n\\n


    Why?

    The actual code is too large and spread across multiple files to be
    posted here, but those three lines really are in that exact sequence.

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Mon Apr 24 01:32:18 2023
    Luc <luc@sep.invalid> wrote:
    puts "_string is $_string"
    $argW delete "insert -$_lastWordSize c" insert
    $argW insert insert $_string

    The output of puts:

    # ==============================================\n\n

    What is inserted into the text widget:

    # ==============================================\\n\\n

    Why?

    Too little info provided -- and code that does not run -- for us to
    tell much.

    The actual code is too large and spread across multiple files to be
    posted here, but those three lines really are in that exact sequence.

    Then try posting an actual small working sample here. The code you
    have posted does not run (three variables are undefined -- and we are
    not told their contents). And the code is 100% dependent upon the
    contents of those variables, esp. the _string variable.

    And your annotations are also incorrect, because the puts in the code
    shown above would output something like "_string is blah" not "#
    =====...\n\n".

    Most likely the contents of _string is not what you think it is at the
    time your delete and insert's are actually called.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Rich on Sun Apr 23 23:30:00 2023
    On Mon, 24 Apr 2023 01:32:18 -0000 (UTC), Rich wrote:

    Luc <luc@sep.invalid> wrote:
    puts "_string is $_string"
    $argW delete "insert -$_lastWordSize c" insert
    $argW insert insert $_string

    The output of puts:

    # ==============================================\n\n

    What is inserted into the text widget:

    # ==============================================\\n\\n

    Why?

    Too little info provided -- and code that does not run -- for us to
    tell much.

    The actual code is too large and spread across multiple files to be
    posted here, but those three lines really are in that exact sequence.

    Then try posting an actual small working sample here. The code you
    have posted does not run (three variables are undefined -- and we are
    not told their contents). And the code is 100% dependent upon the
    contents of those variables, esp. the _string variable.

    And your annotations are also incorrect, because the puts in the code
    shown above would output something like "_string is blah" not "# =====...\n\n".

    Most likely the contents of _string is not what you think it is at the
    time your delete and insert's are actually called.


    I know that the string is {# ==============================================\n\n}

    I know because it is part of an array, I have a [parray] command in the
    code, I found the relevant key and confirmed the exact string, there is
    also a [puts $array(key)] command that prints the one string instead of
    the entire array, and there is a [set _string $array(key)] command just
    a moment before those three lines I provided. The [puts] line confirms
    that the content is copied to the $_string variable correctly.


    And your annotations are also incorrect, because the puts in the code

    Yes, I wrote it from memory instead of copy-pasting it so it is indeed incorrect, but just assume I wrote
    "_string is # ==============================================\n\n"


    The code sequence is the one I posted. There is no way the content
    of the $_string variable could be changed between the first and the
    third line.


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Luc on Mon Apr 24 03:37:49 2023
    Luc <luc@sep.invalid> wrote:
    On Mon, 24 Apr 2023 01:32:18 -0000 (UTC), Rich wrote:

    Luc <luc@sep.invalid> wrote:
    puts "_string is $_string"
    $argW delete "insert -$_lastWordSize c" insert
    $argW insert insert $_string

    The output of puts:

    # ==============================================\n\n

    What is inserted into the text widget:

    # ==============================================\\n\\n

    Why?

    Too little info provided -- and code that does not run -- for us to
    tell much.

    The actual code is too large and spread across multiple files to be
    posted here, but those three lines really are in that exact sequence.

    Then try posting an actual small working sample here. The code you
    have posted does not run (three variables are undefined -- and we are
    not told their contents). And the code is 100% dependent upon the
    contents of those variables, esp. the _string variable.

    And your annotations are also incorrect, because the puts in the code
    shown above would output something like "_string is blah" not "#
    =====...\n\n".

    Most likely the contents of _string is not what you think it is at the
    time your delete and insert's are actually called.


    I know that the string is {# ==============================================\n\n}

    The code sequence is the one I posted. There is no way the content
    of the $_string variable could be changed between the first and the
    third line.

    This bit of working code:

    text .t
    pack .t

    set _string {# ==============================================\n\n}
    set _lastWordSize 5

    puts "_string is $_string"

    .t delete "insert -$_lastWordSize c" insert
    .t insert insert $_string

    Produces this output when run:

    $ wish luc
    _string is # ==============================================\n\n

    And produces this text widget view:

    https://pasteboard.co/bCdOII7UkQxy.png

    So something else is happening somewhere.

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