[C_Integer]

Description

Link: [C_Integer]
Author: Göran Törnquist
Category: Variable
Version: 8.x
License:
Posted: Apr. 20, 2006
Updated: Apr. 20, 2006
More by this author...
Provides Lasso with a integer type that primarily remembers the formatting even if the variable is assigned a new value.

Encapsulates the format and the real integer value within the custom type.

The majority of the custom tags are dealing with automatic conversion and assigments.

Parameters

none


Sample Usage

var: 'debt' = (C_Integer: 1000);
$debt->(setFormat: -groupChar=' ');

$debt += 5;
'You owe me ' + $debt + ' apples';

$debt = 2000;
'You owe me ' + $debt + ' oranges';
						

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Define_Type: 'C_Integer', -prototype;
	local: 'format' = array;
	local: 'value' = integer;
	
	Define_Tag: 'onCreate', -optional='value';
		if: (local_defined: 'value');
			self->'value' = #value;
		/if;
	/Define_Tag;

	Define_Tag: 'onAssign';
			params->(get: 1)->type;
			self->'value' = (integer: params->(get: 1));
		return: true;
	/Define_Tag;
	
	Define_Tag: '+=';
		self->'value' += params->(get: 1);
		return: true;
	/Define_Tag;
	
	Define_Tag: '-=';
		self->'value' -= params->(get: 1);
		return: true;
		//it was expected to return a value, but that errors
		//this is probably because of the order of calling that is invoked
		//due to the implementation of onAssign and onConvert
	/Define_Tag;

	Define_Tag: '*=';
		self->'value' *= params->(get: 1);
		return: true;
	/Define_Tag;
	
	Define_Tag: '/=';
		self->'value' /= params->(get: 1);
		return: true;
	/Define_Tag;
	
	Define_Tag: 'onConvert';
		select: params->(get: 1);
		case: 'string';
			null->\setFormat->(run: -name='setFormat', -owner=self->'value', -params=self->'format');
			return: (string: self->'value');
		case: 'integer';
			return: (integer: self->'value');
		case: 'decimal';
			return: (decimal: self->'value');
		/select;
		
	/Define_Tag;
	
	Define_Tag: '_unknownTag';
		local: 'tag' = integer->properties->second->(find: tag_name);
		local: 'result' = null;
		if: #tag == null;
			#tag = null->properties->second->(find: tag_name);
		/if;
		
		if: #tag != null;
			#result = #tag->(run: -name=tag_name, -owner=self->'value', -params=params);
		else;
			fail: -9948, 'No tag, type or constant was defined under the name ' + self->type + '->' + tag_name + ' with arguments ' + params;
		/if;
	/Define_Tag;
	
	Define_Tag: 'setFormat';
		self->'format' = params;
	/Define_Tag;
/Define_Type;

 

Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net