swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
Prerequisite Concepts      

Shelf Literals

A shelf literal is the portion of a shelf declaration following the initial keyword: much like "Hello, world!" is a string literal, 5 is a numeric literal, and true is a switch literal, so

  {"Hello, World!" with key "a", "Salut, Monde!" with key "b"}
is a literal value for a shelf. Note that the braces are part of the shelf literal.

You can initialize a shelf with a shelf literal expression:

  process
     local integer my-constant-numbers initial { 1, 2, 3, 4, 5 }
     output format-numbers (my-constant-numbers)

You can also use a literal expression to set the value of a variable anywhere in code:

  set my-integer to 7

You can use a shelf literal to set a value or to specify a function argument:

  define string source function format-numbers (read-only integer the-numbers)
    as
      repeat over the-numbers
        output "4fkd" % the-numbers || "%n"
      again
  
  process
     output format-numbers ({1, 2, 3, 4, 5})

This feature is very useful when writing unit tests for code. It saves having to create a shelf variable and initialize it when it is needed only once.

Prerequisite Concepts
 
   
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.0β Documentation Generated: September 16, 2008 at 1:38:25 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.