• Number format

    From =?UTF-8?B?SmVhbi1Mb3VpcyBUb3VybsOp?@21:1/5 to All on Wed Jan 18 02:21:54 2023
    Hello,

    How can I display (SAY) the number 123456789 under the form 123.456.789 ?

    Thank you

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jaime Cruz@21:1/5 to All on Wed Jan 18 08:27:27 2023
    On 1/18/23 05:21, Jean-Louis Tourné wrote:
    Hello,

    How can I display (SAY) the number 123456789 under the form 123.456.789 ?

    Thank you

    /******************************* REXX *********************************/
    /* REXX External Function written by Gerard Schildberger and */
    /* uploaded to the comp.lang.rexx Usenet newsgroup on June 11, */
    /* 2007 in response to a question from me. */
    /* */
    /* Arguments are: */
    /* Comma(_, c, s, t) */
    /* Where: */
    /* _ = the input number to have commas inserted */
    /* c = Character to be inserted (Default = ',') */
    /* n = Number of spaces between "c" */
    /* t = total insertions to perform (Default = 9999999) */ /**********************************************************************/
    Parse Arg _, c, s, t

    c = PickBlank(c, ',')
    If \IsInt(s) | ,
    s < 1 Then
    s = 3

    n = _ || '.9'
    a = 123456789
    k = 0
    If \IsInt(t) Then
    t = 9999999

    Do j = Verify(n, a || '0', , Verify(n, a || '0.', 'M')) - s - 1 To ,
    Verify(n, a, 'M') By -s While k < t
    _ = Insert(c, _, j)
    k = k + 1
    End

    Exit _

    /**********************************************************************/
    /* Subroutine to determine if a number is a whole number or not. */ /**********************************************************************/
    IsInt:
    Procedure
    Return Datatype(Arg(1), 'W')

    /**********************************************************************/
    /* Subroutine to select the insertion character or blanks. */ /**********************************************************************/ PickBlank:
    Procedure
    Parse Arg x, y
    Arg xu
    If xu == 'BLANK' Then
    Return ' '
    Return Word(x y, 1)

    --
    Jaime A. Cruz

    Nassau Wings Motorcycle Club
    http://www.nassauwings.org/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?SmVhbi1Mb3VpcyBUb3VybsOp?@21:1/5 to All on Wed Jan 18 09:21:19 2023
    Le mercredi 18 janvier 2023 à 14:27:29 UTC+1, Jaime Cruz a écrit :
    On 1/18/23 05:21, Jean-Louis Tourné wrote:
    Hello,

    How can I display (SAY) the number 123456789 under the form 123.456.789 ?

    Thank you
    /******************************* REXX *********************************/
    /* REXX External Function written by Gerard Schildberger and */
    /* uploaded to the comp.lang.rexx Usenet newsgroup on June 11, */
    /* 2007 in response to a question from me. */
    /* */
    /* Arguments are: */
    /* Comma(_, c, s, t) */
    /* Where: */
    /* _ = the input number to have commas inserted */
    /* c = Character to be inserted (Default = ',') */
    /* n = Number of spaces between "c" */
    /* t = total insertions to perform (Default = 9999999) */ /**********************************************************************/ Parse Arg _, c, s, t

    c = PickBlank(c, ',')
    If \IsInt(s) | ,
    s < 1 Then
    s = 3

    n = _ || '.9'
    a = 123456789
    k = 0
    If \IsInt(t) Then
    t = 9999999

    Do j = Verify(n, a || '0', , Verify(n, a || '0.', 'M')) - s - 1 To , Verify(n, a, 'M') By -s While k < t
    _ = Insert(c, _, j)
    k = k + 1
    End

    Exit _

    /**********************************************************************/
    /* Subroutine to determine if a number is a whole number or not. */ /**********************************************************************/ IsInt:
    Procedure
    Return Datatype(Arg(1), 'W')

    /**********************************************************************/
    /* Subroutine to select the insertion character or blanks. */ /**********************************************************************/ PickBlank:
    Procedure
    Parse Arg x, y
    Arg xu
    If xu == 'BLANK' Then
    Return ' '
    Return Word(x y, 1)

    --
    Jaime A. Cruz

    Nassau Wings Motorcycle Club
    http://www.nassauwings.org/


    Thank You for this quick response. I imagined that there was maybe a rexx " FORMAT" instruction to obtain the same result.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gil Barmwater@21:1/5 to All on Wed Jan 18 14:08:58 2023
    On 1/18/2023 5:21 AM, Jean-Louis Tourné wrote:
    Hello,

    How can I display (SAY) the number 123456789 under the form 123.456.789 ?

    Thank you

    Here is another way to do it if you are using ooRexx. Note that it
    assumes the input string is an integer but allows for the character to
    be inserted (.) to be changed as well as the length of each sub-string (3).

    if arg() > 0 then do
    use arg a.1, a.2='.', a.3=3
    return chunk(a.1, a.2, a.3)
    end

    ::routine chunk public
    use arg str, sep=',', size=3
    if str~length > size then do
    parse value str~length-size'|'str with p '|' +1 front +(p) back
    str = chunk(front, sep, size)||sep||back
    end
    return str

    --
    Gil Barmwater

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ErichSt@21:1/5 to All on Thu Jan 19 01:41:01 2023
    How can I display (SAY) the number 123456789 under the form 123.456.789 ?
    say translate('abc.def.ghi', 123456789, 'abcdefghi')

    For the general case, covering also smaller numbers, you could use
    say strip(translate('abc.def.ghi', 12345~right(9), 'abcdefghi'), 'l', ' .')

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?B?SmVhbi1Mb3VpcyBUb3VybsOp?@21:1/5 to All on Thu Jan 19 03:57:30 2023
    Le jeudi 19 janvier 2023 à 10:41:02 UTC+1, ErichSt a écrit :
    How can I display (SAY) the number 123456789 under the form 123.456.789 ?
    say translate('abc.def.ghi', 123456789, 'abcdefghi')

    For the general case, covering also smaller numbers, you could use
    say strip(translate('abc.def.ghi', 12345~right(9), 'abcdefghi'), 'l', ' .')



    Thank You all

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)