Tcl catch not seeming to be effective in xltp string function

Homepage Clovertech Forums Cloverleaf Tcl catch not seeming to be effective in xltp string function

  • Creator
    Topic
  • #121523
    Jim Kosloskey
    Participant

    Cloverleaf 2209, Windows.

    I am writing a new STRING Action Function. In this code, I build up a string command that is stored in a variable (full_cmd), then execute that command inside a catch expecting the catch to report back when that command is incorrect and why.

    This works as expected when a proper string command is contained in full_cmd.

    When I test for a mal-formed command like this: “string is alpha -junk 1a3” it should fail and report back the error like this: “bad option “-junk”: must be -strict or -failindex”.

    Here is the Tcl command used to execute ‘full_cmd’:

    set err [catch {set is_result [{*}$full_cmd]} err_lit]

    The above works as expected in hcitcl. But when executed in my xltp_func_str type proc from within the STRING Action in an Xlate I get this:

    errorCode: TCL LOOKUP COMMAND {string is alpha -junk 1a3 }

    errorInfo:
    invalid command name “string is alpha -junk 1a3 ”
    while executing
    “$full_cmd”
    (procedure “xlateStrIs” line 98)
    invoked from within
    “xlateStrIs alpha -junk Y”
    <End of errorInfo>

    I realize the Xlate is pre-loading the code and does some validation at that point, but it appears it is ignoring I have a catch. The Command is indeed in error but the error is being handled. However, my code is not being given a chance to execute.

    What can I do about this?

    I know I can play evaluator and do my own evaluation of the command as it is collected before invocation but then my code can become out of date when Tcl decides to change how the resultant command should be constructed. I should be able to rely on catch.

    Thanks in advance if anyone knows how to get around this. In the meantime, I will add my own validation despite it not being the ideal solution.

    This technique worked, by the way, I am pretty sure with Cloverleaf 6.0. I know later changes were made to how xltp code is loaded in the Xlate and I suspect that is what I am experiencing.

     

     

    email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

  • You must be logged in to reply to this topic.

Forum Statistics

Registered Users
5,115
Forums
28
Topics
9,290
Replies
34,422
Topic Tags
286
Empty Topic Tags
10