Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Io Octave/CLI--在同一控制台线路上保持长输出_Io_Command Line Interface_Octave - Fatal编程技术网

Io Octave/CLI--在同一控制台线路上保持长输出

Io Octave/CLI--在同一控制台线路上保持长输出,io,command-line-interface,octave,Io,Command Line Interface,Octave,我使用的算法需要一些时间来计算,如果我打印输出以确保正确的代码部分正在执行,即使每次迭代只写一个,我最终会看到整个屏幕上布满了点,这些点覆盖了我可能感兴趣的所有以前的输出 将输出发送到控制台行时,是否有办法“将光标发送回”控制台行?或者,是否有办法在控制台输出上输出一个“旋转条”,以执行从点a到点B的程序所需的时间 我想要写的是以下内容,其中每一行都会按顺序出现在同一行上: Processing Processing . Processing .. Pricessing ... Processi

我使用的算法需要一些时间来计算,如果我打印输出以确保正确的代码部分正在执行,即使每次迭代只写一个
,我最终会看到整个屏幕上布满了点,这些点覆盖了我可能感兴趣的所有以前的输出

将输出发送到控制台行时,是否有办法“将光标发送回”控制台行?或者,是否有办法在控制台输出上输出一个“旋转条”,以执行从点a到点B的程序所需的时间

我想要写的是以下内容,其中每一行都会按顺序出现在同一行上:

Processing
Processing .
Processing ..
Pricessing ...
Processing
Processing .
Processing ..

您可以打印退格字符(
\b
),这将向后移动光标。似乎它可能会覆盖以前的字符,但在我的上它不会。比如说:

printf ("processing ");
for i = 1:3
  for i = 1:9
    printf (".");
    pause (0.1);
  endfor
  printf (repmat ("\b", 1, 9));
  printf (repmat (" ", 1, 9));
  printf (repmat ("\b", 1, 9));
endfor
printf ("\n");
[############################################              ]   80%
或者,您可以安装Octave Forge,这里有
text\u waitbar
功能:

pkg load miscellaneous;

text_waitbar (0, 70); # set length of waitbar
text_waitbar (0.0, "processing ");
for i = 1:3
  for i = 1:9
    text_waitbar (i/9, "processing");
    pause (0.1);
  endfor
endfor
看起来是这样的:

printf ("processing ");
for i = 1:3
  for i = 1:9
    printf (".");
    pause (0.1);
  endfor
  printf (repmat ("\b", 1, 9));
  printf (repmat (" ", 1, 9));
  printf (repmat ("\b", 1, 9));
endfor
printf ("\n");
[############################################              ]   80%

看一下杂项软件包中的text_waitbar我试图让text_waitbar正常工作,但这正是我想要的。你是对的,text_waitbar是如此简单和方便,给我留下了深刻的印象。唯一的缺点是警告库中某些不推荐使用的语法。