I simply want to pad a field with a number of leading zeros but the specific number is the value of an argument passed to the code.
I have tried
PadUnSigArg1 = FMT(UnSigArg1, "Arg1'0'R")
which does not work
and
PadUnSigArg1 = 0(Arg1 - Len(UnSigArg1)):UnSigArg1
which almost works
0.0000000123456
I realise I can manipulate the second result to get what I want but can I do it cleaner?
Any solution would be greatly appreciated.
FMT function
Moderators: chulett, rschirm, roy
If you want to write a routine with a total of 7 letters or digits and if your number is less then 7 and you want the rest to be filled with Zero you write the following code into your Routine:
Ans=FMT(Arg1,"7'0'R")
and if you want to have it flexible use a second Argument Arg2
pFormat=Arg2:"'0'R"
Ans=FMT(Arg1,pFormat)
That's it.
Wolfgang
Ans=FMT(Arg1,"7'0'R")
and if you want to have it flexible use a second Argument Arg2
pFormat=Arg2:"'0'R"
Ans=FMT(Arg1,pFormat)
That's it.
Wolfgang
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Can you please delete this post from Editor's Corner?
It's not necessary to post on every Forum.
Wolfgang's answer is 100% correct. However there is an alternative syntax that some people prefer.The "%" character has the special meaning of "use zero as a background character" in the formatted result.
It's not necessary to post on every Forum.
Wolfgang's answer is 100% correct. However there is an alternative syntax that some people prefer.
Code: Select all
Fmt(TheString, "R%":Arg1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.