Justin C. Walker on Mon, 04 Feb 2008 08:32:10 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Question on input from a file...



On Feb 3, 2008, at 22:06 , David Cleaver wrote:

Hello everyone,

I've written a series of instructions in a file and now I need to run those instructions while I'm in gp. When I ran read(str_file), it looked like it was trying to read and run the commands in the file, but it kept running into errors. The biggest problem I could tell was that it didn't like all my commands on separate lines. So, I put all the commands on one line, and it still came back with an error [expected character: ')' instead of: ...<instructions>]

One thing to keep in mind when tracking down these syntax errors is that 'gp' likes to have its "instructions" separated by ";". What these errors tell you is that you need a few of these :-}

In particular, look at the last 'write', and the 'str_line' before the last 'for' statement.

It's taken me a while to figure out how to get to where I'm at, but now I'm stuck and was wondering if anyone could look at my following code snippet and tell me what needs to be fixed for this to work?

Also, if you want to stick snippets in files, note that 'gp' likes statements on one (virtual) line, so if you want to split this across lines, as you do in your snippet, enclose the lines in "{}".

And a final note to ease typing burdens :-} you can use "\r /path/to/ file" (no quotes) in place of read("/path/to/file"). If the file is in the directory you were in when you ran 'gp', you can drop the "/ path/to/".

Hope that helps.

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
-----------
My wife 'n kids 'n dogs are gone,
I can't get Jesus on the phone,
But Ol' Milwaukee's Best is my best friend.
-----------