Next: Optimized computational sequences Up: Implementation Previous: Other Assign forms

Interactive output

Interactive output can be used in a session to send results to files. A change in definition followed by re-execution results in modified contents of the file. Here the text file temp.f is created and the contents of the file are displayed.


In[4]:= example1 = {Expand[(a+b-c-d)^2],
                    Sin[Expand[(a+Exp[(b-c-d)])^3]]};
In[5]:= channel = OpenWrite["temp.f",FormatType->OutputForm];
In[6]:= Write[channel,FortranAssign[a,example1]];
In[7]:= Close[channel];

In[8]:= !!temp.f

        a(1)=a**2+2.*a*b+b**2-2.*a*c-2.*b*c+c**2-2.*a*d-2.*b*d+2.*c*d
     &  +d**2
        a(2)=sin(a**3+exp(3.*b-3.*c-3.*d)+3.*a*exp(2.*b-2.*c-2.*d)+3.
     &  *a**2*exp(b-c-d))
The process of writing to an external file has been simplified, by inclusion of the option AssignToFile.


In[9]:= FortranAssign[a,example1,AssignToFile->"temp.f"];

In[10]:= !!temp.f

        a(1)=a**2+2.*a*b+b**2-2.*a*c-2.*b*c+c**2-2.*a*d-2.*b*d+2.*c*d
     &  +d**2
        a(2)=sin(a**3+exp(3.*b-3.*c-3.*d)+3.*a*exp(2.*b-2.*c-2.*d)+3.
     &  *a**2*exp(b-c-d))
As has already been mentioned, the output produced by the Assign functions is a sequence of strings. The strings are wrapped in OutputForm, which avoids printing of string delimiters (") for example. Cutting and pasting of results using an editor is then straightforward. This process also facilitates the use of the Copy Output From Above command when using the NoteBook interface.


bondaren@thsun1.jinr.ru