1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FileOpen Issue

Discussion in 'Support' started by Fross, Jul 2, 2008.

  1. Fross

    Joined:
    May 30, 2008
    Messages:
    223
    Likes Received:
    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
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    On Wed, 02 Jul 2008 07:30:37 -0500, you wrote:


    You need to say

    set l=%@fileread[%h]
    set r=%@fileclose[%h]
     
  3. WavSlave

    Joined:
    May 29, 2008
    Messages:
    47
    Likes Received:
    0
    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.
     
  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    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
     
  5. Fross

    Joined:
    May 30, 2008
    Messages:
    223
    Likes Received:
    1
    Doh!

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

    Much appreciated.

    Michael
     

Share This Page