This is happening to me again. Under slightly different circumstances.
I'm loading an rss feed using the http functions.
When I run the code on my windows system, it runs fine.
When I run it on Android it messes up.
Here is the situation:
I use two different sources (URLs) that I get the rss from.
Both seem to work just fine, but when I run a routine to pull out what I want from the rss feed, on Windows I can pull out the data I need. But when run on Android, the file is full of HTML instead of XML and the HTML has no usable data.
The only difference is that I used two different sources for the data.
But both sources work just fine in Windows but don't work on Android.
Also, this seems similar (yet different) to a problem I had from the difference between Windows and Android in filename use. Windows doesn't care if you use a capital or not and Android does.
I am not cross mixing the name of the file so I know that is not the problem. And I am consistent in my use of the variables.
I don't understand why switching sources works on Windows but gives me HTML from who knows where on Android?
Please help! I'm open to any suggestions on where to start looking
Please forgive the messiness. I pulled it out of the code for my app and did not clean up the changes I had to make to get it to run standalone.
I invite you to run the code on your Windows system then broadcast it to your Android and see if you get the same problem. I've used several Android systems and have the problem on all of them.
There are two things to look for. One is the "newsHeadlinesCounter" that is displayed on the screen upon execution.
If you run this on Windows, changing the "httpHost$ and "httpFile$" by commenting and un-commenting that section of the code, you will see that in Windows the counter progresses using either httpHost$.
However in Android, if you use "ABCNews" as the httpHost$, you get HTML (which has no data and does not advance the counter) and I have no clue where the HTML is coming from.
The other thing to look at is the actual print to the screen of the file contents as it reads it. In Windows you can see when the counter advances it has hit some XML it likes. In Android, if you look at what is printing out, it is not XML at all but HTML from somewhere.
I'm sure that I'm doing something wrong. I would just like for someone to point that out to me! Thanks for any help!!!!
Here is my code:
// Project: testRSSJunk
// Created: 2015-04-14
// set window properties
SetWindowTitle( "testRSSJunk" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
dim newsLines$[5000]
dim newsHeadLines$[5000]
gosub getTheNews
end
getTheNews:
httpSupplier = 1
httpOutputFile$ = "junk.txt"
deleteFile(httpOutputFile$)
`httpHost$ = "feeds.foxbusiness.com"
`httpFile$ = "/foxbusiness/section/business-leaders/mixed?format=xml"
httpHost$ = "feeds.abcnews.com"
httpFile$ = "/abcnews/thisweekheadlines"
` setprintColor(255,255,255)
deleteFile(httpOutputFile$)
http = CreateHTTPConnection()
SetHTTPHost( http, httpHost$, 0 )
SendHTTPRequestASync( http, httpFile$ )
while GetHTTPResponseReady(http) = 0
Print( "Connecting..." )
Sync()
endwhile
GetHTTPFile( http, httpFile$, httpOutputFile$ )
while GetHTTPFileComplete(http) = 0
Sync()
endwhile
keepItCoolTimer# = timer() + .5
while timer() < keepItCoolTimer#
sync()
endwhile
CloseHTTPConnection(http)
DeleteHTTPConnection(http)
http = CreateHTTPConnection()
CloseHTTPConnection(http)
DeleteHTTPConnection(http)
for h88 = 1 to 1000
closeFile(h88)
next h88
rem end
keepItCoolTimer# = timer() + .5
while timer() < keepItCoolTimer#
sync()
endwhile
gfe = getFileExists(httpOutPutFile$)
debugTimer# = timer() + 5
while getPointerPressed() = 0
print("click on screen to continue")
print(gfe)
print(httpOutputFile$)
sync()
endwhile
openToRead(1,httpOutputFile$)
openToWrite(2,"new.txt")
while fileEOF(1) = 0
fTemp$ = readLine(1)
writeLine(2,fTemp$)
endwhile
closeFile(2)
closeFile(1)
httpOutputFile$ = "new.txt"
newsLineCount = 0
openToRead(1,httpOutPutFile$)
while FileEOF(1) = 0
inc newsLineCount
newsLines$[newsLineCount] = readLine(1)
endwhile
closeFile(1)
remstart
for h3 = 1 to newsLineCount
print("debugging")
print("h3 = " + str(h3))
print("newsHeadlinesCounter = " + str(newsHeadlinesCounter))
print("newsHeadlines$[newsHeadlinesCounter] = " + newsHeadlines$[newsHeadlinesCounter])
print("newsLines$[h3] = " + newsLines$[h3])
sync()
next h3
remend
` debugTimer# = timer() + 5
setprintColor(255,255,255)
` while timer() < debugTimer#
` for h88 = 1 to newsLinecount
` print(newsLines$[newsLineCount])
` next h88
` sync()
` endwhile
//}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}[]
//httpSupplier
maxNewsLines = newsLineCount
newsHeadLinesCounter = 0
for h3 = 1 to maxNewsLines
temp9$ = GetStringToken(newsLines$[h3],"<>",2)
if temp9$ = "title"
inc newsHeadlinesCounter
newsHeadlines$[newsHeadlinesCounter] = newsLines$[h3]
if httpSupplier = 1 or httpSupplier > 9
temp2$ = GetStringToken(newsheadlines$[newsHeadlinesCounter],"[]",3)
else
temp2$ = GetStringToken(newsheadlines$[newsHeadlinesCounter],"><",3)
endif
newsHeadlines$[newsHeadlinesCounter] = temp2$
endif
` keepMoving = 0
` while keepMoving = 0
if getPointerPressed() then keepMoving = 1
if getRawKeyPressed(27) then end
print("h3 = " + str(h3))
print("newsHeadlinesCounter = " + str(newsHeadlinesCounter))
print("newsHeadlines$[newsHeadlinesCounter] = " + newsHeadlines$[newsHeadlinesCounter])
print("newsLines$[h3] = " + newsLines$[h3])
sync()
` endwhile
next h3
while getPointerPressed() = 0
print("END - click on screen to exit")
sync()
endwhile
return