SpiderBasic 3.30 beta 1 is out !
Posted: Mon May 25, 2026 12:21 pm
Hi folks,
Here is the new 3.30 beta version of SpiderBasic introducing a nice new feature we wanted to implement since a while: async/await support. What does it means for you ? Less callbacks ! The commands can finally wait for there execution to finish and you can code in a more linear fashion.
For example, using the OpenFileRequester() to display a local image was looking like that:
Now, the same code using async under the loop makes the code easier to follow and more PureBasic-like
This is early work on this and if it works well it be done for the whole commandset. I tested on cordova and it works as expected, but feel free to test and see if it is OK.
The modified affected commands which now uses await:
That means that these commands doesn't need a callback anymore and will returns the result directly when the processing is done, actually blocking the program flow.
Here is the change list for this version:
Have fun !
The Fantaisie Software team
Here is the new 3.30 beta version of SpiderBasic introducing a nice new feature we wanted to implement since a while: async/await support. What does it means for you ? Less callbacks ! The commands can finally wait for there execution to finish and you can code in a more linear fashion.
For example, using the OpenFileRequester() to display a local image was looking like that:
Code: Select all
Procedure Loaded(Type, Filename$, ObjectId)
Static x = 200, y = 200
OpenWindow(#PB_Any, x, y, 300, 300, Filename$, #PB_Window_TitleBar | #PB_Window_SizeGadget)
ImageGadget(#PB_Any, 0, 0, ImageWidth(ObjectId), ImageHeight(ObjectId), ImageID(ObjectId))
; Shift the next opened window
;
x + 40
y + 40
EndProcedure
Procedure LoadingError(Type, Filename$)
Debug Filename$ + ": loading error"
EndProcedure
Procedure RequesterSuccess()
; Process all the selected filename
;
While NextSelectedFile()
LoadImage(#PB_Any, SelectedFileID(), #PB_LocalFile) ; when using #PB_LocalFile, all files selected with OpenFileRequester() are directly available
Filename$ = SelectedFileName()
Wend
EndProcedure
Procedure ButtonEvent()
OpenFileRequester("image/*", @RequesterSuccess(), #PB_Requester_MultiSelection)
EndProcedure
OpenWindow(0, 100, 100, 200, 45, "Image viewer", #PB_Window_TitleBar)
ButtonGadget(0, 10, 10, 180, 25, "Open local image...")
BindGadgetEvent(0, @ButtonEvent())
; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading, @Loaded())
BindEvent(#PB_Event_LoadingError, @LoadingError())Code: Select all
Procedure ButtonEvent()
x = 200
y = 200
Filename$ = OpenFileRequester("image/*", #PB_Requester_MultiSelection)
; Process all the selected filename
;
While Filename$
Image = LoadImage(#PB_Any, Filename$, #PB_LocalFile) ; when using #PB_LocalFile, all files selected with OpenFileRequester() are directly available
If Image
OpenWindow(#PB_Any, x, y, 300, 300, Filename$, #PB_Window_TitleBar | #PB_Window_SizeGadget)
ImageGadget(#PB_Any, 0, 0, ImageWidth(Image), ImageHeight(Image), ImageID(Image))
; Shift the next opened window
;
x + 40
y + 40
EndIf
Filename$ = NextSelectedFilename()
Wend
EndProcedure
OpenWindow(0, 100, 100, 200, 45, "Image viewer", #PB_Window_TitleBar)
ButtonGadget(0, 10, 10, 180, 25, "Open local images...")
BindGadgetEvent(0, @ButtonEvent())The modified affected commands which now uses await:
Code: Select all
CaptureImage()
CloseFile()
CopyFile()
CreateDirectory()
DeleteDirectory()
DeleteFile()
ExamineDirectory()
FetchData()
FileSize()
GetFileAttributes()
GetFileDate()
HTTPRequest()
LoadImage()
LoadJSON()
LoadScript()
LoadSound()
LoadSprite()
LoadXML()
OpenFileRequester()
ReadFile()
RequestFileSystem()
SetCurrentDirectory()Here is the change list for this version:
Code: Select all
- Added: async/await support for most of the commands, callbacks are now optionals and program flow easier to follow !
- Added: FileSystem library to easily act on local files (iOS, Android only)
- Added: Preference library using local storage based on Peter's work (Thanks ! https://github.com/spiderbytes/Preferences)
- Added: CaptureImage() to get an image from the camera (iOS, Android only)
- Added: CreatePasswordHash() and VerifyPasswordHash() based on bcrypt
- Optimized: Splitted the system library to not have all cordova libs included when using a single command
- Optimized: Android app creation should be much faster on Windows
- Changed: NextSelectedFile() to NextSelectedFileName()
- Removed SelectedFileName() and SelectedFileID()The Fantaisie Software team