Cheers blink0k
Knew I was doing something wrong with the Type just could not figure out how to put one inside other.
The site also gives the times for your location that the ISS is overhead and who is in it at the moment, Will now be able to incorporate that. Have only ever seen it once before.
Eventually might make a shoot em up where you have to defend the ISS using real data.
But at the moment just making an Info APP. Might even make a tutorial for STEAM.
Anyway Here is the full working code as It might help someone else.
// Project: ISS
// Created: 2020-02-29
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "ISS" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
`ISS Location
`Use open-notify.org to Get Json File with Location
http = CreateHTTPConnection()
SetHTTPHost( http, "api.open-notify.org", 0 )
GetHTTPFile( http, "/iss-now.json", "IssLocation.json" )
while GetHTTPFileComplete(http) = 0
Print( "Downloading: " + str(GetHTTPFileProgress(http)) )
Sync()
endwhile
CloseHTTPConnection(http)
DeleteHTTPConnection(http)
`Open the Downloaded File and Coppy it to a string
file = OpenToRead("IssLocation.json")
JsonLocationString as string
JsonLocationString= ReadString(file)
CloseFile(file)
`Create a user type to hold the contents of the Json File
type iss_position
latitude as float
longitude as float
endtype
type gps_data
iss_position as iss_position
timestamp as integer
_message as string
endtype
gps as gps_data
`ISS as iss_positions
gps.fromJSON( JsonLocationString )
`Convert Unix Time to Real Time Format
Year$ = Str(GetYearFromUnix( gps.timestamp ))
Month$ = Str(GetMonthFromUnix( gps.timestamp ))
Day$ = Str(GetDaysFromUnix( gps.timestamp ))
Min$ = Str(GetMinutesFromUnix( gps.timestamp ))
Hour$ = Str(GetHoursFromUnix( gps.timestamp ))
`Print the Results
do
Print( "Iss Location")
Print( "Message : " + gps._message )
Print( "longitude : " + Str(gps.iss_position.longitude) )
Print( "latitude : " + Str(gps.iss_position.latitude) )
Print( "Unix Time Stamp : " + Str(gps.timestamp) )
Print( "Date " + day$ + "/" + Month$ + "/" + Year$)
Print( "Time " + Hour$ + ":" + Min$ )
Print( "The JSon File" )
Print( JsonLocationString)
Sync()
loop