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
Cloverleaf
Help with xlateStrTrimLeft/Right
mark-tucker
I have a value coming in that is the date in YYYYMMDD and I need to reorder it to MMDDYYYY for the receiving system. I was quite sure I had used xlateStrTrimLeft and xlateStrTrimRight to capture a range of numbers, not specific values but I cant make it happen. I was going to use each to copy YYYY and MMDD to 2 variables sand CONCAT them back in the reverse order.
Any help would be appreciated.
Find more posts tagged with
Clovertech
Comments
jcobane1
You could use the clock commands to reformat the date:
set dateIn [lindex $xlateInVals 0]
set dateOut [clock format [clock scan $dateIn -format "%Y%m%d"] -format "%m%d%Y"]
set xlateOutVals [list $dateOut]
(for some reason, it isn't displaying the last portion of my "set xlateOutVals [list $dateOut]" command above)
Hope that helps.
Jim Cobane - Henry Ford Health
brent-fenderson
Try this
set xlateOutVals [fmtclock [clock scan [string range [lindex $xlateInVals 0] 0 7] -format "%Y%m%d"] "%m%d%Y"]
jcobane1
Remember that you should treat xlateOutVals as a list
Paul Bishop
if you used string commands before, it would most likely have been the string range command. The format is
string range
<string> <first> <last>
where <string> is the value you are pulling from, either a variable or in quotes
<first> is the position of the first character to pull (zero based index)
<last> is the position of the last character to pull (zero based index)
you can also use "end" as the index values and add adjustments to them if you want such as "end-2" which is the index for the third to last position.
Jim Kosloskey
If you want to use the STRING Action Functions (which I recommend) then I think you would want to use the substring Function to extract the portions of the date you want to reorder.
So, your first substring Function would have the range of 0 and 3 to pickup the YYYY placing in a temp variable.
Your second STRING Action substring Function would have the range of 4 and end to pick up the MMDD portion and place it in a temp variable.
Then CONCAT the 2 temp variables in the appropriate order.
No need to use any Tcl.
If you would like a PowerPoint explaining all of the STRING Action Functions; an Xlate that exercises them all so you can experiment with them; additional STRING Action Functions that I have created; and a white paper on how to write your own STRING ACTION functions, email me and I will send you that distribution.
Charlie Bursell
Everybody has an opinion I might as well too. :-) I like regular expressions.
set dt 20250305
regsub -- {(\d{4})(\d{4})} $dt {\2\1} newdt
echo $newdt ==> 03052025
The beauty of TCL is there are several ways to do the same thing
mark-tucker
I ended up using the xlateStrSubstring but I am keeping all the other suggestions in mind as I learn more about TCL. Thanks to all who replied!
Jason Russell
Just as a note, I didn't see this as an actual response, string trim (in general, none of the languages I've used it in vary in this regard), and it's variants of left and right, does not "capture" data at all. It simply removes it. I suppose there are some convoluted ways to use it, but, as shown above, there's much easier and simpler ways to do it.
To kind of wrap the previous responses up, as someone said, with languages in general, there's always multiple different ways to approach a problem. However, with what you're doing and how it would be implemented, I think
From an xlate standpoint, xlatesubstr is probably the simplest, though it probably takes multiple lines to accomplish. This allows easy reading via the xlate panes, rather than having to drill down and really look at the code, it's all pretty much right there.
From a pure TCL standpoint clock is probably the simplest. I find TCL's clock implementation a bit unwieldy, but it's all there in one neat little package.
string range is probably second. It's essentially the same as xlatesubstr but strictly in TCL. Takes multiple lines but is easy to read.
regex from a purely personal standpoint I would avoid. regex is essentially it's own little language by itself. You can do some absolute magic with regex but it's not fun to try to parse it out/troubleshoot.