Rad line by line from url

Just starting out? Need help? Post your questions and find answers here.
PowerSoft
User
User
Posts: 65
Joined: Sun Aug 16, 2015 2:54 pm

Rad line by line from url

Post 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
  
  
OS X 10.10.5 PB 5.31(x64)
User avatar
Kiffi
Addict
Addict
Posts: 1503
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Rad line by line from url

Post 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
Hygge
Post Reply