Cards
package command loads the latest Snaml Generic WML library.
package require WML
This procedure will navigate a list of cards in cycle. ls is the list of card's content. Current card id is card_$n. m is the number of elements in the ls.
proc Navigation {ls} {
set m [list::length $ls]
for {set n 0} {$n < $m} {incr n} {
# specify card id and title
_card "id='card_$n' title='Card: $n'"
'accept' key refers to prev card. The previous card id is the (n-1)%m.
_do "type='accept' label='Prev'"
__go "href='#card_[expr {($n-1)%$m}]'"
do_
'option' key refers to next card. The next card id is the (n+1)%m.
_do "type='options' label='Next'"
__go "href='#card_[expr {($n+1)%$m}]'"
do_
display current card. _b_ is the inline command of bold. lindex gets the nth item from the ls.
_p {align='center'}
quote "[_b_ Card] $n [_b_ of] $m"
__br; __br
quote [lindex $ls $n]
p_
card_
}
}
output wml page to file cards.wml. __pi specifies the header of XML. __doctype specifies the
standard wml DTD file.
output cards.wml
__pi {xml version='1.0'}
__doctype {wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml"}
set ls with the initial elements.
set ls {"Let's start!" "Where is the Rocky Mountain?" "Right answer!"}
call Navigation proc with ls.
_wml
Navigation $ls
wml_
|