return displist in sub proc

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf return displist in sub proc

  • Creator
    Topic
  • #51125
    Todd Horst
    Participant

    My main proc calls some back-end procs so the other developers here don’t have to be bothered with the details. In certain cases id like to error out the message.

    In order to do this the only thing you would really need to do its to global the displist. However i have no real way of returning the displist from a sub proc, as returning would simply exit from that proc and resume running the calling proc.

    I see in tcl 8.5.7 documentation the return function has a parameter for level. Im assuming this would work for me, i could simply dictate the level would be at 2 instead of the default 1. However in tcl 8.4 (which CL 5.7 uses and we are running) i dont see that same parameter.

    Does anyone know of a way to work around this in 8.4? If not, do we know when CL will move to 8.5.7 or greater?

    Thanks

    Todd Horst

Viewing 4 reply threads
  • Author
    Replies
    • #68872
      Michael Hertel
      Participant

      I know this isn’t right but how about creating a syntax error when you want to “error the message”.

      Don’t set BippityBoppityBoop yet “echo $BippityBoppityBoop” when you want it to bomb.

      You could get creative and echo $MessageIntetionallyErrorByProc

      That would give you better info when looking at the undefined error.

    • #68873
      Todd Horst
      Participant

      I see, your just suggesting i do a tcl error. That actually should work.

      Code:


      proc test_sub_error_work { } {
         global mh
         msgmetaset $mh USERDATA “Error out because….”
         echo $SEE_USERDATA_ERROR
      }

    • #68874
      garry r fisher
      Participant

      Hi,

      Not sure if I understand exactly what you want to do but why don’t you use either return -code error or return -code return?

      Using return error allows you to return an error state to the calling procedure and you could add an error string as follows:

      return – code error “This has errored”

      You will need to catch this in your calling procedure.

      Alternatively:

      return -code return

      Will return to the calling procedure and once control is returned it will in turn return without running the rest of the procedure.

      These are just quick suggestions off the top of my head – I’m sure you can improve on them.

      This is available on older versions of Tcl.

      Regards

      Garry

    • #68875
      Jim Kosloskey
      Participant

      Todd,

      If your proc is the one being invoked in a UPoC, then wouldn’t you return $dispList thus returning to Cloverleaf(R) with the dispList however it was set?

      So if a sub-proc changes dispList and you have it defined as global, then your proc has the effective changed dispList when the invoked proc just returns to you. You could also have it return with some sort of return information and you could check that as well if you wanted to.

      However, I think that if the sub-proc changes dispList and returns to your proc, dispList now contains the updated value (hopefully a valid disposition list) and by returning to Cloverleaf with dispList (return $dispList) the intended message disposition will occur.

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

    • #68876
      Todd Horst
      Participant

      Jim Kosloskey wrote:

      Todd,

      If your proc is the one being invoked in a UPoC, then wouldn’t you return $dispList thus returning to Cloverleaf(R) with the dispList however it was set?

      So if a sub-proc changes dispList and you have it defined as global, then your proc has the effective changed dispList when the invoked proc just returns to you. You could also have it return with some sort of return information and you could check that as well if you wanted to.

      However, I think that if the sub-proc changes dispList and returns to your proc, dispList now contains the updated value (hopefully a valid disposition list) and by returning to Cloverleaf with dispList (return $dispList) the intended message disposition will occur.

      The big thing is that i normally wont be returning the dispist immediately when I’ve finished by sub proc. And i dont want to add code in the main script (parent script) to check the displist for changes, and the sub proc is used in several (currently about 10) scripts so in some cases displist may already not be blank. I just want to have the minimum amount of code in these parent scripts.

      I tried the return -code return, and it seemed that by doing this, when viewing in the error db it showed up as a tcl error anyway. so i still am using a echo with an invalid variable.

      The other thing im wondering is before i error out this message i want to shut the thread down, (as to not cause more errors).

      Does cloverleaf always wait until a message has cleared a state before allowing a pstop to execute?

      In other words, if i issue a pstop within my tcl script and then throw a tcl error, will it always send that message to the error db. I initially tried to not error out the message and just do a pstop thinking the message would remain in the recover db, but it appears to have been sent out, which is a problem since the message is going to a external db, so if it goes out on a bad odbc connection its really is just being lost.

Viewing 4 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,127
Forums
28
Topics
9,300
Replies
34,445
Topic Tags
288
Empty Topic Tags
10