Ran into this issue this morning. It's probably something I'm missing.
The ERP software I work with has workorder numbers that are in two parts, job number and job number suffix. The job number always has 6 characters and the suffix always has 3 characters. Even though the title is "job number" the input characters are alphanumeric (although alpha characters need to be capitalized.)
I have a program that allows a bar code scanner to "type" the job number and suffix into input boxes, runs the two generated variables through the "upper" function to make sure they are upper case, then pastes the values into the appropriate fields in a form.
If suffix = inv, the line Let>suffix={upper(%suffix%)} will change the value of suffix to INV as expected. My problem is that if variable suffix = 001, the line Let>suffix={upper(%suffix%)} will strip off the leading zeros and the value of suffix will become 1. So, I added quotes around %suffix% altering the script line to read Let>suffix={upper("%suffix%")}. Now a suffix value of 001 remains 001 but a suffix value inv throws a Macro Scheduler error "Incorrectly formed parameters", followed by a second error "i not appropriate".
Next I tried the same thing setting VAREXPLICIT=1 and got the same results.
In other complex expressions quotes are required around text items. Why do I get an error when surrounding text with quotes using the "upper" function?
Examples and results:
Let>suffix=inv
Let>suffix={upper(%suffix%)}
suffix will equal INV
Let>suffix=001
Let>suffix={upper(%suffix%)}
suffix will equal 1
Let>suffix=001
Let>suffix={upper("%suffix%")}
suffix will equal 001
Let>suffix=inv
Let>suffix={upper("%suffix%")}
Macro Scheduler will error
Thanks for listening,
Dick
Proper use of "upper"?
Moderators: JRL, Dorian (MJT support)
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
This issue has been raised before. Help does say that upper only works with a-z but it does seem reasonable that there should be a way to have it handle numerics more gracefully.
If you need it then this is a workaround:
Let>suffix=001
Concat>suffix,x
Let>suffix={upper(%suffix%)}
MidStr>suffix,1,3,suffix
MessageModal>%suffix%
If you need it then this is a workaround:
Let>suffix=001
Concat>suffix,x
Let>suffix={upper(%suffix%)}
MidStr>suffix,1,3,suffix
MessageModal>%suffix%
While it might not be the easiest route, my work-around would be to test the %suffix% string for numeric characters, then optionally use Upper.
I'm sure there is some slick way to use VBScript for this but I literally examine each character.
AlphaChar=ABCDEFGHIJK.....abcdefg......
NumChar=0123456789
then something like Pos>SuffixCharOne,AlphaChar,AlphaFound
Pos>SuffixCharOne,NumChar,NumFound
you get the picture....
if you would like I can send plenty of example code...
painful, but effective
I'm sure there is some slick way to use VBScript for this but I literally examine each character.
AlphaChar=ABCDEFGHIJK.....abcdefg......
NumChar=0123456789
then something like Pos>SuffixCharOne,AlphaChar,AlphaFound
Pos>SuffixCharOne,NumChar,NumFound
you get the picture....
if you would like I can send plenty of example code...
painful, but effective
Thanks Me_again that works.
Using the concept you supplied I've added a line and made the problem resolution more generic. The following does the same thing without any need to know the length of the string.
Let>prefix=x
Let>suffix=inventory
Concat>prefix,suffix
Let>prefix={upper(%prefix%)}
MidStr>prefix,2,2147483647,suffix
MessageModal>%suffix%
Incidently, 2147483647 is the largest number that I've been able to use with Midstr.
Later,
Dick
Using the concept you supplied I've added a line and made the problem resolution more generic. The following does the same thing without any need to know the length of the string.
Let>prefix=x
Let>suffix=inventory
Concat>prefix,suffix
Let>prefix={upper(%prefix%)}
MidStr>prefix,2,2147483647,suffix
MessageModal>%suffix%
Incidently, 2147483647 is the largest number that I've been able to use with Midstr.
Later,
Dick
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
You made it too easy with that fixed format
I think it would be a bit more elegant to just get the length of the string and use that in the MidStr>
Let>prefix=x
Let>suffix=inventory
Concat>prefix,suffix
Let>prefix={upper(%prefix%)}
Len>suffix,lenny
MidStr>prefix,2,%lenny%,suffix
MessageModal>%suffix%

Let>prefix=x
Let>suffix=inventory
Concat>prefix,suffix
Let>prefix={upper(%prefix%)}
Len>suffix,lenny
MidStr>prefix,2,%lenny%,suffix
MessageModal>%suffix%
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
So far as I can tell upper only gives the wrong result if the string is 100% numeric AND starts with a zero.SkunkWorks wrote:While it might not be the easiest route, my work-around would be to test the %suffix% string for numeric characters, then optionally use Upper.
I'm sure there is some slick way to use VBScript for this but I literally examine each character.
AlphaChar=ABCDEFGHIJK.....abcdefg......
NumChar=0123456789
then something like Pos>SuffixCharOne,AlphaChar,AlphaFound
Pos>SuffixCharOne,NumChar,NumFound
you get the picture....
if you would like I can send plenty of example code...
painful, but effective
So:
001 results in 1
100 results in 100
001x results in 001X