• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Progressbar

Started by jep, 2008.04.01, 10:24:14

Previous topic - Next topic

jep

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

Andre Nancoz

The datatype statement is missing a quote on the N literal.

  if datatype( ARG(1), 'N ) & datatype( ARG(2), 'N' ) then

jep