 
                
                17 posts
                
             
            
                Posted 30 July 2012 - 11:44 AM
                hmmm, after solving my XML problem I hit another snag :ph34r:/>/>
I enabled API_http in the config files for CC, so that isnt the problem
I have:
local UpdateURL = getConfigParam("UpdateURL")
writeBanner(UpdateURL)
sleep(5)
if UpdateURL ~= nil then
local OScode = http.get("http://google.com/")
write(OScode) -- my write to screen function
if OSCode ~= nil then
f = fs.open("osp","w")
local OSLines = textutils.unserialize(OSCode)
for x = 0, #OSLines do
f.writeLine(OSLines[x])
end
f.close()
end
end
And the output is:
table: 62101a6c
Any ideas?
Thanks
Tom
 
         
        
        
            
            
                
                     
                
                1604 posts
                
             
            
                Posted 30 July 2012 - 02:54 PM
                The http functions return a file handle, wich you use to read the content returned like you do with a file.
Example:
local content = http.get("some_url")
print(content.readAll()) -- read and print the content
content.close() -- not sure if it's needed, but just in case
 
         
        
        
            
            
                
                     
                
                17 posts
                
             
            
                Posted 30 July 2012 - 05:36 PM
                Ahhh :)/>/> that makes sense thanks
Maybe that should be in the wiki? It isn't explained :ph34r:/>/>
                
             
         
        
        
            
            
                
                     
                
                109 posts
                
             
            
                Posted 30 July 2012 - 06:18 PM
                I failed
EDIT: I need to spend a bit more time studying what I'm looking at. I just derped HARD.
                
             
         
        
        
            
            
                
                     
                
                8543 posts
                
             
            
                Posted 30 July 2012 - 06:40 PM
                Ahhh :)/>/> that makes sense thanks
Maybe that should be in the wiki? It isn't explained :ph34r:/>/>
I'll update the wiki tonight if it hasn't already been.
MysticT, I assume from the code you posted that the file handle returned is equivalent to what you'd get from fs.open() rather than io.open(). Is that correct, or should I test tonight to confirm?
 
         
        
        
            
            
                
                     
                
                1604 posts
                
             
            
                Posted 30 July 2012 - 07:27 PM
                MysticT, I assume from the code you posted that the file handle returned is equivalent to what you'd get from fs.open() rather than io.open(). Is that correct, or should I test tonight to confirm?
Yes, that's right. The handle returned (that is actually a table) has the same functions as one obtained from opening a file in read mode (fs.open("path", "r")) wich are:
handle.readLine()
handle.readAll()
handle.close()
Also, the io api is defined in lua (inside rom/apis), and io.open it just wraps a file handle returned by fs.open.
 
         
        
        
            
            
                
                     
                
                8543 posts
                
             
            
                Posted 31 July 2012 - 01:04 AM
                MysticT, I assume from the code you posted that the file handle returned is equivalent to what you'd get from fs.open() rather than io.open(). Is that correct, or should I test tonight to confirm?
Yes, that's right. The handle returned (that is actually a table) has the same functions as one obtained from opening a file in read mode (fs.open("path", "r")) wich are:
handle.readLine()
handle.readAll()
handle.close()
Also, the io api is defined in lua (inside rom/apis), and io.open it just wraps a file handle returned by fs.open.
I'm quite aware of the distinction between the two, and the nature of each. ;-) Thanks for the clarification, though!