~ubuntu-branches/ubuntu/utopic/xslthl/utopic

« back to all changes in this revision

Viewing changes to examples/sources/example-tcl.xml

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2013-05-16 08:59:07 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20130516085907-ujk9f81x8w344ch1
Tags: 2.1.0-2
Upload to sid

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="UTF-8"?>
2
 
<example-document>
3
 
        <header>Tcl code</header>
4
 
        <para>Example tcl code</para>
5
 
        <code xml:whitespace="preserve" language="tcl">
6
 
                <![CDATA[
7
 
#!/usr/bin/tclsh
8
 
 
9
 
# 99.tcl; Tcl version of 99 Bottles of Beer Song
10
 
 
11
 
proc findBString { count } {
12
 
  return [switch -exact -- $count {
13
 
    0       { expr {"No more bottles"}  }
14
 
    1       { expr {"1 bottle"}         }
15
 
    default { expr {"$count bottles"}   }
16
 
  }]
17
 
}
18
 
 
19
 
set bottles 99
20
 
set bString [findBString $bottles]
21
 
while {$bottles + 1} {
22
 
  puts "$bString of beer on the wall.  $bString of beer."
23
 
  incr bottles -1
24
 
  if {$bottles + 1} {
25
 
    set bString [findBString $bottles]
26
 
    puts "Take one down, pass it round, $bString of beer on the wall.\n"
27
 
  } else {
28
 
    puts "Go to the store and buy some more...99 bottles of beer."
29
 
  }
30
 
}
31
 
                ]]>
32
 
        </code>
33
 
        <para>Origin: http://www.99-bottles-of-beer.net/language-tcl-797.html</para>
34
 
        <para>Additional examples</para>
35
 
        <code xml:whitespace="preserve" language="tcl">
36
 
                <![CDATA[
37
 
# keywords starting with an '-' are not keyword         
38
 
proc -proc { -switch } {
39
 
  switch -exact -- $-switch {
40
 
    0       { expr {"No more bottles"}  }
41
 
    1       { expr {"1 bottle"}         }
42
 
    default { expr {"$count bottles"}   }
43
 
  }
44
 
}               
45
 
                ]]>
46
 
        </code>
47
 
</example-document>
 
 
b'\\ No newline at end of file'