[Scilab-users] printf "\r" in Scilab 6x

classic Classic list List threaded Threaded
4 messages Options
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] printf "\r" in Scilab 6x

Dear Scilab’ers,

 

The following code, when executed from SciNotes in Scilab 5x, printed the loop progress to console, at same location, thanks to  printf ("\r").

The printf behaviour seems to have changed in Scilab 6x, and the strings are now printed one after the other.

 

printf("Print loop progress at same place in console (was OK in Scilab 5x):\n");

N = 1e5;

j=1;

for i=1:N

    if modulo(i,int(N/10))==0 then      // Print progress by steps of 10%

        printf("Progress = %i%s\r",j*10,"%"); // carriage return, prints at same place on console

        j=j+1;

    end

end

 

 

Is it still possible to print at same place to console in Scilab 6x?

 

Regards,

Rafael

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: printf "\r" in Scilab 6x

Le 10/04/2020 à 09:46, Rafael Guerra a écrit :

Dear Scilab’ers,

The following code, when executed from SciNotes in Scilab 5x, printed the loop progress to console, at same location, thanks to  printf ("\r").

The printf behaviour seems to have changed in Scilab 6x, and the strings are now printed one after the other.

 

printf("Print loop progress at same place in console (was OK in Scilab 5x):\n");

N = 1e5;
j
=1;
for
i=1:N
    if modulo(i,int(N/10))==0 then      // Print progress by steps of 10%
        printf("Progress = %i%s\r",j*10,"%"); // carriage return, prints at same place on console

        j=j+1;
    end

end

Please see http://mailinglists.scilab.org/Scilab-users-Scilab-API-sciprint-to-print-on-the-same-line-td4040189.html#a4040193

and http://bugzilla.scilab.org/14342

and
for i = 1:12, mprintf("Progress = %d\n\n", i); sleep(2000); clc(0); end



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: printf "\r" in Scilab 6x

Great thanks.

Using clc(0) solves it, clearing current line in the Command window.

It works both for printf and mprintf.

Maybe some generous soul could add this example to the ‘clc’ help entry?

 

 

From: users <[hidden email]> On Behalf Of Samuel Gougeon
Sent: Friday, April 10, 2020 11:36 AM
To: [hidden email]
Subject: Re: [Scilab-users] printf "\r" in Scilab 6x

 

Le 10/04/2020 à 09:46, Rafael Guerra a écrit :

Dear Scilab’ers,

The following code, when executed from SciNotes in Scilab 5x, printed the loop progress to console, at same location, thanks to  printf ("\r").

The printf behaviour seems to have changed in Scilab 6x, and the strings are now printed one after the other.

Please see http://mailinglists.scilab.org/Scilab-users-Scilab-API-sciprint-to-print-on-the-same-line-td4040189.html#a4040193

and http://bugzilla.scilab.org/14342

and
for i = 1:12, mprintf("Progress = %d\n\n", i); sleep(2000); clc(0); end

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
JLan JLan
Reply | Threaded
Open this post in threaded view
|

Re: printf "\r" in Scilab 6x

In 6.0.2 I find I need to use:

for i = 1:12, mprintf("Progress = %d\n\n\n", i); sleep(2000); clc(1); end



On 2020-04-10 10:50 AM, Rafael Guerra wrote:

> for i = 1:12, mprintf("Progress = %d\n\n", i); sleep(2000); clc(0); end
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users