Sign in to follow this  
Followers 0
micechal

Output to console at the same line continuously

5 posts in this topic

Hi. Quick question:

How can I avoid such thing:

Processing 1 of 10 (10%)...
Processing 2 of 10 (20%)...
Processing 3 of 10 (30%)...
Processing 4 of 10 (40%)...

when using ConsoleWrite, in favor of only one line being rewritten/erased multiple times?

Share this post


Link to post
Share on other sites



Use @CR only.

 

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thank you, that works great when run from cmd.exe. But do you know if it's also possible to achieve this in Scite? Or maybe it was designed like so on purpose?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This example works with SciTE's output pane..

For $i = 1 To 5
    _ConsoleWriteSameLine("Line #" & $i)
    Sleep(1000)
Next

ConsoleWrite("The End" & @LF)


Func _ConsoleWriteSameLine($sMessage)
    ControlSend("[Class:SciTEWindow]", "", "Scintilla2","+{HOME}{DEL}{BS}+{HOME}{DEL}")
    ConsoleWrite($sMessage & @LF)
EndFunc   ;==>ConsoleWriteSameLine

Edit: Replaced Chr(8) & "+{HOME}{DEL}") ; Chr(8) = backspace character, in the case where characters already exist on the line being written to. The first "+{HOME}{DEL}" deletes that line, if it exists. Then, the "{BS}" makes the cursor jump to the line above where the second "+{HOME}{DEL}" deletes that line also.

Edited by Malkey

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

That just looks like a horrible idea... but interesting to see how it turns out.

Edit:

I happened to pause the script at an opportune time:

For $i = 1 To 500
    _ConsoleWriteSameLine("Line #" & $i)
    Sleep(100)
Next

ConsoleWrite("The End" & @LF)


Func _ConsoleWriteSameLine($sMessage)
    ControlSend("[Class:SciTEWindow]", "", "Scintilla2","+{HOME}{DEL}{BS}+{HOME}{DEL}")
    ConsoleWrite($sMessage & @LF)
EndFunc   ;==>ConsoleWriteSameLine 

Scite->Output:

ine #139Line #140

 

Other times I saw the BS char.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0