Desktop User Guides > Professional > Interview scripting > Writing interview scripts > Interview Object Model overview > Referring to objects in routing scripts
Referring to objects in routing scripts
IOM has a hierarchical structure, so whenever you want to run an operation (method) or assign a value to a property you must specify the exact location of that operation or property in the hierarchy. The general syntax for these specifications is:
where object1 is the top-level object in the hierarchy, object2 is an object within object1, and object3 is a property or operation within object2. The reference can contain any number of objects separated by dots.
Look at some examples of things most people want to do in their scripts. For more information about these examples, see Writing interview scripts.
Asking questions
The main point of an interview is asking questions. The task you want to perform is related to a question, so you know that you will use the Question object. This makes the Question object the top-level object for this statement.
The next step is to consider what you want to do with this object. You want to ask a question, so you need to use the Ask operation. This makes Ask() the second item in the statement. This makes the statement Question.Ask(). However, this does not work because you have not said which question you want to ask. To do this, replace the reference to the Question object with the question name. If you want to ask the question whose name is prefer, the statement becomes:
and this is what you type in the Routing section.
Setting styles
Now suppose that you want to display the text of the prefer question in red. If you follow the procedure, you start by asking what part of the interview you are working on. It is a question so you use the Question object, and you already know that because you are defining something for a specific question you use the question’s name instead of the word Question.
The next thing to decide is what part of the question you are working with. It's the question text, and the object related to texts of all types is the Label object. This gives you:
The part of the text you want to control is its color, which is a visual attribute. Anything to do with the way something looks on the screen is controlled by the Style object, so you extend the specification to read:
The Color property defines an item's color, so the full specification for the item to be changed is:
All that remains is to specify the color to be used. You want red text, so what you type in the Routing section is:
prefer.Label.Style.Color = "red"
Here is the statement that displays the categorical response texts for prefer in italics:
prefer.Categories[..].Label.Style.Font.Effects = FontEffects.feItalic
In the left of the statement, Categories is a collection item and the [..] that follows it means “all items in the collection”. Label.Style refers to the category text, and Font.Effects refers to the way you want the text to be displayed (italics, bold, underline, and so on are called font effects in IOM).
The right side of the assignment specifies the italic font effect. The values that represent the font effects are stored in the Font.Effects Type Definition. Each effect has its own name, but all effects start with fe. Because the Type Definition has its own hierarchical structure, you define the effect to be set using the same notation as for other hierarchical references.
A grid consists of row headings, column headings (which might be repeated in long grids), and grid cells. In most grids, the row headings come from the loop definition itself, while the column headings come from the response list to the repeated question that is inside the loop. You refer to these texts in the same way that you refer to ordinary questions and their responses.
The cells inside the grid are formed by combining a row characteristic with a column characteristic (for example, by combining gender and age), and in order to refer uniquely to one cell you must identify both the row and the column that form the cell. To do this, start statements with:
The name of the grid (loop) item. [..] after the name means “all repetitions of the loop”. To refer to a particular repetition, replace .. with a number for a number or a categorical text as appropriate. For example, TeaLoop[{Assam}] refers to the repetition for Assam tea.
The name of a question inside the loop.
Refers to all the responses to Qname. To refer to a particular response, replace .. with a number or categorical text as appropriate. For example: Countries.Catagories[{China}] refers to the “China” response.
Following these rules, you can refer to the cell formed by Assam and China by starting a statement with the text:
For example, to give the cell a pink background, use:
Writing scripts
If you write your scripts using UNICOM Intelligence Professional, you can use the ScriptAssist feature to help you choose the right objects in the right order. ScriptAssist displays a list of valid choices whenever you type a dot in an object reference. Scroll down the list, and then select the item you want to insert. In the most recent example, you would type on the left-hand side of the = sign is the question name, the [..], and the dots between the objects. All the rest you could select from lists.
The following diagrams show which objects refer to which elements of an interview page. The first one shows a categorical question and the objects associated with the texts, boxes, and buttons on the page:
This graphic is described in the surrounding text.
Categorical question showing object names for question text, check box, response text, other response, and navigation button text
The following diagram shows the same question but with different styles applied:
This graphic is described in the surrounding text.
See also
Interview Object Model overview