Home AMX User Forum NetLinx Studio

using file_open command

Hi,
Just wondering if anybody has ever used the file_open command to open files for reading and/or writing? Im trying to use it at the moment to open a web page but not having much success. Has anybody any tips on what to do? I have done this before using different languages and it has always been fairly straightforward. I'm pretty new to this language, maybe there is something I have missed? This is what I have tried:

define_constant
char filePath[50] = 'http://www.******.ie' //file to open
integer ioFlag = 1 //read only

define_variable
slong handle
.
.
.
.
handle = file_open(filePath,ioFlag) //open the file

Problem is handle returns a -5 which means a disk I/O error.
I was talking to tech support about this and they're not really sure why its not working.

Comments

  • DHawthorneDHawthorne Posts: 4,584
    I don't think the FILE_OPEN command supports the HTML protocol. It's meant for a local file on your master's RAM drive. Opening HTML on the web is very different than opening a local file. The HTML protocol requires a request to the HTML server, and the server responds by sending the file, which is then cached to your local drive. FILE_OPEN won't do any of that. You will probably need to mimic the HTML commands in a TCP connection, save it locally, and then use FILE_OPEN. Depending on what you are trying to do, it might be just as easy at that point to parse the HTML stream directly.
  • Chip MoodyChip Moody Posts: 727
    If you're looking to get data from a web server, you'll need to look into the IP_CLIENT_OPEN command in NetLinx. Once you have an open TCP/IP connection to the web server, (you'll get an online event for the device you create for the connection) you need to send HTTP commands to request the document/resource you're looking for.

    If you want some source code to mull over, say the word. If you can give more of a clue as to what you're doing, that would help...

    - Chip
  • Chip MoodyChip Moody Posts: 727
    P.s.

    The file operation commands in NetLinx work with the "Disk On Chip" on the original masters, and the compact flash cards (formatted as a disk) on the NI's and ME-260s...

    - Chip
  • shanemshanem Posts: 28
    Thanks for your help guys, I got it now.

    Cheers,
    Shane
Sign In or Register to comment.