David Cleaver on Mon, 04 Feb 2008 07:49:04 +0100

 Question on input from a file...

```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>]
```
```
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?
```
Some setup info:
b=factor(a)
(here, a and b have the same length)

The code snippet:

for (i=1,length(b),
str_line=Str(a[i], " = ");
for (j=1,length(b[i][,1]),
if (b[i][,2][j] == 1,
if (j!=length(b[i][,1]),
str_line=concat(str_line, Str(b[i][,1][j], " * ")),
str_line=concat(str_line, Str(b[i][,1][j]))
),
if (j!=length(b[i][,1]),
str_line=concat(str_line, Str(b[i][,1][j], "^", b[i][,2][j], " * ")),
str_line=concat(str_line, Str(b[i][,1][j], "^", b[i][,2][j]))
)
)
)
str_line=concat(str_line, Str(" = "))
for (j=1,length(b[i][,1]),
if (j!=length(b[i][,1]),
str_line=concat(str_line, Str(((b[i][,1][j]-1)/(b[i][,1][1]-1)), " & ")),
str_line=concat(str_line, Str(((b[i][,1][j]-1)/(b[i][,1][1]-1))))
)
)
)
write(str_out, str_line)

This should produce output like the following:
1373653 = 829 * 1657 = 1 & 2
1530787 = 619 * 2473 = 1 & 4
101649241 = 61 * 661 * 2521 = 1 & 11 & 42

```
I probably have some small typo somewhere, or I'm probably using some functions incorrectly. I would appreciate any help or guidance that anyone can provide.
```
-David C.

```