// rt_p_a1a1 : Program RASTELL-TOULL 
//      a1   : Reading an auxillary file in format RASTELL TOULL
//      a1a1 : Format 0 in Scilab language

// A1 Comments display
Programme = "rt_p_a1a1"
Version   = "V2.1 du 20120503"
Copyright = "Jacques-Deric Rouault - Rastell Toull"
mprintf ("Program   = " + Programme + "\n")
mprintf ("Version   = " + Version + "\n")
mprintf ("Copyright = " + Copyright + "\n" + "\n")

// A2 Directory control
[fsce,erreur] = mopen (Programme + ".sce","r");
if erreur<>0 then 
  mprintf ("ERROR A2 : DIRECTORY ERROR " + Programme + ".sce\n\n");
  abort; 
end;  
mclose (fsce);
mprintf ("A2 Directory Control OK\n")

// A3 Opening the auxilliary text file
[ftxt,erreur] = mopen(Programme +'.txt','r')
if erreur<>0 then
  mprintf ("ERROR A3 : AUXILLIARY FILE NOT FOUND\n\n")
  abort
end
mprintf ("A3 Opening the auxilliary text file OK\n")

// A4 Reading and control of identifier RASTELL-TOULL
str = mgetl (ftxt,1);
if str <> "\\RASTELL-TOULL" then 
  mclose (ftxt);  
  mprintf ("ERROR A4 : IDENTIFIER RASTELL-TOULL INCORRECT\n\n");
  mclose(ftxt)
  abort;
end;
mprintf ("A4 Identifier RASTELL-TOULL correct\n")

// A5 Reading and control of identifier FORMAT
str = mgetl (ftxt,1);
if str <> "\\FORMAT" then 
  mprintf ("ERROR A5 : IDENTIFIER FORMAT INCORRECT\n\n");
  mclose (ftxt);  
  abort;
end;
mprintf ("A5 Identifier FORMAT correct\n")

// A6 Reading and control of the value of the format
str = mgetl (ftxt,1);
format_fichier = sscanf (str,"%i");
if format_fichier <> 0 then 
  mprintf ("ERROR A6 : INCORRECT VALUE OF FORMAT\n\n");
  mclose (ftxt);  
  abort;
end;
mprintf ("A6 Value of format is correct\n")

// A7 Reading and control of identifier FINEND
str = mgetl (ftxt,1);
if str <> "\\FINEND" then 
  mprintf ("ERROR A7 : IDENTIFIER FINEND INCORRECT\n\n");
  mclose (ftxt);  
  abort;
end;
mprintf ("A7 Identifier FINEND correct\n")

// A8 Closing the auxilliary text file
mclose(ftxt)

// A9 End of running
mprintf ("End of running of program " + Programme + " OK\n");
