does anyone know what the LibraryMaker.exe in the SDK folder is good for?

@Fred?
Greetings ... Peter

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
NoneCode: 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)
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)
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
that's good news.Fred wrote:I will try to change that
Then I will wait a while before releasing my libraries.