[Scilab-users] diary lost in try/catch statement .

philippe rouxph.22 at gmail.com
Mon Sep 3 11:48:04 CEST 2018


Hi,

In scilab-5 I used to save console output of script file execution in a
text file with "diary", this seems to fail in scilab-6, for new errors
types recently added (Syntax error, Unexpected token ).  Perhaps I
misunderstood something in try/catch statement , let's consider the file
bug_syntax_error.sce containing :

diary(0)
diary('file.txt','new');
try disp('let''s make an error')
    1!=0  // syntax error
catch
    disp('added to diary')
end
diary('file.txt','close')


execute this script with CTRL+SHIFT+E  or "exec" will not create file.txt


--> exec('bug_syntax_error.sce', -1)
à la ligne     4 du fichier exécuté bug_syntax_error.sce

    1!=0  // syntax error
     ^^
Erreur : Unexpected token '!'

--> mgetl file.txt

mgetl : Impossible d'ouvrir le fichier file.txt.

execute this script from scinotes with CTRL+E will give :


--> diary(0)

--> diary('file.txt','new');

--> try disp('let''s make an error')
  >     1!=0  // syntax error
  > catch
  >     disp('added to diary')
  > end
    1!=0  // syntax error
     ^^
Erreur : Unexpected token '!'

--> diary('file.txt','close')

--> mgetl file.txt
 ans  =

!                                      !
!                                      !
!--> try disp('let''s make an error')  !
!                                      !
!  >     1!=0  // syntax error         !
!                                      !
!  > catch                             !
!                                      !
!  >     disp('added to diary')        !
!                                      !
!  > end                               !
!                                      !
!    1!=0  // syntax error             !
!                                      !
!     ^^                               !
!                                      !
!Erreur : Unexpected token '!'         !
!                                      !
!                                      !
!                                      !
!--> diary('file.txt','close')         !


I also remark that those new errors (like bad comparisons 1=2  or bad
string delimiters mixing ' and " ) have no localization. This doesn't
happend with "old" errors (which have localization), replacing "1!=0"
with "ieee(0),1/0" I get :

--> exec('bug_syntax_error.sce', -1)

 let's make an error

 added to diary

--> mgetl file.txt
 ans  =

!                      !
!                      !
! let's make an error  !
!                      !
!                      !
!                      !
! added to diary       !


Best regards,

Philippe




More information about the users mailing list