1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

progresscounter and progressbar

Discussion in 'T&T - Scripting' started by wbiebel, Jul 25, 2008.

  1. wbiebel

    Joined:
    Jun 28, 2008
    Messages:
    22
    Likes Received:
    0
    To give the response of working to the user in batchfiles which have a longer execution time you can display a progressbar or a progresscounter. I have them in a file called "util.btm" and call them this way:

    do i = 0 to 100
    gosub "util" display_progressbar 0 %i 100
    enddo

    Here the scripts:

    :progresscounter [start current end]
    iff %end le %start then
    set xxx=%end
    set end=%start
    set start=%xxx
    unset xxx
    endiff
    if not %current ge %start .and. not %current le %end return 0

    set total=%@eval[%end - %start]
    set done=%@eval[%current - %start]
    set progress=%@eval[%done / %@max[1,%total]]
    return %@int[%@eval[%progress * 100]]


    :display_progresscounter [start current end]
    set sd1=%_expansion
    setdos /x0
    gosub progresscounter %start %current %end
    set ret=%_?
    setdos /a1
    echos ^e[s %ret ^% ^e[u
    setdos /a0
    setdos /x-%sd1
    return


    :display_progressbar [start current end]
    set len=75
    set sd1=%_expansion
    setdos /x0
    gosub progresscounter %start %current %end
    set ret=%_?
    setdos /a1
    echos ^e[s %@repeat[²,%@int[%@eval[%ret / 100 * %len]]]%@repeat[°,%@eval[%len - %@int[%@eval[%ret / 100 * %len]]]] ^e[u
    setdos /a0
    setdos /x-%sd1
    return


    Of course you can change the "len" variable as well as the two repeated bar-characters.
     
  2. doudelgado

    Joined:
    Jan 17, 2009
    Messages:
    2
    Likes Received:
    0
    WoW that's work perfect but where or How I put my own script. I try in differents areas but the result it's not correct. Can U tell me, please!
     

Share This Page