Last Newline

The last line in a Scilab script is ignored if it is not terminated by a newline (^J on UNI* systems, but most of the time written in C-style \n). This is emphasized at several places in the official Scilab documentation, but it is so common to forget it especially when using emacs that we repeat it here. However, emacs can be told always to add a final newline by adding (setq require-final-newline t) to the startup-file, .emacs. See "Learning GNU Emacs" [cameron:1996], Table C-8.

Another weapon against this kind of syntax flaw, and a few other pesky things, is e.g. the Perl-script shown in Example 2-2, which fixes part of the format of a Scilab script.

Example 2-2. Canonicalization of Scilab files

        use Text::Tabs;
        while (<>) {
            chomp;                  # remove newline if there is one
            tr/\200-\377/ /;        # map 8-bit chars to spaces
            s[\s+$][];              # kill whitespace at end of line 
            $_ = expand $_;         # convert tabs to spaces
            print "$_\n";           # print adding a newline