Can I call SB procedure from WebGadget document?

Just starting out? Need help? Post your questions and find answers here.
ehbarba
Posts: 31
Joined: Thu Mar 29, 2018 2:20 am

Can I call SB procedure from WebGadget document?

Post by ehbarba »

Hello Spiders

I need to know how can I call an SB procedure from an html document loaded in a WebGadget like this:

On SB program:

Procedure TestProcedure(s$)
Debug s$ +" Ok!"
EndProcedure

On page loaded in WebGadget:

...
<span class="xxx" onclick="...???...f_testprocedure('test');">
...

Thanks a lot for all your help. You are a great team!!!

Best regards

Ezequiel
ehbarba
Posts: 31
Joined: Thu Mar 29, 2018 2:20 am

Re: Can I call SB procedure from WebGadget document?

Post by ehbarba »

Sorry, it's very obvious:

<span class="xxx" onclick="window.parent.f_testprocedure('test');">

Best Regards

Ezequiel
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

Re: Can I call SB procedure from WebGadget document?

Post by falsam »

A test without webgadget because I think it's useless ;)

A simple example without CCS

■ HTML Code (This is an example : mainform.html)

Code: Select all

<h1>Call SpiderBasic procedure</h1>

<!-- your button -->
<p><button onclick="window.parent.f_dummy('test');" >Click Me</button></p>
No <html> <header> <body>

SpiderBasic code

Code: Select all

; Remove spiderbasic body style
!	$("body").removeClass("flat");
!	$('*').css('background', 'transparent');	

; Include your html file
!$("body").load("mainform.html");

Declare Dummy(Value.s)
Declare onClose()

;, Show value
; This procedure is called when you click on the button defined in the HTML page
Procedure Dummy(Value.s)
  OpenWindow(#PB_Any, 0, 0, 300, 50, "Information", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  TextGadget(#PB_Any, 10, 10, 280, 24, "Value : " + Value)
  
  BindEvent(#PB_Event_CloseWindow, @onClose() ) 
EndProcedure

Procedure onClose()
  CloseWindow( EventWindow() )
EndProcedure
■ Demo : http://falsam.com/sbtest/callsbprocedure.html

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

Re: Can I call SB procedure from WebGadget document?

Post by falsam »

ehbarba wrote:I need to know how can I call an SB procedure from an html document loaded in a WebGadget
Sorry. I'll still answer your question with the Webgadget. It's true I don't know your project. :oops:

html code is the same as my previous example

■ Code SpiderBasic

Code: Select all

Declare Start()
Declare Dummy(Value.s)
Declare onClose()

Start()

Procedure Start()
  OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_Background)
  WebGadget(0, 20, 20, 800, 600, "mainform.html")
EndProcedure

;Show value
; This procedure is called when you click on the button defined in the HTML page
Procedure Dummy(Value.s)
  OpenWindow(#PB_Any, 0, 0, 300, 50, "Information", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  TextGadget(#PB_Any, 10, 10, 280, 24, "Value : " + Value)
  
  BindEvent(#PB_Event_CloseWindow, @onClose() ) 
EndProcedure

Procedure onClose()
  CloseWindow( EventWindow() )
EndProcedure
■ Démo http://falsam.com/sbtest/callsbprocfromwebgadget.html

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english
ehbarba
Posts: 31
Joined: Thu Mar 29, 2018 2:20 am

Re: Can I call SB procedure from WebGadget document?

Post by ehbarba »

Thank you very much Falsam.

Your samples are great and the point is fully well explained. I am using it in my project.

Best regards

Ezequiel
Post Reply