FileOpen Issue

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
 
May 20, 2008
11,288
95
Syracuse, NY, USA
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]
 
May 29, 2008
47
0
Orion Arm, MWG
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.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
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
 
Similar threads
Thread starter Title Forum Replies Date
vefatica @FILEOPEN with W(rite) empties file! Support 6
vefatica Fixed @FILEOPEN returns 4294967295 Support 2
R fileopen Support 1
G v28 Display Issue Support 7
Jay Sage Issue with CD_ENTER Alias Support 37
Jay Sage Issue with CD_LEAVE Alias Support 3
fpefpe How to? issue with % and evaluation Support 5
cgunhouse Standard User Account Issue Support 2
samintz WAD Display wrapping issue Support 5
M TCC color issue in ConEmu Support 4
samintz Timer issue Support 4
Alpengreis Documentation Minor issue in help file for view /E Support 1
samintz WAD ANSI issue Support 3
D TCSTART issue after reinstallation Support 14
A Documentation [Help file] OPTION "//" synopsis formatting issue Support 0
Chen Touboul Overtyping issue - i press the Insert key, help till press enter for new line in TCC Support 2
Y TCC and Cmder imcompatibility issue Support 7
M Another possibly strange remote registry issue Support 5
T WAD bpokestr issue Support 5
D High-DPI Scaling issue Support 1
S CMDebug 22 issue with del command Support 1
cgunhouse Foldermonitor Issue Support 7
samintz Build 38 Install issue Support 5
rps WAD Setlocal issue Support 4
Luiz Rodrigues Issue with Maven Support 1
Seven Update / install issue with 20.0.20.10.32 take command Support 7
Fross WebDav Drive Mapping Issue Support 19
D Upgrade issue Support 3
Fross V20b8 Everything Issue Support 5
T TCC display issue Support 1
cgunhouse _logfile Issue Support 5
T Fixed Querybox issue Support 1
cgunhouse Fixed Share Memory Issue Support 5
cgunhouse Foldermonitor with "/E" Option Issue Support 6
Fross TabComplete Argument Issue Support 1
fpefpe How to? Stange start up issue Support 1
C cosmetic issue with LIST's (I) Support 9
jbarnes1967 TC 18.00 x64 issue with lua io.popen() Support 2
D How to? Wildcards as sets - looping issue with FOR and REN Support 7
T WAD Free issue Support 6
R Fixed v17.0.54 Tab->COMSPEC Dialog Box Issue Support 2
R Minor Cosmetic Issue in Take Command Window Support 2
cgunhouse One line IFF ... Then ... Else ... EndIFF Statement issue in V17 Support 13
cgunhouse IFTP Path Issue in V17 - Fixed Support 7
S BDEBUGGER issue Support 9
cgunhouse @ISPROC Issue Support 15
cgunhouse TCMD.INI Issue Support 7
T Fixed multi-line alias issue Support 13
R WAD issue with filename completion with system and hidden files Support 8
D Strange issue with FOR loop Support 15

Similar threads