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 category in the Web Projects Control Panel is selected, the New button will prompt you to create a new Node Service, Node Module, or Node API. If you create a new Node Service, Alpha Anywhere will create a new stub Node service that serves as a helpful starting point for defining a new service.
Select the Node category in the Web Projects Control Panel.
Click the New button in the Web Projects Control Panel toolbar.
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