infor.com
concierge
infor u
developer portal
documentation central
customer center
Posts
Categories
Groups
ERPs
CSD
FSM/HRT
LN
M3
Syteline/ CSI
Hubs
Developer
Healthcare
Hospitality
Public Sector
Onboarding
Release Center
CloudSuites
Aerospace & Defense (LN)
Automotive (LN)
Chemicals (M3)
Corporate (FSM/HRT)
Distribution (Sx.e/CSD)
Distribution Enterprise (M3)
Engineering & Construction (LN)
Fashion (M3)
Food & Beverage (M3)
Healthcare (FSM/HRT)
Industrial (Syteline/CSI)
Industrial Enterprise (LN)
Manufacturing (M3)
Public Sector (FSM/HRT)
Solutions
Supply Chain Management (SCM)
Human Capital Management (HCM)
Events
Groups
User Groups
Your Groups
About
Email Community Support
Infor News
Migrated Forums
Home
Clovertech
Clovertech Archive
Read Only Archives
Cloverleaf
Tcl Library
list doesnt contain element error
Kevin Crist
i have a field (ORC.12) that i need to replace but sometimes the HL7 doesnt go that far and i get the 'list doesn't contain element 12' error. I am using lreplace. How do i get around this using tcl?
Thanks.
Find more posts tagged with
Clovertech
Comments
Jim Kosloskey
Possibly do a llength first to see if the list is as long as you want?
Then it is up to you what you want to do.
Kevin Crist
Thanks Jim, that helped. I got hopefully one more question.
After finding the length i put in the below IF statement and realized that it now only works if the ORC is 13 (my daily Monday moment).
How do I put in that if it needs to be = into the syntax?
if {[string equal $ORCLength 13]} {
Jim Kosloskey
if {$ORCLength <= 13} {...}
Kevin Crist
thanks.
Paul Bishop
a nifty bit of code I picked up in level 2 and 3 classes:
while {[llength $FT1] <= 26} {lappend FT1 {}}
where FT1 is the list that you want to add to and 26 is the field you want to add/modify.
System
Originally posted by Steven Siegfried
You could have wrapped your ORC.12 logic in a catch.
catch {
set ORC_fields [lreplace $ORC_fields 12 12 with your replacement]
}
If ORC fields come inbound shorter, than there is nothing to replace. Having said that, if for some reason you must have something entered in ORC.12, you would go with the field length to build it out.
Charlie Bursell
As Paul said above:
while {[llength $FT1] <= 13} {lappend FT1 {}}
No need to check length of the segment. The above code would do nothing if field 12 or above were populated.
Anytime I am to change a field in a list, unless I know for sure the list will be of adequate length I use this code. For example you would not need if you were to place a value in MSH.4 because you know the segment must have more fields than that.
Maybe you picked this up in one of my classes. I always covered that.
System
Originally posted by Steven Siegfried
while {[llength $FT1] <= 13} {lappend FT1 {}}
101 different ways to write code, having said that, I will absolutely use this logic next time!