Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

FileOpen Issue

May
380
4
Hey all,

I think I might be losing my brain, but I've been having trouble with fileopen. I wrote this quick little batch file to illustrate. Does anyone else have this issue?

Code:
set h=%@FileOpen["%1",r]
set l=%@FileRead[h]
set r=%@FileClose[h]

If I run it against a text file (I've tried several) I receive:
Code:
TCC: (Sys) C:\Temp\xx.btm [2] The parameter is incorrect.
"%@FileRead[h]"
TCC: (Sys) C:\Temp\xx.btm [3] The handle is invalid.
"%@FileClose[h]"

Any idea what I'm doing wrong? I seems that the handle is not getting set correctly due to the fileclose message. I've also tried to hard code the name to ensure that I wasn't mistyping the command line.

I know I've used fileopen/fileread many times in the past, but I seem to be stuck here.

Thanks,

Michael
 
On Wed, 02 Jul 2008 07:30:37 -0500, you wrote:


>set h=%@FileOpen["%1",r]
>set l=%@FileRead[h]
>set r=%@FileClose[h]

You need to say

set l=%@fileread[%h]
set r=%@fileclose[%h]
 
Code:
set h=%@FileOpen["%1",r]
set l=%@FileRead[h]
set r=%@FileClose[h]

I would think that the h argument is being interpreted literally rather than being replaced by the value of h. Try using %h in the second and third SET commands and see if that fixes things.
 
frossm wrote:
| Hey all,
|
| I think I might be losing my brain, but I've been having trouble with
| fileopen. I wrote this quick little batch file to illustrate. Does
| anyone else have this issue?
|
|
| Code:
| ---------
| set h=%@FileOpen["%1",r]
| set l=%@FileRead[h]
| set r=%@FileClose[h]
| ---------
|
| If I run it against a text file (I've tried several) I receive:
|
| Code:
| ---------
| TCC: (Sys) C:\Temp\xx.btm [2] The parameter is incorrect.
| "%@FileRead[h]"
| TCC: (Sys) C:\Temp\xx.btm [3] The handle is invalid.
| "%@FileClose[h]"
| ---------
|
| Any idea what I'm doing wrong? I seems that the handle is not getting
| set correctly due to the fileclose message. I've also tried to hard
| code the name to ensure that I wasn't mistyping the command line.
|
| I know I've used fileopen/fileread many times in the past, but I seem
| to be stuck here.

It is a well-known phenomenon (called psychological stet) that we see not
what we actually wrote, but what we thought we wrote. In your 2nd and 3rd
statements you use the letter h, instead of the value of the variable h -
i.e., %h.

I've been victim of this, too!
--
HTH, Steve
 
Doh!

Thanks everyone. I must have looked at this 100 times and I just didn't see it.

Much appreciated.

Michael
 
Back
Top
[FOX] Ultimate Translator
Translate