GNU Octave에서 단일 파일의 실행 보기(echo fcnname on)

GNU Octave에서 단일 파일의 실행 보기(echo fcnname on)

질문은 간단합니다. MATLAB에서는 간단히 단일 상태를 echo myFun on설정하는 데 사용할 수 있습니다.echo기능m-file을 로 변환 on하면 실행된 각 행이 표시됩니다.

그러나 GNU Octave에는 이러한 구문이 없습니다. help echo쇼:

octave:1> help echo
'echo' is a built-in function from the file libinterp/corefcn/input.cc

 -- Command: echo
 -- Command: echo on
 -- Command: echo off
 -- Command: echo on all
 -- Command: echo off all
     Control whether commands are displayed as they are executed.

     Valid options are:

     'on'
          Enable echoing of commands as they are executed in script
          files.

     'off'
          Disable echoing of commands as they are executed in script
          files.

     'on all'
          Enable echoing of commands as they are executed in script
          files and functions.

     'off all'
          Disable echoing of commands as they are executed in script
          files and functions.

     With no arguments, 'echo' toggles the current echo state.

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the [email protected]
mailing list.

더 자세히 살펴보면 정보 페이지에 다음과 같은 내용이 나와 있습니다.

 -- Built-in Function: VAL = echo_executing_commands ()
 -- Built-in Function: OLD_VAL = echo_executing_commands (NEW_VAL)
 -- Built-in Function: echo_executing_commands (NEW_VAL, "local")
     Query or set the internal variable that controls the echo state.

     It may be the sum of the following values:

     1
          Echo commands read from script files.

     2
          Echo commands from functions.

     4
          Echo commands read from command line.

     More than one state can be active at once.  For example, a value of
     3 is equivalent to the command 'echo on all'.

     The value of 'echo_executing_commands' may be set by the 'echo'
     command or the command line option '--echo-commands'.

     When called from inside a function with the "local" option, the
     variable is changed locally for the function and any subroutines it
     calls.  The original variable value is restored when exiting the
     function.

따라서 아래의 시도와 같은 방법으로 잠재적으로 문제를 해결할 수 있습니다. 그러나 문서에서 알 수 있듯이 이는기능과 어느 서브루틴 호출. 그래서 문제는 아직 해결되지 않았습니다. 나는 내 자신의 질문에 대답했다고 생각했지만 그렇지 않다는 것을 깨달았습니다.

echo_executing_commands(2, 'local');디버깅이 필요한 함수 파일의 시작 부분에 추가하기만 하면 됩니다 . 즉, 을 열고 myFun.mm-file 함수의 시작 부분에 명령문을 삽입합니다. 참고로 이는오직옥타브 기능을 완벽하게 호환하려면 다음을 사용하세요.

if exist('OCTAVE_VERSION', 'builtin') ~= 0; echo_executing_commands(2, 'local');end

답변1

이 작동하지 않습니다

echo_executing_commands(2, 'local');디버깅이 필요한 함수 파일의 시작 부분에 추가하기만 하면 됩니다 . 즉, 을 열고 myFun.mm-file 함수의 시작 부분에 명령문을 삽입합니다. 참고로 이는오직옥타브 기능을 완벽하게 호환하려면 다음을 사용하세요.

if exist('OCTAVE_VERSION', 'builtin') ~= 0; echo_executing_commands(2, 'local');end

관련 정보