Variables and Data Types

[Previous] [Next]

OmniMark provides a variety of data types, both built-in and through OMX components. The stream, switch (Boolean), and integer variable types are built in. OmniMark has no string type, but stream variables handle string data. Additional numeric types BCD (binary coded decimal) and float are provided by OMX files. Numerous OMX variable types also represent many different external data sources.

Variables can be either global or local. Global variables exist for the lifetime of the program and are visible everywhere within a program. Local variables exist only within the rule or function in which they are declared.

Since you cannot use variables until you declare them, global variable declarations usually appear at the top of an OmniMark program, and local variables appear at the beginning of the rule or the function in which you plan to use them. You must indicate the scope of a variable (global or local) in the variable declaration.

A variable declaration that creates a global integer variable named word-count looks like this:

 global integer word-count 

To create a local stream variable named quotation, use the following variable declaration:

 local stream quotation 

To store a string in a stream variable, you can use the set keyword, as in the following example:

 set quotation to "Do you have any grapes?" 

You can set and change integer variable values the same way you set and change stream variables—using the set action—but you can also manipulate integer variables by using the increment and decrement actions. For example, to increase the value of the count1 variable by 1, you need only use the following statement:

 increment count1 

You can increment or decrement the value of an integer variable by the value of another integer variable. For example, you could decrement the value of count1 by the value of count2 with the following code:

 decrement count1 by count2 

The program that follows makes use of a global switch variable to decide which output action should be executed.

 global switch question process set question to true do when question ;checks if question is true output "to be" else output "not to be" done 

Note that the output of this program will always be "to be".

You can declare a variable with an initial value:

 global integer count2 initial {3} global stream quotation2 initial {"A mallard!"} global switch status2 initial {true} 

You can set a variable to the value of another variable. For example, the process rule in the following program will set the value of the global integer variable var1 to the value of the local integer variable var2 and give you the output 8.

 global integer var1 process local integer var2 set var2 to 8 set var1 to var2 process output "%d(var1)" 

Finally, you can initialize a variable to a dynamic expression. For example, instead of writing this:

 local TCPConnection connection set connection to TCPConnectionOpen on server-host at server-port 

you can initialize the variable dynamically:

 local TCPConnection connection initial {TCPConnectionOpen on server-host at server-port } 

XML and SOAP Programming for BizTalk Servers
XML and SOAP Programming for BizTalk(TM) Servers (DV-MPS Programming)
ISBN: 0735611262
EAN: 2147483647
Year: 2000
Pages: 150 © 2008-2017.
If you may any questions please contact us: