[TT# 1592][t] Improve test for open opcode delegation. All tests in the file pass...
[parrot.git] / examples / pir / substr.pir
blob1b866824ee07f101b26ae057603935f4945220fb
1 # Copyright (C) 2001-2008, Parrot Foundation.
2 # $Id$
4 =head1 NAME
6 examples/pir/substr.pir - playing with substr
8 =head1 SYNOPSIS
10     % ./parrot examples/pir/substr.pir
12 =head1 DESCRIPTION
14 A exuberating C<substr> version of "Hello World".
16 =cut
18 .sub "example" :main
19         $I2 = 1
20         $I1 = 0
21         $S1 = "Hello World"
22         $I3 = 0
23         $I4 = 0
24         $I5 = length $S1
25 WAX:    $S2 = substr $S1, $I3, $I4
26         print  $S2
27         print  "\n"
28         $I4 = $I4 + $I2
29         if $I4 == $I5 goto WANE
30         branch WAX
31 WANE:   $I1 = length $S1
32         print  $S1
33         print  "\n"
34         chopn  $S1, 1
35         unless $I1 == $I3 goto WANE
36 DONE:
37 .end
39 # Local Variables:
40 #   mode: pir
41 #   fill-column: 100
42 # End:
43 # vim: expandtab shiftwidth=4 ft=pir: