[Swift-user] Writing to an output file

Michael Wilde wilde at mcs.anl.gov
Thu Jun 4 13:06:16 CDT 2009


Erin,

An app function can only be the declaration of a single external 
application. It can't be anything else - and here you're trying to use 
an app declaration to return a value, like a Java property.

You'll typically want to place statements like "int x = 10" in open code 
  (ie outside all otehr procedures, typically at the end of your script) 
or inside a compound procedure.

Next, what you're trying to do here doesnt fit well with the Swift 
model: you typically dont take data that you compute directly in Swift 
(as opposed to in a Swift app) and write that data to a file. Files are 
typically written only by app procedures - i.e., they contain the output 
of programs.

- Mike


In this test, were you just trying to fill an array with scalar values

On 6/4/09 12:36 PM, Hodgess, Erin wrote:
> Here is what SHOULD be a simple process.  I'm writing to an array, and 
> sending that to an output file.  Here are the files and the results:
> 
> [erin at tp-login2 swift1]$ cat iter2.swift
> type file; 
>  
> app initialCondition() { 
>         int x = 10;
> } 
> 
>      int step[0]=initialCondition();
> 
> file o <"output.txt">; 
> 
>         o=step[0];
> [erin at tp-login2 swift1]$ swift -tc.file tc.data iter2.swift
> Could not compile SwiftScript source: line 4:13: unexpected token: x
> [erin at tp-login2 swift1]$
> 
> The file is in /home/erin/swift1/iter2.swift.
> 
> Thanks,
> Erin
> 
> 
> 
> Erin M. Hodgess, PhD
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: hodgesse at uhd.edu
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-user



More information about the Swift-user mailing list