Page 1 of 1

File i/o error using file number #1

Posted: Thu Feb 02, 2017 9:30 pm
by bagee
I can not figure this out at all.

I am running a macro report offline and I am getting the error in the topic line.
The report works for some files and and not for others and it seems to also depend on the workstation being used?? Anyone have any ideas???

This is where I believe the error comes from, but I'm not sure how to fix it.

name report

tempfile$=_exepath$ + "Input.txt"

bunch of lines.....

! Print file (to Printer)
Open tempfile$ for input as #1
counter=43
i=0
While i < 2
Input #1, line$
counter = counter + 1
StrPrint "" + line$, 1, counter
If LEN(line$)= 0
i=i+1
Else
i=0
EndIf
If counter = 70 Then
EndPrint
StartPrint
StrPrint "Data file: " + _DataPath$ + _Datafile$, 1, 1
Counter = 3
EndIf
EndWhile
Close #1
EndPrint
Draw 2, R5
Delete _ExePath$ + "Input.txt", DontAsk

Re: File i/o error using file number #1

Posted: Sat Feb 04, 2017 8:52 am
by antonk
not sure about Chemstation macros, but from the days of yore file handles
numbered
1 - standard output
2 - standard input
3 - standard error
And that is so for nearly all platforms.
And while the program works they are already opened.

Try #7 for instance :)

Re: File i/o error using file number #1

Posted: Mon Feb 06, 2017 5:24 am
by mckrause
Agreed. I don't like using 1, 2 or 3 for I/O. If you go read some of the macros that HP wrote you'll see that they favor using #30, #50 and #100 for file numbers.