[chequeboxes]

Description

Link: [chequeboxes]
Author: Jon Harris
Category: Output
Version: 8.x
License: Public Domain
Posted: Jan. 17, 2006
Updated: Jan. 17, 2006
More by this author...

I use this tag as part of a pdf generator which prints the digit names in boxes on a cheque. Just pass it the amount and the number of digits (optional) and it will return an array with them in. If the number of digits is less than required it will pad them with 'zeros'.

Parameters

-amount string, required the amount for conversion
-digits integer, optional number of digits required for padding

Sample Usage

[chequeboxes: -amount='500',-digits='5']
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
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;

?>

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net