LibraryMaker.exe?
LibraryMaker.exe?
Hello,
does anyone know what the LibraryMaker.exe in the SDK folder is good for?
@Fred?
Greetings ... Peter
does anyone know what the LibraryMaker.exe in the SDK folder is good for?
@Fred?
Greetings ... Peter
Re: LibraryMaker.exe?
Hi,
I would say, it is the same as in PB, a tool for building own library files.
If you have a look at the files in the "libraries" directory you see, that this files have a "header" where the SB functions are defined, like they are shown as a hint in SB footer while typing in a function call, and in the same files "body" there are all the SB functions in JS defined.
If you do a search in the PB forums for "librarymaker" you will find some old postings about.
Greetings, Hoerbie
I would say, it is the same as in PB, a tool for building own library files.
If you have a look at the files in the "libraries" directory you see, that this files have a "header" where the SB functions are defined, like they are shown as a hint in SB footer while typing in a function call, and in the same files "body" there are all the SB functions in JS defined.
If you do a search in the PB forums for "librarymaker" you will find some old postings about.
Greetings, Hoerbie
Re: LibraryMaker.exe?
It seems like the libmaker shipped with the Windows version didn't worked correctly. It should be OK for the nex version. In the meantime, you can download this package which contains the new LibMaker and 2 examples to build lib:
https://www.spiderbasic.com/download/Examples.zip
Be sure to create your lib in the SpiderBasic/Libraries folder (and not in UserLibraries as it doesn't seem to work for now). You can use the GUI or the commandline
Here is the 'Easy' example for reference:
Easy.desc
Easy.js
Easy.sb
https://www.spiderbasic.com/download/Examples.zip
Be sure to create your lib in the SpiderBasic/Libraries folder (and not in UserLibraries as it doesn't seem to work for now). You can use the GUI or the commandline
Here is the 'Easy' example for reference:
Easy.desc
Code: Select all
; For SpiderBasic, always C
C
; Number of cordova plugins to use
;
0
; For SpiderBasic, always LIB
;
LIB
; SpiderBasic libraries needed by the library
;
0
; Help directory name
;
Easy
; Library functions (FunctionName, Arg1, Arg2, ...)
;
; Fonction without any argument which returns a string
;
Easy42 () - Returns the number 42
Long
; Function without any argument which returns a double
;
EasyPI () - Returns the number PI
Double
; Function without any argument which returns a string
;
EasyString () - Returns the string "Hello World"
String
; Function with 1 argument which returns string
;
EasyConcatString, String, (Text$) - Returns the string "Hello " + Text$
String
; Function with 2 arguments which returns the sum of 2 integer parameters
;
EasyAdd, Long, Long, (Number1, Number2) - Returns the sum of the 2 numbers
Long
; Function without argument which increase a persistent value
;
EasyIncrease () - Returns the current increased value
Long
; Function with 3 optional parameters
;
EasyAddOptional, Long, [Long], [Long, Long], (Number1 [Number2, [Number3, Number4]) - Returns the sum of the specified numbers
Long
; Function without argument which increase a persistent value
;
EasyFillArray, Array, (Array()) - Fill the array with random numbers
None
Code: Select all
/*
* 'Easy' library code
*
* Self explanatory example to build a new user library for SpiderBasic
*
* Library rules:
* - All SpiderBasic function needs to be prefixed by 'spider_'
* - If you need private variables for your library, you can use a scope: spider.yourlibraryname
* - If a function returns a number, 'null' or 'undefined' return is not allowed. The function must always return a number even for it's default case
* - If a function returns a string, 'null' or 'undefined' return is not allowed. The function must always return a string even for it's default case
* - A function parameter is always strongly typed according to the type set in the .desc file. It can never be 'null', 'undefined' etc.
*
* To compiler the lib (Windows):
* "%SPIDERBASIC_HOME%/SDK/LibraryMaker/LibraryMaker.exe" /NOLOG /TO %SPIDERBASIC_HOME%/Libraries/
*/
/* Our private scope where we can define objects which will be shared between the function lib
*/
spider.easy = {
currentEasyNumer: 0,
};
function spider_Easy42()
{
return 42;
}
function spider_EasyPI()
{
return Math.PI;
}
function spider_EasyString()
{
return "Hello world";
}
function spider_EasyConcatString(text)
{
if (text != "") // Only great if we pass a none empty string
{
return "Hello " + text + " !";
}
return "";
}
function spider_EasyAdd(number1, number2)
{
return number1 + number2; // number1 and number2 are granted to be numbers, never 'undefined', 'null', 'bool' or 'string' etc.
}
function spider_EasyIncrease()
{
spider.easy.currentEasyNumer++; // Use private object for persistant value
return spider.easy.currentEasyNumer;
}
function spider_EasyAddOptional(number1, number2, number3, number4)
{
if (typeof number2 === "undefined") number2 = 0; // optional parameter
if (typeof number3 === "undefined") number3 = 0; // optional parameter
if (typeof number4 === "undefined") number4 = 0; // optional parameter
return number1 + number2 + number3 + number4;
}
//
// Array object:
// array.array: javascript array containing the data
// array.type: type of the array (#PB_Long, #PB_String, #PB_Double)
// array.nbDimensions = nb of dimension in the array
// array.dimensions: array of array for each dimension
// array.structure: associated structure (if any)
//
function spider_EasyFillArray(array)
{
if (array.nbDimensions == 1) // Only support array with one dimension
{
var array;
for (var i = 0 ; i < array.array.length; i++)
{
array.array[i] = (Math.random() * 100) | 0; // generate an integer number between 0 and 100
}
}
}
Code: Select all
Debug Easy42()
Debug EasyPI()
Debug EasyString()
Debug EasyConcatString("Timo")
Debug EasyAdd(2, 20)
Debug "Increase internal value 3 times:"
Debug EasyIncrease()
Debug EasyIncrease()
Debug EasyIncrease()
Debug "Display randomized array:"
Dim Numbers(3)
EasyFillArray(Numbers())
For i = 0 To 3
Debug Numbers(i)
Next
Debug "EasyAddOptional: " + EasyAddOptional(1)
Debug "EasyAddOptional: " + EasyAddOptional(1, 2)
Debug "EasyAddOptional: " + EasyAddOptional(1, 2, 3, 4)
Re: LibraryMaker.exe?
Great!
It finally allows us to seamlessly integrate new libraries.
Thanks a lot, Fred! .... Peter
It finally allows us to seamlessly integrate new libraries.
Thanks a lot, Fred! .... Peter
Re: LibraryMaker.exe?
Please note than your still need to build your lib for the 3 OS (one Windows compiled lib can't be used on OS X and vice-versa)
Re: LibraryMaker.exe?
Could you make the lib format platform-independent?Fred wrote:Please note than your still need to build your lib for the 3 OS (one Windows compiled lib can't be used on OS X and vice-versa)
If it's only JavaScript, it would be nice to use the libs on all platforms (create on macOS, use on Windows).
cya,
...Danilo
...Danilo
Re: LibraryMaker.exe?
For now all the code is shared with PureBasic, that's why it's plateform dependant. I will try to change that
-
- Posts: 220
- Joined: Sat Mar 01, 2014 3:02 pm
Re: LibraryMaker.exe?
This is cool
Any chance it will be cross platform when the latest release comes out of beta?Fred wrote:For now all the code is shared with PureBasic, that's why it's plateform dependant. I will try to change that
Re: LibraryMaker.exe?
that's good news. Then I will wait a while before releasing my libraries.Fred wrote:I will try to change that
Thanks and Greetings ... Peter