numbers and strings - IBM AS400

This is a discussion on numbers and strings - IBM AS400 ; hi guys is there someone can help me? how can I move a number variable in a string variable changing the zeros ahead in blanks? for example I have "6" in a numeric variable (len=4), I need " 6" (len=4) ...

+ Reply to Thread
Results 1 to 20 of 20

Thread: numbers and strings

  1. numbers and strings

    hi guys
    is there someone can help me?
    how can I move a number variable in a string variable changing the
    zeros ahead in blanks?

    for example

    I have "6" in a numeric variable (len=4), I need " 6" (len=4) in a
    string variable

    is there an automatic function to do this?

    thank's ^__^


  2. Re: numbers and strings

    On 9 May, 15:00, Paola wrote:
    > hi guys
    > is there someone can help me?
    > how can I move a number variable in a string variable changing the
    > zeros ahead in blanks?
    >
    > for example
    >
    > I have "6" in a numeric variable (len=4), I need " 6" (len=4) in a
    > string variable
    >
    > is there an automatic function to do this?
    >
    > thank's ^__^


    In what language Paolo? In RPG/ILE you could use something along the
    lines of:

    EvalR ChrVar = %Char(NumVar)


  3. Re: numbers and strings

    What language are you using? CL, RPG, SQL, ....

  4. Re: numbers and strings

    il 09/05/2007 16.00, Scrive Paola 40711088:
    > hi guys
    > is there someone can help me?
    > how can I move a number variable in a string variable changing the
    > zeros ahead in blanks?
    >
    > for example
    >
    > I have "6" in a numeric variable (len=4), I need " 6" (len=4) in a
    > string variable
    >
    > is there an automatic function to do this?
    >
    > thank's ^__^
    >

    in rpgle
    eval string = %editc(nueric:'Z')
    in C
    sprintf(string, "% 4.1d", numeric);

    --
    Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

  5. Re: numbers and strings

    On 9 Mag, 16:26, "Dr.UgoGagliardelli"
    wrote:
    > il 09/05/2007 16.00, Scrive Paola 40711088:> hi guys
    > > is there someone can help me?
    > > how can I move a number variable in a string variable changing the
    > > zeros ahead in blanks?

    >
    > > for example

    >
    > > I have "6" in a numeric variable (len=4), I need " 6" (len=4) in a
    > > string variable

    >
    > > is there an automatic function to do this?

    >
    > > thank's ^__^

    >
    > in rpgle
    > eval string = %editc(nueric:'Z')
    > in C
    > sprintf(string, "% 4.1d", numeric);
    >
    > --
    > Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    > Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    > Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    > schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'


    I'm using rpg400


  6. Re: numbers and strings

    On 9 May, 15:35, Paola wrote:
    > On 9 Mag, 16:26, "Dr.UgoGagliardelli"
    >
    >
    >
    >
    >
    > wrote:
    > > il 09/05/2007 16.00, Scrive Paola 40711088:> hi guys
    > > > is there someone can help me?
    > > > how can I move a number variable in a string variable changing the
    > > > zeros ahead in blanks?

    >
    > > > for example

    >
    > > > I have "6" in a numeric variable (len=4), I need " 6" (len=4)in a
    > > > string variable

    >
    > > > is there an automatic function to do this?

    >
    > > > thank's ^__^

    >
    > > in rpgle
    > > eval string = %editc(nueric:'Z')
    > > in C
    > > sprintf(string, "% 4.1d", numeric);

    >
    > > --
    > > Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    > > Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    > > Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    > > schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

    >
    > I'm using rpg400- Hide quoted text -
    >
    > - Show quoted text -


    If it's an unpacked field, never negative and always the same length
    as the character field you could "mess" around with the MLLZO (I am
    having to dig deep into my mind for op codes this old).


  7. Re: numbers and strings

    Wow, have I discovered one of the (very) rare occasions where COBOL is
    no more "wordy" than RPG? :-)

    MOVE NUMVAR TO CHARVAR.


  8. Re: numbers and strings

    On 9 Mag, 16:58, "walker.l2" wrote:
    > Wow, have I discovered one of the (very) rare occasions where COBOL is
    > no more "wordy" than RPG? :-)
    >
    > MOVE NUMVAR TO CHARVAR.


    if I do as you say I'll have '0006' in the charvar... I need '
    6' !!!
    sigh sigh ;(


  9. Re: numbers and strings

    On 9 Mag, 16:58, Rob wrote:
    > On 9 May, 15:35, Paola wrote:
    >
    >
    >
    >
    >
    > > On 9 Mag, 16:26, "Dr.UgoGagliardelli"

    >
    > > wrote:
    > > > il 09/05/2007 16.00, Scrive Paola 40711088:> hi guys
    > > > > is there someone can help me?
    > > > > how can I move a number variable in a string variable changing the
    > > > > zeros ahead in blanks?

    >
    > > > > for example

    >
    > > > > I have "6" in a numeric variable (len=4), I need " 6" (len=4) in a
    > > > > string variable

    >
    > > > > is there an automatic function to do this?

    >
    > > > > thank's ^__^

    >
    > > > in rpgle
    > > > eval string = %editc(nueric:'Z')
    > > > in C
    > > > sprintf(string, "% 4.1d", numeric);

    >
    > > > --
    > > > Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    > > > Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    > > > Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    > > > schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

    >
    > > I'm using rpg400- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > If it's an unpacked field, never negative and always the same length
    > as the character field you could "mess" around with the MLLZO (I am
    > having to dig deep into my mind for op codes this old).- Nascondi testo tra virgolette -
    >
    > - Mostra testo tra virgolette -


    i try... thank's


  10. Re: numbers and strings

    C Z-ADD60 Z4 40
    C MOVE Z4 Z4A 4
    C '0' CHECKZ4A X 20
    C '0':'*' XLATEZ4A:X Z4A
    C '0':' ' XLATEZ4A Z4A
    C '*':'0' XLATEZ4A:X Z4A


  11. Re: numbers and strings

    On 9 Mag, 17:27, patrick.tho...@alise-technologies.fr wrote:
    > C Z-ADD60 Z4 40
    > C MOVE Z4 Z4A 4
    > C '0' CHECKZ4A X 20
    > C '0':'*' XLATEZ4A:X Z4A
    > C '0':' ' XLATEZ4A Z4A
    > C '*':'0' XLATEZ4A:X Z4A


    you're a genious!!! thank's ^__^


  12. Re: numbers and strings

    On 9 May, 16:34, Paola wrote:
    > On 9 Mag, 17:27, patrick.tho...@alise-technologies.fr wrote:
    >
    > > C Z-ADD60 Z4 40
    > > C MOVE Z4 Z4A 4
    > > C '0' CHECKZ4A X 20
    > > C '0':'*' XLATEZ4A:X Z4A
    > > C '0':' ' XLATEZ4A Z4A
    > > C '*':'0' XLATEZ4A:X Z4A

    >
    > you're a genious!!! thank's ^__^


    Nice one Patrick...except that's a programmatic solution and
    cheating ;-)

    Personally Paola I would either write a small function in RPGLE that
    accepts a number, a length of character, the edit code and returns the
    edited code (or alternatively use the QECEDT API rather than re-
    inventing the wheel).


  13. Re: numbers and strings

    On 9 Mag, 17:51, Rob wrote:
    > On 9 May, 16:34, Paola wrote:
    >
    > > On 9 Mag, 17:27, patrick.tho...@alise-technologies.fr wrote:

    >
    > > > C Z-ADD60 Z4 40
    > > > C MOVE Z4 Z4A 4
    > > > C '0' CHECKZ4A X 20
    > > > C '0':'*' XLATEZ4A:X Z4A
    > > > C '0':' ' XLATEZ4A Z4A
    > > > C '*':'0' XLATEZ4A:X Z4A

    >
    > > you're a genious!!! thank's ^__^

    >
    > Nice one Patrick...except that's a programmatic solution and
    > cheating ;-)
    >
    > Personally Paola I would either write a small function in RPGLE that
    > accepts a number, a length of character, the edit code and returns the
    > edited code (or alternatively use the QECEDT API rather than re-
    > inventing the wheel).


    I know Rob, but here the chieves want we programs as even they know


  14. Re: numbers and strings

    On 9 May, 16:58, Paola wrote:
    > On 9 Mag, 17:51, Rob wrote:
    >
    >
    >
    >
    >
    > > On 9 May, 16:34, Paola wrote:

    >
    > > > On 9 Mag, 17:27, patrick.tho...@alise-technologies.fr wrote:

    >
    > > > > C Z-ADD60 Z4 40
    > > > > C MOVE Z4 Z4A 4
    > > > > C '0' CHECKZ4A X 20
    > > > > C '0':'*' XLATEZ4A:X Z4A
    > > > > C '0':' ' XLATEZ4A Z4A
    > > > > C '*':'0' XLATEZ4A:X Z4A

    >
    > > > you're a genious!!! thank's ^__^

    >
    > > Nice one Patrick...except that's a programmatic solution and
    > > cheating ;-)

    >
    > > Personally Paola I would either write a small function in RPGLE that
    > > accepts a number, a length of character, the edit code and returns the
    > > edited code (or alternatively use the QECEDT API rather than re-
    > > inventing the wheel).

    >
    > I know Rob, but here the chieves want we programs as even they know- Hide quoted text -
    >
    > - Show quoted text -


    It is the same nearly everywhere unfortunately Paola...except once
    someone realises things have to move forwards and everyone is
    questioned as to why they haven't. That is when you find a brick wall
    and bang your head against it!


  15. Re: numbers and strings

    On 9 Mag, 18:03, Rob wrote:
    > On 9 May, 16:58, Paola wrote:
    >
    >
    >
    >
    >
    > > On 9 Mag, 17:51, Rob wrote:

    >
    > > > On 9 May, 16:34, Paola wrote:

    >
    > > > > On 9 Mag, 17:27, patrick.tho...@alise-technologies.fr wrote:

    >
    > > > > > C Z-ADD60 Z4 40
    > > > > > C MOVE Z4 Z4A 4
    > > > > > C '0' CHECKZ4A X 20
    > > > > > C '0':'*' XLATEZ4A:X Z4A
    > > > > > C '0':' ' XLATEZ4A Z4A
    > > > > > C '*':'0' XLATEZ4A:X Z4A

    >
    > > > > you're a genious!!! thank's ^__^

    >
    > > > Nice one Patrick...except that's a programmatic solution and
    > > > cheating ;-)

    >
    > > > Personally Paola I would either write a small function in RPGLE that
    > > > accepts a number, a length of character, the edit code and returns the
    > > > edited code (or alternatively use the QECEDT API rather than re-
    > > > inventing the wheel).

    >
    > > I know Rob, but here the chieves want we programs as even they know- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > It is the same nearly everywhere unfortunately Paola...except once
    > someone realises things have to move forwards and everyone is
    > questioned as to why they haven't. That is when you find a brick wall
    > and bang your head against it! - Nascondi testo tra virgolette -
    >
    > - Mostra testo tra virgolette -


    holy words


  16. Re: numbers and strings

    On May 9, 10:09 am, Paola wrote:
    > On 9 Mag, 16:58, "walker.l2" wrote:
    >
    > > Wow, have I discovered one of the (very) rare occasions where COBOL is
    > > no more "wordy" than RPG? :-)

    >
    > > MOVE NUMVAR TO CHARVAR.

    >
    > if I do as you say I'll have '0006' in the charvar... I need '
    > 6' !!!
    > sigh sigh ;(


    Not if CHARVAR is PIC(ZZZ9).

    Scott


  17. Re: numbers and strings

    To be fair, I suppose we may need a second MOVE (to a PIC X field)
    depending on what the OP wants to do with the string (though usually
    zero suppression is for display (on-scren or in print) purposes, in
    which case a second MOVE would be pointless / unnecessary).

    Of course, since the OP is using RPG, this is all moot. :-)


  18. Re: numbers and strings

    Mind you, why not use a REDEFINES clause in Working Storage? That way
    we wouldn't need to do any MOVEs at all. :-)


  19. Re: numbers and strings

    patrick.thomas@alise-technologies.fr wrote:
    > C Z-ADD60 Z4 40
    > C MOVE Z4 Z4A 4
    > C '0' CHECKZ4A X 20
    > C '0':'*' XLATEZ4A:X Z4A
    > C '0':' ' XLATEZ4A Z4A
    > C '*':'0' XLATEZ4A:X Z4A
    >


    Hi Patrick, my first attempt was very similar, but like yours, it
    crashed when Z4 was zero. Also, I had to set Z4A to *ZEROS before the
    MOVE of Z4, for the case where Z4A had a non-blank value from before.

    C Z-ADD60 Z4 40
    C Z4 IFEQ 0
    C MOVE '0' Z4A 4 P
    C ELSE
    C MOVE *ZEROS Z4A
    C MOVE Z4 Z4A
    C '0' CHECKZ4A X 20
    C '0':' ' XLATEZ4A Z4A
    C ' ':'0' XLATEZ4A:X Z4A
    C ENDIF

  20. Re: numbers and strings

    On 10 Mag, 18:23, Barbara Morris wrote:
    > patrick.tho...@alise-technologies.fr wrote:
    > > C Z-ADD60 Z4 40
    > > C MOVE Z4 Z4A 4
    > > C '0' CHECKZ4A X 20
    > > C '0':'*' XLATEZ4A:X Z4A
    > > C '0':' ' XLATEZ4A Z4A
    > > C '*':'0' XLATEZ4A:X Z4A

    >
    > Hi Patrick, my first attempt was very similar, but like yours, it
    > crashed when Z4 was zero. Also, I had to set Z4A to *ZEROS before the
    > MOVE of Z4, for the case where Z4A had a non-blank value from before.
    >
    > C Z-ADD60 Z4 40
    > C Z4 IFEQ 0
    > C MOVE '0' Z4A 4 P
    > C ELSE
    > C MOVE *ZEROS Z4A
    > C MOVE Z4 Z4A
    > C '0' CHECKZ4A X 20
    > C '0':' ' XLATEZ4A Z4A
    > C ' ':'0' XLATEZ4A:X Z4A
    > C ENDIF




    hi... thank you first of all...
    ....
    i understand i'm the worste of programmers!!


+ Reply to Thread