: (field selection operator)

modifier

Syntax
record variable : field name


Purpose

You can use : (colon) to select an individual field of a record:

  declare record metadata-label
     field string author
     field string title
     field string publisher
     field integer year
     field switch in-print initial {true}
  
  process
     local metadata-label doc-info
  
     set doc-info:author to "Mark Baker"
     set doc-info:title to "Internet Programming with OmniMark"
     set doc-info:publisher to "Kluwer Academic Publishers"
     set doc-info:year to 2000
  
     set author-name to doc-info:author
     output doc-info:title

The field selection operator can also be used to select a field from an expression of a record type. The expression must be parenthesized. Thus, the field selection operator can be applied to a function call if that function returns a record type:

  declare record point
     field integer x
     field integer y
  
  declare record pixel extends point
     field string color
  
  define dynamic point function 
     move-point    value point a
                to value point b
  as
     local point c
  
     set c:x to b:x
     set c:y to b:y
  
     return c
  
  define overriding point function 
     move-point    value pixel a
                to value point b
  as
     local pixel c
  
     set c:x to b:x
     set c:y to b:y
  
     return c
  
  process
     local point a variable
     local pixel b
     local point c
  
     set b:x     to 5
     set b:y     to 78
     set b:color to "red"
  
     set c:x to 87
     set c:y to 56
  
     output "d" % (move-point b to c):x

Related Concepts