OS2World OLD-STATIC-BACKUP Forum

OS/2 - SIGs => Rexx => Topic started by: jep on 2008.04.01, 10:24:14

Title: Progressbar
Post by: jep on 2008.04.01, 10:24:14
Marked as: Easy
Hello,

here's an example on how to create a function that display a progressbar.

call rxProgress 23, 214, 2 /* row 0 is the topmost row */


/* part, of_total, display_on_row */
rxProgress: Procedure
    if datatype( ARG(1), 'N' ) & datatype( ARG(2), 'N' ) then
    do
        if datatype( ARG(3), 'W' ) then
            parse value SysCurPos( ARG(3), 0 ) with prev_row prev_col
    progress = 76 * ARG(1) % ARG(2)
    say left( copies( '█', progress )||copies( '░', 76 - progress ), 76 )||right( ( ( 100 * ARG(1) ) % ARG(2) )||'%', 4 )
        if datatype( ARG(3), 'W' ) then
            call SysCurPos prev_row, prev_col
    end
Return 0
Title: Re: Progressbar
Post by: Andre Nancoz on 2008.04.02, 19:23:18
The datatype statement is missing a quote on the N literal.

  if datatype( ARG(1), 'N ) & datatype( ARG(2), 'N' ) then
Title: Re: Progressbar
Post by: jep on 2008.04.03, 11:52:41
Fixed :-)

Thanks