httprequest example (or how to get data out of a callback)

Just starting out? Need help? Post your questions and find answers here.
Poltergeist
Posts: 5
Joined: Fri Feb 06, 2015 10:14 am

httprequest example (or how to get data out of a callback)

Post by Poltergeist »

This is probably going to be very newby like, but I just cannot figure it out: I'm trying to use the httprequest example

Code: Select all

Procedure HttpGetEvent(Success, Result$, UserData)
  If Success
    Debug Result$
  Else
    Debug "HTTPRequest(): Error"
  EndIf
EndProcedure

; Get the content of this file, and display it in the debug window
;
HTTPRequest(#PB_HTTP_Get, #PB_Compiler_Filename, "", @HttpGetEvent())

If want to use result$ after the httprequest. I can see that result$ has a value (the corrrect value) but I cannot get it exported somehow out of the procedure. A

Code: Select all

ProcedureReturn result$
does not have any effect...

It should be possible, but how?
IdeasVacuum
Posts: 143
Joined: Tue Feb 25, 2014 1:27 pm

Re: httprequest example (or how to get data out of a callbac

Post by IdeasVacuum »

Once the code is converted to js, Result$ and result$ are different variables because js is case-sensitive.
Poltergeist
Posts: 5
Joined: Fri Feb 06, 2015 10:14 am

Re: httprequest example (or how to get data out of a callbac

Post by Poltergeist »

I doubt that is an issue to be honest. If I change debug Result$ into debug result$ it still gives the correct output.

I've now used code in the callbackprocedure to parse the data. Not a pretty solution, but for now it works. If someone knows if I can get the value of Result$ out of the callback procedure, please do tell!
IdeasVacuum
Posts: 143
Joined: Tue Feb 25, 2014 1:27 pm

Re: httprequest example (or how to get data out of a callbac

Post by IdeasVacuum »

Can it be worked-around using a global var?
Post Reply