Hi Mike,
Yes, it has been discussed a few times here that assigning a value to a variable and then comparing another variable with this one works; instead of comparing the variable against a value. So your solution is right.
However… I don’t understand your problem. Tcl will not see the space and treat the space as a list delimiter; that is something you do yourself, or can avoid yourself.
First rule of using tcl inside Cloverleaf: xlateInVals and xlateOutVals are lists, so always treat them that way!
So if the barcode is “EAN12345 “, then
COPY @barcodefield -> @otherfield
with tcl code
lassign $xlateInvals code
echo “this is the field that is coming in: ”
set xlateOutVals [list $code]
will show the full field and @otherfield will have the value “EAN12345 “
So the piece of code to get the last character of a field is something like this:
lassign $xlateInVals code
set last_char [string range $code end end]
set xlateOutVals [list $code]
or in short
set xlateOutVals [list [string range [lindex $xlateInVals 0] end end]]
If you want the code to add a backslash behind a field if the last character is a space:
lassign $xlateInVals code
if {[string equal [string range $code end end] ” “]} {
set code “${code}”
}
set xlateOutVals [list $code]
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands