Node services can be called from Node modules, other Node services and Xbasic scripts.
Node services can be created and managed from within Alpha Anywhere. The Node services category in the Web Projects Control Panel will filter the project to display node services in the project. A Node service can be created using the New toolbar button. Node services can also be added from the Node menu in the More... options on the Web Projects Control Panel toolbar.
When the Node Services item has focus, the New button will create a new stub Node service that serves as a helpful starting point for defining a new service.
Click the New button in the Web Projects Control Panel toolbar.
If prompted, select Node Service from the New File dialog.Alpha Anywhere will automatically create a new Node Service, skipping the New File dialog, if the Node Services category is selected in the Web Projects Control Panel.
In the Create Node Service Stub dialog, enter a Service name. Optionally check (or uncheck) the Open service definition .js file after creating it? checkbox. Click OK.
Alpha Anywhere will generate a Node Service stub. The stub includes comments that describe how to call the Node Service from Xbasic.
Create your Node service. Save your changes.
Once you have defined your Node service, you can call it from your Xbasic code using the node_request_result() function.
For example, say you have define a service called multiply and that this service takes as input x and y. Here is how you could call the service from Xbasic:
dim pIn as p pIn.x = 4 pIn.y = 3 dim pOut as p pOut = node_request_result("multiply",pIn) ? pOut.error = "" 'empty string indicates no errors. ?pOut.result = 12