Announcement

Collapse
No announcement yet.

Open handle does not return filenum > 0.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Open handle does not return filenum > 0.

    While it still works i wanted to open a API file using Open handle and use it's returned filenum with Line input #..

    It seems that Line Input only handles #..

    I wanted to open in an earlier stage and use a global variable in a type.
    Since it doesn't actually returns a new pb filenumber i assume it's all based on basic notation only.


    Dim FF As Long

    open handle hAPIFile For Input As #FF

    Line Input #FF....

    FF is 0 but works fine.

    But now this;

    Type AllSettings

    hAPIFile As long
    hPBFile As Long

    End Type

    Global MyType as AllSettings

    Open handle MyType.hAPIFile For Input As MyType.hPBFile

    Line Input MyType.hPBFile, a$


    Can't get this to work..
    (In fact, I still need an API Line Input..)


  • #2
    OPEN HANDLE requires a valid handle to a file that is already open! Are you actually filling "FF" with a valid handle? From you code you appear to be using OPEN HANDLE with an unopened file. OPEN HANDLE is designed to be used to access a file that is opened by an API call, of from another module (such as when your PB code is in a DLL called from another application, etc)

    'psuedocode
    DIM FF AS LONG
    FF = CreateFile(...) ' Open the file and return a handle to a file
    OPEN HANDLE...AS #FF

    Also, the # prefix is required by LINE INPUT#.

    It is unclear (at least to me ) - what you are really trying to achieve.




    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment

    Working...
    X