Fisheries and Oceans Canada / Pêches et Océans Canada - Government of Canada / Gouvernement du Canada Fisheries and Oceans Canada / Pêches et Océans Canada - Government of Canada / Gouvernement du Canada
 
Français Contact Us Help Search Canada Site
Home What's New DFO National Site Map Media

Fisheries & Oceans
 
 
Maritimes Region
Fishing Industry
General Public
Marine & Oceans Industry
Media
Students and Teachers
Scientists and Researchers
 
AconIconACON       Home/Topics   |   Commands   |   More Examples

File Input/Output

/*----------------------------------------------------*/
/* this example shows reading a data file and writing */
/* it to an output file "x.out". */
/* In this example if the input record contains a */
/* comment line (like these), they are removed */
/*----------------------------------------------------*/
Function Remove_comments(fname)
{   eof = 255; /* ASCII end of file is 255 */
  input = fopen(cat(fname,".in"),"r");
  output = fopen(cat(fname,".out"),"w");
  string = fgets(input);
  while (chartonum(substr(string,1,1)) != eof) do
  {  if (substr(string,1,2) != "/*") then fputs(string,output);
    string = fgets(input);
  };
  fclose(input);
  fclose(output);
};
Remove_comments(cat(HostPath(),"Test Data/Test_File_IO"));


AconIconACON       Home/Topics   |   Commands   |   More Examples



Last Modified : 2003-11-19