Lasso Soft Inc. > Home

[QR]

LinkQR
AuthorRichard Fortnum
CategoryData Type
Version8.5.x
LicensePublic Domain
Posted05 Jul 2011
Updated12 Jul 2011
More by this author...

Description

QR type, QR Code Based upon qrencode from Kentaro Fukuchi, fukuchi@megaui.net

http://fukuchi.org/works/qrencode/

http://fukuchi.org/works/qrencode/manual/index.html

Sample Usage

var('m') = qr(-size = 5, -margin = 10);
var('f') = lasso_uniqueid;
$m->generate(
     -path = '///Library/Webserver/Documents/localtest/QR/files/', 
     -filename = $f + '.png', 
     -inputString = 'http://WWW.pints.com?flavour=' + $f);

'
'; $m->version;

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.

[	// CTYP v6 (March 10)

define_type('QR', -description = 'QR code generation');

/*-----------------------------------------------------------------------------------------
DESCRIPTION
		QR type, QR Code
		Based upon qrencode from Kentaro Fukuchi, fukuchi@megaui.net
		http://fukuchi.org/works/qrencode/
		http://fukuchi.org/works/qrencode/manual/index.html
		
		Installation notes for Mac OS X Snow Leopard
		=============================================
		
		Lasso 8.6 tested only
		cd ~
		mkdir qr
		cd qr/
		tar zxvf qrencode-3.1.1.tar.gz
		cd qrencode-3.1.1
		export png_CFLAGS="-I /usr/X11/include/"
		export png_LIBS="-lpng -L/usr/X11/lib/"
		touch pkg-config
		chmod +x pkg-config 
		export PATH=$PATH:.
		
		./configure --enable-static --disable-shared																// Not documented anywhere else, contacted Kentaro
		(old version was ./configure only)
		make
		
		n.b.: The make script did not take into consideration Mac OS X.  Therefore the binary will reside inside the directory where the make file is.
		Copy this binary file "qrencode" after a make is done without errors, into /usr/local/bin/ and it will work.  If not, check your $PATH environment
			variable and make sure /usr/local/bin/ is indeed listed there.  More information on environment variables on the Internets.  
		Permissions for Lasso file writing will have to be met.  More details on Thtevie's page:  http://www.stevepiercy.com/lasso_stuff/file_perms.lasso
		rf_shell is my mod of the shell tag, which encapsulates os_process for it to work (this can get really time consuming as it's tricky).  Find it here:
			http://tagswap.net/shell
		XTools will need to be installed in order to compile the qrencoder files
		
		Now to make a QR code:
		./qrencode -o ~/Desktop/modulo.png "http://www.modulo.ro"
		
			-o				output filename
			-s number	size (number), specify the size of dot (pixel) (default = 3)
			-l {LMQH}	level of error correction, from L lowest to H highest
			-v number	symversion (number), the version of the symbol (default = auto)
			-m number	margin width (default = 4)
			-S 			structured, make structured symbols.  Version must be specified
			-c				case sensitive.  encode lower-case alphabet characters in 8-bit mode (default)
			-i				ignore case, only use upper case
			-8				use 8 bit.  -k, -c, -i will be ignored
			-v				display the version number and copyrights of the qrencode
			
		Examples
		--------
		
		qrencode -o ~/Desktop/google.png "http://www.google.com"
		qrencode -o ~/Desktop/google5.png -s 5 "http://www.google.com"
		qrencode -o ~/Desktop/google10.png -s 10 "http://www.google.com"
		qrencode -o ~/Desktop/domain.png -s 10 -l H -m 20 -c "http://www.domain.com?p=contact&employee=fred%20rocking&department=accounting"


PROPERTIES
		size 						- pixel size (default 3)
		error_collection 		- error collection level, from Lowest, to Medium, to Q to Highest, default L								// not really implemented
		version 					- version of the symbol, default = auto																				// not implemented
		margin 					- margin of the code, default = 4
		structured 				- boolean, make structured symbols, version must be specified													// not implemented
		kanji 					- boolean, assume kanji (shift-jis)
		casesensitive 			- boolean, encode lower case alphabet characters in 8-bit (default)
		ignorecase 				- boolean, ignore case distinctions and only use uppercase characters
		8bit 						- use 8 bit only (k, c, i will be ignored)
		inputString 			- the string to be input
		qr_home					- home of the qrencode binary
		
METHODS
		qr->generate(-required = 'path', -required = 'filename');					generates the outputted png file, path must include terminus "/", filename without suffix (will always be .png)
		qr->version;																				shows what version 

VERSION HISTORY
		v1.0	2011.06.27 21:16:00			created

LICENSE
		Public Domain

FEEDBACK
	Rich Fortnum, fortnum@viaduct-productions.com
	Viaduct Productions http://www.viaduct-productions.com
	
KUDOS
	Pier Kuipers - insight into quotation usage re: ' vs "
	James Harvard - BASH Shell escaping of quotations
	Kentaro Kukuchi - Original qrencode (libqrencode) binaries & implementation

Latest version available from .

TBD:





-----------------------------------------------------------------------------------------*/

// ========================================================================================================================================================== PROPERTIES
local('size') 								= 3;													// I have re-iterated default values here
local('error_collection') 				= 'L';
local('version') 							= 'auto';
local('margin')							= 4;
local('structured')						= true;
local('kanji')								= false;
local('casesensitive')					= false;
local('ignorecase')						= false;
local('8bit')								= false;
local('qr_home')							= 'qrencode';

// ========================================================================================================================================================== CONSTRUCTOR

define_tag('onCreate', -description = 'ctyp instance onCreate method');
	// ==> insert incoming parameters into the properties
	local('paramName') = string;
	iterate(params, local('i'));
		if(#i->type == 'pair');
			#paramname = #i->first;
			#paramName->removeleading('-');
			self->properties->first->keys >> #paramName ? self->#paramName = encode_sql(#i->second);
		else;
			#paramName = #i;
			#paramName->removeleading('-');
			self->properties->first->keys >> #paramName ? self->#paramName = true;
		/if;
	/iterate;
/define_tag;

// ========================================================================================================================================================== METHODS

define_tag('change', -required = 'property', -required = 'value', -description = 'generic set method');
	self->#property = #value;
/define_tag;

define_tag('show_properties', -description = 'displays properties in a nicer matter');
	local('f') = '
PROPERTIES:
'; local('myProps') = self->properties->first; iterate(#myProps, local('t')); local('myPropName') = #t->first; #f += '- ' + #t->first + ' (' + self->#myPropname->type + ') = ' + #t->second + '
'; /iterate; #f += '
'; return(@#f); /define_tag; define_tag('show_methods', -description = 'shows methods & descriptions for this type'); local('f') = '
PROPERTIES:
'; iterate(self->properties->second, local('t')); #f += #t + '
'; /iterate; #f += '
'; return(@#f); /define_tag; define_tag('generate', -description = 'generates the QR code with the supplied location', -required = 'path', -type = 'string', -required = 'filename', -type = 'string', -required = 'inputString', -copy, -type = 'string', -optional = 'feedback', -type = boolean); // path has terminal "/" local('syntax') = self->'qr_home' + ' -o ' + #path + #filename + ' -s ' + self->'size' + ' -l ' + self->'error_collection' + ' -m ' + self->'margin'; !local_defined('feedback') ? local('feedback') = false; self->'kanji' ? #syntax += ' -k'; self->'casesensitive' ? #syntax += ' -c'; self->'ignorecase' ? #syntax += ' -i'; self->'8bit' ? #syntax += ' -8'; #syntax += ' '; #inputString = string_replaceregexp(#inputString, -find='\'', -replace='\'\\\'\''); #syntax += '\'' + #inputString + '\''; inline(-username = $un, -password = $pw); local('p1') = rf_shell(#syntax); // remember to match up this tagname to shell /inline; local('out') = 'QR string: ' + #syntax; #feedback ? return(#syntax); /define_tag; define_tag('version', -description = 'shows version of qrencode'); local('syntax') = self->'qr_home' + ' -V'; inline(-username = $un, -password = $pw); local('f') = rf_shell(#syntax); // remember to match up this tagname to shell /inline; return(#f); /define_tag; /define_type; ]

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft