I tried the following code to integrate JS functions inside SpiderBasic and it produces some errors (you can find the generated JS code as comments inside the source):
Workaround for the variable names: Use only lower case variable names for this kind of using.; Begin-----------------------------------------------------------------
; Function JSTest1----------------------------------------------------
Procedure.s JSTest1(Text.s)
Protected res.s
!v_res = window.btoa(v_Text);
ProcedureReturn res
EndProcedure
;function proc0(v_text) { //convert variable name to lower case
;var v_res="";
;v_res = window.btoa(v_Text);
;return v_res;
;return ""; //unreachable code
;}
; Function JSTest2----------------------------------------------------
Procedure JSTest2()
EnableJS
Return 42;
DisableJS
EndProcedure
;function proc2() {
;Return 42; //syntax error
;return 0; //unreachable code
;}
; Main----------------------------------------------------------------
Debug JSTest1("Stefan")
Debug JSTest2()
; End-------------------------------------------------------------------
Suggestion for a future release of SpiderBasic: Don't convert variable names.
Suggestion for the EnableJS block: Disable automatic code correction (and syntax highlighting) in SpiderBasic IDE inside a EnableJS...DisableJS block.
Suggestion: Remove unreachable code automatically after the first return - not necessary but nice.
Cheers
Stefan