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

Can I call SB procedure from WebGadget document?

by ehbarba Tue Jun 12, 2018 10:50 pm

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: 24
Joined: Thu Mar 29, 2018 2:20 am

Re: Can I call SB procedure from WebGadget document?

by ehbarba Thu Jun 14, 2018 4:49 am

Sorry, it's very obvious:

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

Best Regards

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

Re: Can I call SB procedure from WebGadget document?

by falsam Thu Jun 14, 2018 2:23 pm

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 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

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

Re: Can I call SB procedure from WebGadget document?

by falsam Thu Jun 14, 2018 3:13 pm

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 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

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

Re: Can I call SB procedure from WebGadget document?

by ehbarba Fri Jun 15, 2018 10:52 pm

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
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 2 guests