Write2

Description

Write2[file, val1 = expr1, val2 = expr2, ...] writes the settings val1 = expr1, val2 = expr2 in sequence followed by a newline, to the specified output file. Setting the option FormatType of Write2 to FortranForm results in FORTRAN syntax output.

The continuation character for FORTRAN output can be controlled by changing $FortranContinuationCharacter.

FullForm[$FortranContinuationCharacter]

Options[Write2]

Attributes[Write2]

See also:  Isolate, PaVeReduce.

Examples

t = 
      Collect[((((((a - c))^2) + (((a - b))^2)))^2), a, Factor]

tempfilename = ToString[$SessionID] <> ".s";

This writes the assignment r=t to a file.

Write2[tempfilename, r = t];

This shows the contents of the file.

TableForm[
      ReadList[If[$OperatingSystem === "MacOS", ":", ""] <> 
          tempfilename, String]]

DeleteFile[
      If[$OperatingSystem === "MacOS", ":", ""] <> 
        tempfilename]

t2 = x + Isolate[t, a, IsolateNames -> W]

Write2[tempfilename, r = t2];

TableForm[
      ReadList[If[$OperatingSystem === "MacOS", ":", ""] <> 
          tempfilename, String]]

DeleteFile[
      If[$OperatingSystem === "MacOS", ":", ""] <> 
        tempfilename]

This is how to write out the expression t2 in Fortran format.

Write2[tempfilename, r = t2, FormatType -> FortranForm];

TableForm[
      ReadList[If[$OperatingSystem === "MacOS", ":", ""] <> 
          tempfilename, String]]

DeleteFile[
      If[$OperatingSystem === "MacOS", ":", ""] <> tempfilename]; 
    Clear[t, t2, tempfilename];