For Programmers: Free Programming Magazines  


Home > Archive > Cobol > December 2006 > number to string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author number to string
luaks

2006-12-14, 7:55 am

Hello

I'm beginer. I try to add some number to string, output must be string
too. For example:
01 STR1 PIC X(25)
01 NUM1 PIC 999V99
01 STR2 PIC X(30)

if STR1 = "aaaaa" and NUM1 = 123,45 then output: STR2 = "aaaa123,45"
How to di it?
Please help me.

luaks

2006-12-14, 7:55 am

In article <1166093112.885280.96530@16g2000cwy.googlegroups.com>,
luaks <luaks@o2.pl> wrote:
>Hello
>
>I'm beginer. I try to add some number to string, output must be string
>too. For example:
>01 STR1 PIC X(25)
>01 NUM1 PIC 999V99
>01 STR2 PIC X(30)
>
>if STR1 = "aaaaa" and NUM1 = 123,45 then output: STR2 = "aaaa123,45"
>How to di it?
>Please help me.


It would seem that you are not trying to 'add some number to string', you
are trying to edit a numeric field with an implied decimal to a character
field and concatenate that with an alphabetic field.

Now please do your own homework.

DD

Bob Iles

2006-12-14, 6:55 pm

luaks wrote:
> Hello
>
> I'm beginer. I try to add some number to string, output must be string
> too. For example:
> 01 STR1 PIC X(25)
> 01 NUM1 PIC 999V99
> 01 STR2 PIC X(30)
>
> if STR1 = "aaaaa" and NUM1 = 123,45 then output: STR2 = "aaaa123,45"
> How to di it?
> Please help me.
>
> luaks
>

Hint - Look up documentation for "STRING" verb.
bob.
Howard Brazee

2006-12-14, 6:55 pm

On Thu, 14 Dec 2006 09:04:33 -0500, Bob Iles <bobi@mikal.com> wrote:

>Hint - Look up documentation for "STRING" verb.
>bob.


Or possibly 05 levels...
Bob Iles

2006-12-14, 6:55 pm

Howard Brazee wrote:
> On Thu, 14 Dec 2006 09:04:33 -0500, Bob Iles <bobi@mikal.com> wrote:
>
>
> Or possibly 05 levels...


I know that 05 levels would be fine if you know
the input string is always going to be "aaaa", but
how could you use 05 level (excluding array processing)
to do this task.

just curious.
bob.
Howard Brazee

2006-12-14, 6:55 pm

On Thu, 14 Dec 2006 12:01:52 -0500, Bob Iles <bobi@mikal.com> wrote:

>
>I know that 05 levels would be fine if you know
>the input string is always going to be "aaaa", but
>how could you use 05 level (excluding array processing)
>to do this task.


As with any problem - the first thing necessary is to determine what
is wanted.
Changing "aaaaa" to "ab " could mean changing:
if STR1 = "ab " and NUM1 = 123,45 then output: STR2 = "ab 123,45"

Or maybe something else is wanted. It may be a good idea for the
original poster to come up with a test plan with test data & expected
results before going much further. If he's not sure about the
expected results, then he should check with his customer.
Richard

2006-12-14, 6:55 pm


luaks wrote:

> I'm beginer. I try to add some number to string,


'add' is a mathematical operation. you probably mean 'concatenate'.

> output must be string
> too. For example:
> 01 STR1 PIC X(25)
> 01 NUM1 PIC 999V99
> 01 STR2 PIC X(30)
>
> if STR1 = "aaaaa" and NUM1 = 123,45 then output: STR2 = "aaaa123,45"
> How to di it?


You should note that NUM1 will not have the value '123,45' it may hold
the characters '12345' the 'V' in the PICTURE is an _implied_ decimal
point, it indicates where the decimal point (or comma to you) will go.
You will need to construct an additional edited numeric field that will
include an actual decimal point if that is an actual requirement.

You could use INSPECT to find the number of characters in STR1 and use
reference notation.

luaks

2006-12-15, 7:55 am


Bob Iles napisal(a):

> Hint - Look up documentation for "STRING" verb.


Thank you Bob, this is what I need.

luaks

luaks

2006-12-15, 7:55 am


Richard napisal(a):
>
> 'add' is a mathematical operation. you probably mean 'concatenate'.


Yes, you are right. My english is weak.

> You should note that NUM1 will not have the value '123,45' it may hold
> the characters '12345' the 'V' in the PICTURE is an _implied_ decimal
> point, it indicates where the decimal point (or comma to you) will go.
> You will need to construct an additional edited numeric field that will
> include an actual decimal point if that is an actual requirement.
>
> You could use INSPECT to find the number of characters in STR1 and use
> reference notation.


Good hint. I will do that.
Thank you.

luaks

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com