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

amonmayr at laas.fr amonmayr at laas.fr
Mon Sep 3 12:38:03 CEST 2018


Hello,

As a workaround, if you replace
     1!=0  // syntax error
with
     str="1!=0";
     evstr(str);
it seems to work as you expected.

Anyway, I think the try/catch structure can catch errors occurring at 
runtime (like division by zero, etc ...), but not syntax errors.
You are supposed to write syntactically correct Scilab!

Antoine


Le 03/09/2018 à 11:48, philippe a écrit :
> 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
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>

-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

  Antoine Monmayrant LAAS - CNRS
  7 avenue du Colonel Roche
  BP 54200
  31031 TOULOUSE Cedex 4
  FRANCE

  Tel:+33 5 61 33 64 59
  
  email : antoine.monmayrant at laas.fr
  permanent email : antoine.monmayrant at polytechnique.org

+++++++++++++++++++++++++++++++++++++++++++++++++++++++




More information about the users mailing list