DQL call by Keyword

You can define a DQL routine and then call it by name elsewhere in the same DQL.

For example, look at the following section of DQL.

 

define "Res" Number .

define "Arg" Number.assign Arg := 10 .

/* This procedure takes a number and returns its square */procedure Number SqByVal(Number x)return x*x .end.

In the section of code above we have done two things.

 

/* This procedure takes a number and returns its square */procedure Number SqByVal(Number x)return x*x .

 

…this code has defined a procedure named SqByVal. The procedure takes one parameter, a number, multiplies the parameter by itself, and then returns it.

Using the new call routine by keyword facility we can use this procedure anywhere in our DQL script. For example, the following line of code;

assign Res := SqByVal(Arg) .

… calls the procedure, and passes it the variable Arg, which currently has a value of ten. The procedure multiplies Arg by itself, and returns the result into Res. If we now write a line of DQL such as;

 

message Res window .

…the value 100 will appear in a message window – just to prove that the procedure really works.

 

If you have DQL procedures which use the same routine many times, then you will appreciate how useful the new facility will be in creating shorter and more easily maintained DQL’s.