Communication amounts to sending and receiving data. This data must have some type in Oz. Data sent from DFKI Oz are virtual strings , whereas data received are strings . In the following we will review these data types and show some operations which may be helpful in the context of Open Programming. For a complete reference, see [1].
Strings are lists of characters, with characters being small integers between 0 and 255. There are special operations on strings, like testing whether a given value X is a string, by \ IsStringB X . For transforming received strings into atoms, integers, or floats the procedures String.toAtom , String.toInt , and String.toFloat are provided. In addition, all functionality provided by the module List is applicable. Especially useful is the combination with the functionality the module Char provides for. Suppose that after receiving a string S="C@l!3E4aN#61!" all characters which are neither uppercase nor lowercase letters must be filtered out. This is achieved by using a combination of FilterB and Char.isAlphaB . Feeding:
{Browse {String.toAtom {FilterB S Char.isAlphaB}}}will show the cleaned information in the browser window. Instead of creating an atom from the cleaned string, the browser offers functionality to display strings directly in a convenient form. For this, you have to select the Virtual strings entry in the View menu. After feeding
{Browse {FilterB S Char.isAlphaB}}in the browser window the character sequence ClEaN will be displayed. Sometimes character codes for certain letters are needed. This can be achieved in the following style:
local [CharA Char0 NL] = "A0\n" in %% use of the declared variables endThe above code fragment declares the variables CharA, Char0, and NL and constrains them to the codes of the characters A, 0, and newline, respectively.
The data to be sent usually consists of a sequence of integers, atoms, floats, and strings. If only strings were allowed to be sent as information, the entire data would have to be transformed into a string. This would be clumsy and inefficient with regard to both space and time. We use virtual strings for this purpose instead. A virtual string is either an atom, a float, an integer, a string, or a tuple with label '#', whose subtrees are virtual strings themselves. For instance,
12#(2#fast#4#"U")#~3.1415is a virtual string. In the above example it is quite clear, that # stands for concatenation (i.e. for virtual concatenation). There is some predefined functionality for virtual strings, like testing, by IsVirtualString , converting to a string, by VirtualString.toString , and changing of signs, by VirtualString.changeSign . The latter procedure is quite important, because
{Browse 12#(2#fast#4#"U")#~3.1415}will show that not the Oz-style unary minus sign but the usual one (i.e., -) is used. The procedure VirtualString.changeSign provides the possibility to choose an arbitrary virtual string for the minus sign in numbers. It takes as input arguments two virtual strings, and substitutes every occurrence of the - character as a unary minus sign in numbers of the first argument by the second argument. Feeding:
{Browse {VirtualString.changeSign 12#(2#fast#4#"U")#~3.1415 '~'}}will show the virtual string with the Oz-style unary minus sign. Note that in order to display the virtual string in readable form in the browser you have to select the Virtual strings item in the View menu of the browser. For more information on browsing virtual strings see also [4]. In the following we will assume that the browser is configured for displaying virtual strings.