Question -solved- Formating Char With Leading 0s

JoseKreif

Member
I can't find much in the progress PDFs i have, so I turn to the community.

I have a vendor table, each vendor has a unique value for "vendor number". I'm writing a report which contains these numbers.
Not every ID is the same length. So I'd like to add leading zeros to them. The vendor ID is char, so I cannot do it the easy way with "Format "99999999""

How can I get a list like this
A201
2323
24532
2342A
3924
34948A

To look like this
000A201
0002323
0024532
002342A
0003924
034948A

Am I on to something with this:

Overlay(d-line,10) = "0000000".
x = length(vendor.id).
Overlay(d-line,10+x) = vend.id.

edit:
I might be missing logic, more like :

Overlay(d-line,10+7-x) = vend.id.
 
Last edited:

Osborne

Active Member
Does doing something like this solve the problem?:
Code:
DEFINE VARIABLE d_line AS CHARACTER FORMAT "X(8)" NO-UNDO.

ASSIGN d_line = "A201"
       d_line = FILL("0",(8 - LENGTH(d_line))) + d_line.

DISPLAY d_line.
 

JoseKreif

Member
It looked like it was working when I go through it in my head. So I went ahead and implemented it. Seems to work great.

def var v-x as int no-undo.
v-x = length(p-num)..

overlay(v-dline,40) = string("000000000000000").
overlay(v-dline,40 + 15 - v-x) = string(p-num).

EDIT:

Does doing something like this solve the problem?:
Code:
DEFINE VARIABLE d_line AS CHARACTER FORMAT "X(8)" NO-UNDO.

ASSIGN d_line = "A201"
       d_line = FILL("0",(8 - LENGTH(d_line))) + d_line.

DISPLAY d_line.

Oh, nice, I didn't see your reply until now. Thanks​
 
Top