Temp variables not working within xlate, post proc

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Temp variables not working within xlate, post proc

  • Creator
    Topic
  • #50710
    Johnny Anderson
    Participant

    CL 5.5, Sun, Solaris 10.

    The attachment has it all layed out. I want to split an ip field into

    2 op fields.  I’ve searched Clovertech and the internet for examples

    and have tried many things but can’t see the problem with my

    code. Also the echos don’t show any values, only the name. Help.

Viewing 7 reply threads
  • Author
    Replies
    • #67198

      Johnny, will your data always look like “pat id ##”?

      If so, you can treat this like a list

      Code:

      set var “pat id 12”
      puts “[lindex $var 2]

      Example tcl fragment inside an xlate:

      Source: 1(0).0(0).0(0).PID.#3(0)

      Tcl: set xlateOutVals

        2]]

        Destination: whichever outbound field you want to use (or a tmp var)

        Note that you probably don’t need to use temp vars for this at all.

        -- Max Drown (Infor)

      1. #67199

        Here’s some sample code you can use for testing this logic:

        Code:

        lappend xlateInVals  {pat id 12}
        puts [lindex $xlateInVals 0]
        set xlateOutVals [list [lindex [lindex $xlateInVals 0] 2]]
        puts [lindex $xlateOutVals 0]

        Stick the code in a file called test.tcl and then run it from the command line with “tcl test.tcl”

        -- Max Drown (Infor)

      2. #67200
        Russ Ross
        Participant

        In your document screen shot it looks like you are trying to use the temp variable before you set it to anything meaningful.

        Try echoing out the value of your temp variable and I think you will see it has a value of “declare”.

        You need to feed your csubstr command somehting from the xlateInVals coming into your TCL code to set the @spilt_pid_3_0 temp variable going out.

        Russ Ross
        RussRoss318@gmail.com

      3. #67201
        Johnny Anderson
        Participant

        I created a new download file with new information, it has 4 pages.

        a. Max: the data

      4. #67202
        Tom Rioux
        Participant

        Johnny,

        Assuming your inbound variable is “R1P12345”, set up a copy statement that has your single source field and your two destination fields.

      5. #67203
        Russ Ross
        Participant

        Figuring out why someone else’s code is having a problem can be some fun but if I already have a proc that does what I need I take the path of least resistance and use it.

        So forgive me for offering a quick alternative instead of digging in anymore at this point.

        If you are saying you will always need to split a given field on ” ” (spaces) then look at this URL where I posted a how to of our generic proc that splits a field using the specified separator (a space in your case I think).

        <a href="http://clovertech.infor.com/viewtopic.php?t=1570&&#8221; class=”bbcode_url”>http://clovertech.infor.com/viewtopic.php?t=1570&amp;

        Russ Ross
        RussRoss318@gmail.com

      6. #67204
        Tom Rioux
        Participant

        Johnny,

        I do need to ask one question though. Is the region going to be “R1” or something similar everytime or will it be a two digit number?  I’m assuming this is just an oversight because you specified a range of “0 2” on the first variable and a range of “2 10” on your second variable.  This will make the character at the end of the first variable the same as the first character of the second variable.  Please clarify for us the exact form of the data.

        Once again, assuming your inbound value will always be in the form of   “R1P12345”, set up a copy statement as below.  I have taken the liberty to fill in the fields mentioned in your document.

        First, you can get rid of the “declare” entries in the xlate.

      7. #67205
        Johnny Anderson
        Participant

        Max and Russ, thanks, I’ve decided to go with Thomas’ solution.

        Thomas, those final changes fixed the problem.  Thanks for your help.

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

    Forum Statistics

    Registered Users
    5,117
    Forums
    28
    Topics
    9,292
    Replies
    34,435
    Topic Tags
    286
    Empty Topic Tags
    10