swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax   Related Concepts  
operator  

literal

 
 

Syntax

literal keyword


Purpose

Placing literal before any of the keywords arg, token, literal, or is lets you use these keywords as part of a macro name or argument delimiter, and lets you use the keyword macro-end in the macro definition.

The code below uses literal before "is" in a macro definition to keep "is" from being interpreted as an OmniMark keyword. The macro named "my" uses the word "is" as a literal, so that you can assign local variables by using an English-like line of code such as "my nick-name is Speedy".

  macro my token id literal is token value is
     set id to value
  macro-end
  
  process
      local stream nick-name
      local stream home-town
  
      my nick-name is "Speedy"   
      my home-town is "Denver"
  
      output "My nickname is %g(nick-name).%n" 
               ||  "My hometown is %g(home-town).%n"

The code below uses literal in a macro definition to define constants automatically without writing a macro for every single one. The macro "const" uses "macro-end" as a literal and dynamically builds a macro every time it sees "const" followed by a word, an equal sign, and a quoted string. This lets you use BASIC-style const declarations instead of macros for declaring constants. Redefining small bits of OmniMark in this way makes for clear and simple examples, but not necessarily for maintainable OmniMark code, so use with caution.

  macro const arg name = token value  is 
     macro name 
     is value
     literal macro-end
  macro-end
  
  const mary = "Mary had a little lamb%n"
  
  process
     output mary

    Related Syntax
 
Related Concepts
 
 

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

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:51:21 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.