Hello,

I am trying to move a numeric field to a character field in free

format and keep the leading zeros. I have tried multiple edit codes

and cannot get the leading zero on the field. Any ideas?

Printable View

- 10-05-2007, 02:50 AMunixfield values
Hello,

I am trying to move a numeric field to a character field in free

format and keep the leading zeros. I have tried multiple edit codes

and cannot get the leading zero on the field. Any ideas?

- 10-05-2007, 02:50 AMunixRe: field values
Hi,

try the following:

/Free

MyCharField = %EditC(MyNumField: 'X');

/End-Free

Birgitta

On 5 Sep., 23:49, Alida <bstew...@mcg-ins.com> wrote:[color=blue]

> Hello,

>

> I am trying to move a numeric field to a character field in free

> format and keep the leading zeros. I have tried multiple edit codes

> and cannot get the leading zero on the field. Any ideas?[/color]

- 10-05-2007, 02:51 AMunixRe: field values
On Sep 5, 5:49 pm, Alida <bstew...@mcg-ins.com> wrote:[color=blue]

> Hello,

>

> I am trying to move a numeric field to a character field in free

> format and keep the leading zeros. I have tried multiple edit codes

> and cannot get the leading zero on the field. Any ideas?[/color]

You can use a zero suppression character in editw to force a specific

number of leading zeros

I will use dots to represent spaces because you couldn't count the

space if I used spaces, so I'll use dots.

If Num is 4 numeric with value 5

data = %editw(Num: '0....'); data would equal " 0005"

data = %editw(Num: '0...'); data would equal " 005"

data = %editw(Num: '.0..'); data would equal " 05"

Anyway you can force a specific number of leading zeros by adjusting

where you put the zero suppession character in the edit word.

The result can can have leading space where the zero suppression

character was specified. You may have to use trim_left to remove the

leading space.

data = %trimL(%editw(Num: '0....'))

- 10-05-2007, 02:51 AMunixRe: field values
I am pretty sure the masking rules return a length of four for the

edit word ('0 ') such that a TrimL should be unnecessary. This is a

/special case/ whereby the digit zero [stop zero suppression character]

acts as an uncounted position. The special case is an exception to the

original rule counting all blanks plus the stop zero suppress character

as the length required to match the number of digits for the numeric

field. Now when the first character is a stop zero suppress character

[there is both zero and asterisk], the number of blanks in the remainder

of the edit word can match the number of digits for the numeric field;

rather than one less.

Regards, Chuck

--

All comments provided "as is" with no warranties of any kind

whatsoever and may not represent positions, strategies, nor views of my

employer

eb wrote:[color=blue]

>

> You can use a zero suppression character in editw to force a specific

> number of leading zeros

>

> I will use dots to represent spaces because you couldn't count the

> space if I used spaces, so I'll use dots.

>

> If Num is 4 numeric with value 5

>

> data = %editw(Num: '0....'); data would equal " 0005"

> data = %editw(Num: '0...'); data would equal " 005"

> data = %editw(Num: '.0..'); data would equal " 05"

>

> Anyway you can force a specific number of leading zeros by adjusting

> where you put the zero suppression character in the edit word.

>

> The result can can have leading space where the zero suppression

> character was specified. You may have to use trim_left to remove the

> leading space.

>

> data = %trimL(%editw(Num: '0....'))[/color]

- 10-05-2007, 02:51 AMunixRe: field values
Why fool around with %editw when %editC does it all without worrying

about how many columns ? Use Birgitta's solution.