To do this, me must first ‘load’ our B4JS classes into our B4J app. They are loaded onto our server.
This code is placed in our Main AppStart() method.
' we are loading our B4JS. In the final parameter, we can even load other .js files: Array as String("myJS1.js", "myJS2.js") ABM.B4JSLoadOnServer(File.DirApp & "/www/js/", Null)
Note 1: we are NOT using a browser on our server side.
Second method: we are calling our own B4JS sub CheckCard:
Dim myB4JClassVar2 As B4JSServerVariable ' Our CheckCard method DOES belong to our B4JSCalculateDistance class, so pass it myB4JClassVar2.Initialize("myVar2", "B4JSCalculateDistance") myB4JClassVar2.B4JSRunMethod("CheckCard", Array As Object(CardNumber))
The result (all in the B4J log of course as we do not have a browser):
' from method 1 Server Card '5105105105105100' is a valid card. Please continue... ' from method 2 Card '5105105105105100' is a valid card. Please continue...<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>
So what happens here? We create a new calculator variable: B4JSServerVariable
This system could have great potential in the future. Why not acting as a mini NodeJS server… But we’ll see!