[Swift-user] passing a file as an argument

J A jamalphd at gmail.com
Mon Feb 1 20:14:36 CST 2010


Hi:

I tried that but got an error ...


*the command is:*

$ swift  CreateFiles.swift  -fname=list.txt


*My code looks like this:*


type file{};
type messagefile {};
//file list<"list.txt">;     // if I uncomment this line and comment the
next line, my code will work fine but I want the file name
                                 // to be dynamic
file list<@arg("fname")>;
..
...
...


*The error I got was:*


$ swift CreateFiles.swift -fname=list.txt
Could not compile SwiftScript source: line 7:11: unexpected token: @



Thanks for your help.

Jamal



On 1/31/10, Michael Wilde <wilde at mcs.anl.gov> wrote:
>
> Jamal, for this, you pass the file name on the command line as a script
> argument after all the swift command arguments, and pick it up inside your
> swift script with the @arg() function, which is like argv in C (except
> indexed by name rather than position). Its described in the User Guide.
>
> - Mike
>
>
> ----- "J A" <jamalphd at gmail.com> wrote:
>
> > Hi:
> >
> > how can I pass a file when executing swift, so i want to do something
> > like this:
> >
> > $ swift file.txt
> >
> >
> > how do I catch the file inside the code?
> >
> > Thanks,
> > Jamal
> >
> > _______________________________________________
> > Swift-user mailing list
> > Swift-user at ci.uchicago.edu
> > http://mail.ci.uchicago.edu/mailman/listinfo/swift-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-user/attachments/20100201/1ac65385/attachment.html>


More information about the Swift-user mailing list