Mel Script - Writing Ascii Data




All file IO in mel requires the use of fopen and fclose to open and close files on the hard drive. We then use fprint to format and write the data to the file.





Example 1 : using fprint

All asci file writing in mel uses fprint to write the data to a file.



		// construct the full path to a file
		$filename = (`internalVar -userTmpDir` + "windowPrefs.mel");
		// open the file for writing
		$file = `fopen $filename "w"`;

		// fprint takes two parameters, the file ID and a text string to print
		fprint $file ( "Hello!! how are you?" + "\n" );
		fprint $file ( 100 + "\n" );
		fprint $file ( 10.05 + "\n" );

		// close the file
		fclose $file;