lastmost Full Description |
|
Syntaxshelf-type? shelf-name lastmost Purpose
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 When the default item on a shelf is set to In this example, which uses 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 " 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 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 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 |