swirl
Guide to OmniMark 8   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax    
operator  

lastmost

 
 

Syntax

shelf-name lastmost


Purpose

lastmost can be used to identify a shelf item to be accessed, wherever an item indexer, [...] or key {...} can be used. The lastmost indexer always accesses the last item on the shelf.

Note that the syntax:

shelf-name lastmost

and

shelf-name [number of shelf-name]

are identical when used to access an item on a shelf. They behave differently when they are used to set the currently selected item:

In the two cases above, when the default item of the shelf or function argument is accessed, the lastmost item is recalculated, while number of is not. This means that when the default item is set to lastmost, it will always be the last item on the shelf, regardless of how the shelf changes.

When the default item on a shelf is set to lastmost, it will always be the last item on the shelf regardless of how the shelf changes. When used to set the currently selected item, lastmost behaves differently than number of.

In this example, which uses lastmost,

  process
     local integer c variable
  
     clear c
     set new c to 1
     using c lastmost
        do
           output "The value is %d(c)%n"
           set new c to 2
           output "The value is %d(c)%n"
           set new c to 3
           output "The value is %d(c)%n"
        done

the output is:

  The value is 1
  The value is 2
  The value is 3

However, when the default is set to the last item with "[number of c]":

  process
     local integer c variable
  
     clear c
     set new c to 1
     using c [number of c]
        do
           output "The value is %d(c)%n"
           set new c to 2
           output "The value is %d(c)%n"
           set new c to 3
           output "The value is %d(c)%n"
        done

the output is:

  The value is 1
  The value is 1
  The value is 1

This is because the number of items on shelf c is just 1. That becomes the numeric index of the shelf for the duration of using.

Note that it cannot be assumed that the "lastmost" item of a passed shelf is its current item. The following function takes this possibility into account, and the using keyword is used to ensure that references to the stream code-set refer only to the newly created item.

  define function add-new-codes (modifiable stream code-set,
                                 value string new-codes) as
     using code-set lastmost
     do
        new code-set
        open code-set as buffer
        repeat scan new-codes
        match letter => one-code
           put code-set "%ux(one-code)"
        match any
           ; skip
        again
        close code-set
     done

    Related Syntax
   number of
 
 
 

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

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:33:48 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.