Page 1 of 1

Rad line by line from url

Posted: Thu Jun 15, 2017 10:36 am
by PowerSoft
I have this code thats read the entire file at once.
Is is posible to read the contence of the file line by line from the URL?
Thanks for any help

Code: Select all

;--------------------------------------------------------------------------
;
; Get the contence of the stations.txt from NORAD over the Internet
;
; Data is stored into Filename$
;
; Version 5 jun 2017
;
; This is an example
;
;--------------------------------------------------------------------------
InitNetwork()

Filename$ = GetHomeDirectory() + "Documents/stations.txt"

If ReceiveHTTPFile("http://www.celestrak.com/NORAD/elements/stations.txt", Filename$)
    Debug "Success"
Else
    Debug "Failed"
  EndIf
  
  

Re: Rad line by line from url

Posted: Thu Jun 15, 2017 7:02 pm
by Kiffi
Is is posible to read the contence of the file line by line from the URL?
no it's not possible. But after the download you can read the txt-file line by line:

Code: Select all

;--------------------------------------------------------------------------
;
; Get the contence of the stations.txt from NORAD over the Internet
;
; Data is stored into Filename$
;
; Version 5 jun 2017
;
; This is an example
;
;--------------------------------------------------------------------------

EnableExplicit

InitNetwork()

Define Filename$
Define Line$
Define FF

Filename$ = GetHomeDirectory() + "Documents/stations.txt"

If ReceiveHTTPFile("http://www.celestrak.com/NORAD/elements/stations.txt", Filename$)
  
  FF = ReadFile(#PB_Any, Filename$)
  
  If FF
    
    While Not Eof(FF)
      Line$ = ReadString(FF)
      Debug Line$
    Wend
    
    CloseFile(FF)
    
  Else
    Debug "ReadFile() failed"
  EndIf
    
  
Else
  Debug "Failed"
EndIf
Greetings ... Peter