mIRC Homepage
Posted By: crashy read excel with socket? - 12/01/03 07:58 AM
Can you read data from a spreadsheet on a website using a socket?

If so, how?
Posted By: Online Re: read excel with socket? - 12/01/03 09:04 AM
You can download the file and run it.

The example below downloads the file Vols&Divs.xls from asx.com.au.

Copy the code, read its comments, and type /excel to begin.

Code:
alias excel {
  [color:green]; Close the socket if already open.[/color]
  sockclose excel
  [color:green]; Open a socket connection[/color]
  sockopen excel asx.com.au 80
}
On *:sockopen:excel:{
  [color:green]; Clear destination file[/color]
  write -c file.xls
  [color:green]; Send HTTP request[/color]
  sockwrite -tn excel GET /programs/Vols&Divs.xls HTTP/1.0
  sockwrite -tn excel Accept: */* *.*
  sockwrite -tn excel Connection: close
  sockwrite -tn excel Host: asx.com.au
  sockwrite -tn excel
}
On *:sockread:excel:{
  [color:green]; As you probably know, the server sends 
  ; some header information prior to the file data.
  ;
  ; We've gotta filter that header, as including it
  ; in the file would corrupt it.
  ;
  ; Here I mark the socket once the header ends
  ; to know whether we can start writing into the file.[/color]
  if !$sock(excel).mark {
    [color:green]; If the socket isn't marked yet, read the data to a mIRC variable.[/color]
    var %var
    sockread %var
    [color:green]; Then check its content.
    ; empty variable represents the header ending.[/color]
    if %var == $null { sockmark excel 1 }
  }
  else {
    sockread &var
    bwrite file.xls -1 &var
  }
}
On *:sockclose:excel:{
  [color:green]; Now that the server closed the connection
  ; the file is ready for use.[/color]
  run file.xls
}

Reference #1
Posted By: crashy Re: read excel with socket? - 12/01/03 12:27 PM
thanks........

at least that stops me from losing my web page when someone requests a quote. such a pity i cant just read lines as they come in. perhaps there is a csv converter out there?

cheers
Posted By: Online Re: read excel with socket? - 12/01/03 01:25 PM
I don't know what csv convertor is, but maybe this page contains what you're looking for.

Anyway, what do you mean by 'as they come in'? come from where? from the internet? well, it's possible to perform real-time commands on received information, but it's useless when you treat xls documents, as only excel knows how to open them.
© mIRC Discussion Forums