FileOpen Issue

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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
 
#4
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