1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?LassoScript
define_tag:'chequeboxes',
-required='amount',
-optional='digits';
// jon harris, digital ink
// number of digis is the length of the amount
local: 'digitcounter' = (string_length: #amount) ;
// array to hold the names of the digits, can be changed to caps, or multi-lingual, if required
local: 'wordsarray' = (array: 'zero','one','two','three','four','five','six','seven','eight','nine') ;
local: 'digitarray' = (array) ;
// did we get the number of digits passed?
if: (local_defined: 'digits') ;
// padding is the difference in lenghts
local: 'padding' = (integer: #digits) - (integer: #digitcounter) ;
// loop to insert in array, if required
if: #padding > 0 ;
loop: -loopto=#padding ;
#digitarray->(insert: 'zero') ;
/loop ;
/if;
/if ;
// the meat! get each digit and find its name.
loop: -loopto= #digitcounter;
local: 'thedigit' = (String_Extract: #amount, -StartPosition=(loop_count), -EndPosition=(loop_count)) ;
local: 'theword' = #wordsarray->(get: (integer: #thedigit) + 1) ;
#digitarray->(insert: #theword) ;
/loop ;
// usage somthing like this
// [chequeboxes: -amount='500',-digits='5']
return: #digitarray;
/define_tag;
?>
|