Page 1 of 1

Only use first console line (Windows) to output things?

Posted: Wed Jan 06, 2021 4:14 pm
by jacky
Hello,

I'm currently working on a console app that should provide some progress output.
It's working with (large) folder structures but what I don't want it to spam the whole console line by line for each folder processed.

Is it possible to just use output a progress report to the first line (of the console), clear that line and use it again when the next progress report is due?
If the output must be wrapped because it's too long, that part would need to be cleared as well...

Go(lang) has a nice library which does it inside the Windows console (https://github.com/vbauerster/mpb) so I guess there is a way in PB, too?

Re: Only use first console line (Windows) to output things?

Posted: Wed Jan 06, 2021 5:30 pm
by mk-soft
Use EnableGraphicalConsole

Code: Select all

If OpenConsole()
  EnableGraphicalConsole(1)
  
  ConsoleLocate(0, 0)
  Print(Space(80*23))
  
  For i = 0 To 100
    ConsoleLocate(0, 0)
    Print(Space(80))
    ConsoleLocate(0, 0)
    Print("Counter " + i)
    Delay(50)
  Next
  
  ConsoleLocate(30, 10)
  PrintN("Press return to exit")
  Input()
EndIf

Re: Only use first console line (Windows) to output things?

Posted: Wed Jan 06, 2021 5:47 pm
by jacky
It's so easy? Wow...

Thank you mk-soft!