› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › xlateOutVals returns different value than passed to it
I’m having an
xlateOutVals is also a list
Try set xlateOutVals
The first element of XlateOutVals is assigned to the first outbound address, the second element to the next address and so forth
Since you have only one outbound address the other elements are discarded
Thank you for the assistance, that worked.
If you don’t mind further elaborating so I can fully understand: How did Cloverleaf know where the start and stop of each list element was?
When I get my input value,”First M” , in the TCL I’m doing that by by setting a variable to lindex of xlateInVals 0. I was under the impression lindex is grabbing the first entry in the list xlateInVals in its entirety and assigning it to my input value.
Why does the TCL/Cloverleaf then think they are different elements when I assign it back out to xlateOutVals since I grabbed the first element only for my input?
Tcl does not think they are different they are just lists
xlateIVals is a list of the input values, one for each input address
So if you had 3 input addresses, xlateInVals would have 3 elements
Likewise, xlateOutVals will contain one element for eacH OB address
So if you had three OB addresses the first element would go to the first address, the second to the second address and the third to the third address. If there are more elements in the list than output adresses they will be discarded
Look at it this way
xlateInVals is a list that aligns with the list xlateInList
xlateOutVals is a list that aligns with the list xlateOutList
I hope it makes sense. If not perhaps someone else can put it in terms you can understand
I will add something.
When you got the first element from xlateInVals you got ‘First M ‘.
You then trimmed the right hand space and got ‘First M’.
At this point this is a string because it is in a Tcl variable which is a string.
When you place it in xlateOutVals as a string it is there for Cloverleaf to use – BUT because Cloverleaf treats what is xlateOutVals as a LIST before it places the value(s) in a message and since the space is part of the ‘white noise’ character set the LIST functions use to delimit a list, Cloverleaf sees a list of 2 elements in your string and it knows each element goes to different destinations.
Try using tcl or hcitcl from the command line.
do this:
set stuff “First M” <– this gives you what you have in yout literal after trimming
Now do this:
lindex $stuff 0 <– this gets the first element of the list – you will get 'First'
If you were to use the foreach Tcl command against $stuff and echo out the contents you would get 2 elements ‘First’ and ‘M’.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
And to further clarify (I always use a lot of echo’s to see what is going on).
If you use your
set xlateOutVals $outputString
echo $xlateOutVals
you will see
First M
However, if you treat xlateOutVals as a list:
set xlateOutVals [list $outputString]
echo $xlateOutVals
you will get
{First M}
If a list element contains a space, tcl will put it in braces to be able to see it as a separate element. If there is no space in the list element, no brackets are used.
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands
xlateInVals and xlateOutVals are engine tcl LIST variables. They are not string variables. It is a best practice to use list command and not string commands on list variables.
set var1 [lindex $xlateInVals 0]
set xlateOutVals [list $var1]
-- Max Drown (Infor)