Link | C_Integer |
Author | Göran Törnquist |
Category | Variable |
Version | 8.x |
License | http://creativecommons.org/licenses/by/2.5/ |
Posted | 20 Apr 2006 |
Updated | 20 Apr 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.
var: 'debt' = (C_Integer: 1000); $debt->(setFormat: -groupChar=' '); $debt += 5; 'You owe me ' + $debt + ' apples'; $debt = 2000; 'You owe me ' + $debt + ' oranges';
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.
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;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft