mIRC Home    About    Download    Register    News    Help

Print Thread
#6210 12/01/03 07:58 AM
Joined: Jan 2003
Posts: 9
C
crashy Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Jan 2003
Posts: 9
Can you read data from a spreadsheet on a website using a socket?

If so, how?

#6211 12/01/03 09:04 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
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

#6212 12/01/03 12:27 PM
Joined: Jan 2003
Posts: 9
C
crashy Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Jan 2003
Posts: 9
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

#6213 12/01/03 01:25 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
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.


Link Copied to Clipboard