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

Just starting out? Need help? Post your questions and find answers here.
jacky
User
User
Posts: 66
Joined: Mon Jan 21, 2019 1:41 pm

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

Post 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?
User avatar
mk-soft
Always Here
Always Here
Posts: 6255
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

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

Post 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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
jacky
User
User
Posts: 66
Joined: Mon Jan 21, 2019 1:41 pm

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

Post by jacky »

It's so easy? Wow...

Thank you mk-soft!
Post Reply