In this example, a variable named counter is defined and assigned the initial value of 1. An endpoint is also defined that displays the current date/time. The control flow consists of three activities.
An activity statement calls an endpoint that displays the current time.
A cycle statement defines the begining of a loop which will execute while the counter value is less than 10000.
An activity statement increments the value of the counter variable
When the cycle completes, the timer endpoint is called again
%% Test performance of large loops%endpoint:simpletimer=>erl://simpletimer:displaycontext:counter=>1controlflowdo% call the timer endpoint to display the current timeactivity:starttime,:call,simpletimerend% main loopcycle(@counter<10000)doactivity:increment,:manipulatedo@counter+=1endend% call the timer endpoint to display the current timeactivity:endtime,:call,simpletimerendend
Parallel Activities
In this example, three HTTP endpoints are defined. A parallel activity is specified and the ":wait" clause tells the engine to wait until all parallel branches have completed.
Note that the statement show runtime_context causes the values of any context variables to be displayed.
Web Service Example
In this example, a Google currency conversion service is called. The control flow consists of three activities.
First, the query for the URL is constructed by several manipulate activities.
Next, the web service is invoked and the query is passed as parameter. The query results are copied to a variable named "returnValue".
Finally, some processing of the returned values would be performed.
% % Demonstrate currency conversion using a Google service%endpoint:currencyConversion=>http://www.google.com/ig/calculatorcontext:amount=>'100'context:fromCurrencyCode=>'USD'context:toCurrencyCode=>'INR'context:urlQuery=>nilcontext:returnValue=>nilcontrolflowdo%% build the URL query string which should look like% hl=en&q=100USD=?INR%activity:build1,:manipulatedo@urlQuery='hl_en&q='+@amountendactivity:build2,:manipulatedo@urlQuery=@urlQuery+@fromCurrencyCodeendactivity:build3,:manipulatedo@urlQuery=@urlQuery+'=?'endactivity:build3,:manipulatedo@urlQuery=@urlQuery+@toCurrencyCodeend% call the currency conversion serviceactivity:getConversion,:call,currencyConversion,@urlQuerydo|results|@returnValue=resultsend% do something with the currency return resultsend
Note that the statement show runtime_context causes the values of any context variables to be displayed.
Executing an operating system command Example
In this example, the command "ls" is executed to display the contents of a directory. Two examples are shown, one that executes the endpoint with no parameters and the second example with a paramater. If this were running on a Windows-based operating sytem, instead of "ls" you would run "dir". Note that any operating system command including a batch file can be executed.
First, an endpoint named "cmdls" is defined. Note that the endpoint URL has the prefix "cmd://".
Next, two context variables are defined for storing the directory contents. Another context variable is defined to hold a parameter that will be passed.
Next, the endpoint is executed and the results stored in a variable named "contents".
Next, the endpoint is executed with a parameter of "/tmp" and the results stored in a variable named "contents2".
Finally, the value of all context variables is displayed.
%
% Test execution of an operating system command
%
endpoint :cmdls=> cmd://ls
context :contents => "NA"
context :contents2 => "NA"
context :parameter => "/tmp"
controlflow do
% call the cmdls endpoint to display the contents of the current directory % this example uses no parameters but stores the results in a variable named "contents"activity:command,:call,cmdlsdo|results|@contents=resultsend% call the cmdls endpoint to display the contents of the current directory and pass a parameter% this example stores the results in a variable named "contents2"activity:command,:call,cmdls,@parameterdo|results|@contents2=resultsend% display the runtime context variables activity:trace,:manipulatedoshowruntime_contextend
end
Last edit: Bruce Kissinger 2012-11-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The syntax to run a file containing WEE rules is:
Note that these commands must be entered inside the Erlang comand line shell.
Loop Example
In this example, a variable named counter is defined and assigned the initial value of 1. An endpoint is also defined that displays the current date/time. The control flow consists of three activities.
Parallel Activities
In this example, three HTTP endpoints are defined. A parallel activity is specified and the ":wait" clause tells the engine to wait until all parallel branches have completed.
Note that the statement show runtime_context causes the values of any context variables to be displayed.
Web Service Example
In this example, a Google currency conversion service is called. The control flow consists of three activities.
Note that the statement show runtime_context causes the values of any context variables to be displayed.
Executing an operating system command Example
In this example, the command "ls" is executed to display the contents of a directory. Two examples are shown, one that executes the endpoint with no parameters and the second example with a paramater. If this were running on a Windows-based operating sytem, instead of "ls" you would run "dir". Note that any operating system command including a batch file can be executed.
%
% Test execution of an operating system command
%
endpoint :cmdls=> cmd://ls
context :contents => "NA"
context :contents2 => "NA"
context :parameter => "/tmp"
controlflow do
end
Last edit: Bruce Kissinger 2012-11-07