![]() |
|
||||
![]() ![]() ![]() ![]() |
|||||
|
|
|||||
| Related Syntax | Related Concepts | ||||
| built-in variable |
#item |
||||
Syntax
numeric expression: #item format item: %format_item(#item)
There are three tools that can be used within a repeat over loop:
#item can be used in numeric expressions or in format items that format integers.
The#item integer always provides a value of 1 for its first iteration and the number of opened elements for its last iteration. This occurs even if the "reversed" option is used because#item never counts back to 1.
As a predefined shelf, #item is "read-only" and may only be passed as a read-only argument.
The#first switch always provides a value of "true" for the first iteration of a repeat-over loop and on subsequent iterations always provides a value of "false".
The#last switch always provides a value of "true" for the last iteration of a repeat-over loop; on previous iterations #last always provides a value of "false".
Usage example:
process
local switch flags variable initial-size 4 initial {true with key "one",
true with key "two",
true with key "three",
true with key "four"}
set flags{"one"} to true
set flags{ "two"} to false
set flags{"three"} to true
set flags{"four"} to false
repeat over flags
do select #item
case 1
output "1st flag is "
case 2
output "2nd flag is "
case 3
output "3rd flag is "
case 4 to 20
output "%d(#item)th flag is "
else
output "Flag number %d(#item) is "
done
do when #first
output "{first loop) "
done
do when #last
output "(last loop) "
done
do when flags
output "on.%n"
else
output "off.%n"
done
again
; Output: "1st flag is {first loop) on.
; 2nd flag is off.
; 3rd flag is on.
; 4th flag is (last loop) off."
|
Related Syntax repeat over, #item, #last, #first |
Related Concepts Shelves |
Copyright © Stilo International plc, 1988-2008.