contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
operator   lastmost    
  Related Syntax    

Syntax

  shelf-type? shelf-name lastmost


Purpose

lastmost can be used to identify a shelf item to be accessed, wherever an @ (item) or ^ (key) indexer 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 counter 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":

  process
     local counter 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 stream 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
   item
   key
   number of
 
 
----  

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:10 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.