I need to copy PID 18 to OBX 14, and strip out all but the last 8 characters in the process. PID 18 will be variable length, and the characters of the string will be different.
I know how to trim leading zeros, and other leading characters when it’s not a variable length field, but cannot quite figure out how to trip all but the last 8 characters when the length will vary, but always be at least 8 characters.
IF the number is 3330520140417, the result I’m getting is 40417. It’s basically trimming off the first 8 characters rather than trimming all but the last 8 characters. I need to get the 20140417.
Many ways to do this, but Keith’s solution is the easiest/most common/efficient way. You can use the argument ‘end’ in many string commands to indicate the last character of a string, and ‘end-x’ to indicate a character x places from the end.
So this would be shorter:
Code:
set num [lindex $xlateInVals 0]
set date [string range $num end-7 end]
set xlateOutVals [list $date]
Or even:
Code:
set xlateOutVals [list [string range [lindex $xlateInVals 0] end-7 end]]
Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands
Author
Replies
Viewing 4 reply threads
The forum ‘Cloverleaf’ is closed to new topics and replies.