Page 1 of 1

Load text, and put into EditorGadget

Posted: Wed Jul 13, 2016 12:07 pm
by jamirokwai
Hi there,

had some headaches fiddling with loading of text, and applying it to an EditorGadget.
I am posting this for further reference :-)

Code: Select all

Procedure ApplyDemoSnippet ( gadget, content )
  If IsGadget ( gadget ) : SetGadgetText ( gadget, content ) : EndIf
EndProcedure

Procedure LoadTextIntoEditorGadget ()
  ! jQuery.get('data/test.txt', function(data) {
  !   f_applydemosnippet ( 1, data );
  ! }, 'text');
EndProcedure
ApplyDemoSnippet ( 0, "" )

This one needs an EditorGadget number 1.

Cheers
J.

Re: Load text, and put into EditorGadget

Posted: Fri Jul 22, 2016 12:24 am
by Peter
Hello jamirokwai,

using HTTPRequest() prevents headaches ;-)

Code: Select all

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

HTTPRequest(#PB_HTTP_Get, "data/test.txt", "", @HttpGetEvent(), 1)
Greetings ... Peter