Page 1 of 1

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

Posted: Fri Feb 06, 2015 2:57 pm
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?

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

Posted: Tue Feb 10, 2015 2:49 pm
by IdeasVacuum
Once the code is converted to js, Result$ and result$ are different variables because js is case-sensitive.

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

Posted: Thu Feb 12, 2015 11:50 am
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!

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

Posted: Sat Feb 14, 2015 2:37 am
by IdeasVacuum
Can it be worked-around using a global var?