Understanding SpiderBasic

Everything else that doesn't fall into one of the other categories.
User avatar
J. Baker
Posts: 27
Joined: Tue Dec 23, 2014 11:58 pm
Location: USA
Contact:

Understanding SpiderBasic

Post by J. Baker »

I'm not fully understanding SpiderBasic's coding method. I've opened the "Screen.sb" example. I see after the OpenScreen(), the Procedures are written but never called upon as in PureBasic. Then sprites are either loaded or created. How can a sprite be loaded at the bottom of the code but it's already being used in a procedure above? This only concerns me as I'm use to writing events as they happen in order.
www.posemotion.com

Mac: OS X 10.13.6 / 1.4GHz Intel Core 2 Duo / 2GB 1067MHz DDR3 / Nvidia 320M

PC: Win XP & Win 7 / AMD Athlon 64 4000+ / 3GB 333MHz DDR / Nvidia 720GT
the.weavster
Posts: 220
Joined: Sat Mar 01, 2014 3:02 pm

Re: Understanding SpiderBasic

Post by the.weavster »

The procedures are bound to events as callbacks (line 111).

Code: Select all

; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading, @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())
BindEvent(#PB_Event_RenderFrame, @RenderFrame())
So if, for example, LoadSprite() failed LoadingError() would be called.
User avatar
J. Baker
Posts: 27
Joined: Tue Dec 23, 2014 11:58 pm
Location: USA
Contact:

Re: Understanding SpiderBasic

Post by J. Baker »

Sorry but maybe I didn't explain topic very well. I see the loading event but even this event is called before the actual loaded or created sprite? I guess I would have preferred for SpiderBasic's syntax to be a little more like PureBasic. Then again, I guess Fred possibly had to write it this way in order for it to be converted for the web.
www.posemotion.com

Mac: OS X 10.13.6 / 1.4GHz Intel Core 2 Duo / 2GB 1067MHz DDR3 / Nvidia 320M

PC: Win XP & Win 7 / AMD Athlon 64 4000+ / 3GB 333MHz DDR / Nvidia 720GT
the.weavster
Posts: 220
Joined: Sat Mar 01, 2014 3:02 pm

Re: Understanding SpiderBasic

Post by the.weavster »

J. Baker wrote:Sorry but maybe I didn't explain topic very well. I see the loading event but even this event is called before the actual loaded or created sprite?
No, it's bound before LoadSprite() but it's not called unless/until the specified event actually occurs. If you didn't bind the callback to the event until after calling LoadSprite() you'd miss the event being fired.

J. Baker wrote:I guess I would have preferred for SpiderBasic's syntax to be a little more like PureBasic.
This methodology is available in PureBasic.
the.weavster
Posts: 220
Joined: Sat Mar 01, 2014 3:02 pm

Re: Understanding SpiderBasic

Post by the.weavster »

Ive just updated my "Hello World" to take into account some new events that have appeared in SpiderBasic.

You should be able to run this code with SpiderBasic and PureBasic without needing any changes.
IdeasVacuum
Posts: 143
Joined: Tue Feb 25, 2014 1:27 pm

Re: Understanding SpiderBasic

Post by IdeasVacuum »

I don't understand the purpose of Spider Basic. The intro in the help basically describes Spider Basic as a rival to Pure Basic.......

So, it would be nice if Fred could take the time to say exactly what Spider Basic is for, what it is intended to do etc.
the.weavster
Posts: 220
Joined: Sat Mar 01, 2014 3:02 pm

Re: Understanding SpiderBasic

Post by the.weavster »

IdeasVacuum wrote:I don't understand the purpose of Spider Basic. The intro in the help basically describes Spider Basic as a rival to Pure Basic.......
PureBasic can be compiled for Linux, Windows and OSX running on an x86 processor. SpiderBasic runs in a browser which will take it to many more platforms.

But even if you're only interested in x86 desktops there are still scenarios where SpiderBasic has advantages, let's say you've written a program that's going to be used by twenty employees in the company you work for and that program connects to an ODBC database, with PureBasic you've got twenty installs to do and twenty DSNs to set up, when you update your program you've again got twenty workstations to update. Now consider SpiderBasic in this scenario, you've only got one install to do, one DSN to set up and only one computer to apply updates to, the twenty workstations just need a bookmark.

I also guess the time will come when SpiderBasic can be used with Apache Cordova to create apps for Android, iOS, Tizen, BB10 and Windows Phone.
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: Understanding SpiderBasic

Post by Fred »

Yes, it's not a rival to PB, but more a complement to it. Depending of what your app needs, using SB could be the right choice to have it working on any device having a (modern) browser
fsw
Posts: 6
Joined: Wed Aug 20, 2014 11:48 pm

Re: Understanding SpiderBasic

Post by fsw »

the.weavster wrote:But even if you're only interested in x86 desktops there are still scenarios where SpiderBasic has advantages, let's say you've written a program that's going to be used by twenty employees in the company you work for and that program connects to an ODBC database, with PureBasic you've got twenty installs to do and twenty DSNs to set up, when you update your program you've again got twenty workstations to update. Now consider SpiderBasic in this scenario, you've only got one install to do, one DSN to set up and only one computer to apply updates to, the twenty workstations just need a bookmark.
Normally a company with 20 employees has a server.
The database program resides on the server and is accessed by 20 employees through a shortcut on their desktop.
No need to install it on each employee's workstation.

The DNS setup still needs to be done though...
Post Reply