[QR_9]

Description

Link: [QR_9]
Author: Rich Fortnum
Category: Output
Version: 9.x
License: Public Domain
Posted: Jul. 12, 2011
Updated: Jan. 01, 0001
More by this author...

Generate QR code & syntax in Lasso 9

Parameters

none


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)

'<br>'
$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.
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
[
log_critical('loading qr type')

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

[QR]
QR Code Generator

Author: Rich Fortnum
Last Modified: Jul. 12, 2011
License: Public Domain


Modified for Lasso 9 by Jolle Carlestam


Description:



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)

'<br>'
$m->version

Latest version available from <http://tagSwap.net/QR_9>.

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

define qr => type {

	// =========== MEMBER
	data public size::integer
	data public error_collection::string
	data public version::string
	data public margin::integer
	data public structured::boolean
	data public kanji::boolean
	data public ignorecase::boolean
	data public eightbit::boolean
	data public qr_home::string

	// =========== CONSTRUCTOR
	public oncreate(
		size::integer = 3,
		error_collection::string = 'L',
		version::string = 'auto',
		margin::integer = 4,
		structured::boolean = true,
		kanji::boolean = false,
		ignorecase::boolean = true,
		eightbit::boolean = false,
		qr_home::string = 'qrencode'
	) => {

		// ==> insert incoming parameters into the properties
		.size = #size
		.error_collection = #error_collection
		.version = #version
		.margin = #margin
		.structured = #structured
		.kanji = #kanji
		.ignorecase = #ignorecase
		.eightbit = #eightbit
		.qr_home = #qr_home


	}

	public oncreate(
		-size::integer = 3,
		-error_collection::string = 'L',
		-version::string = 'auto',
		-margin::integer = 4,
		-structured::boolean = true,
		-kanji::boolean = false,
		-ignorecase::boolean = true,
		-eightbit::boolean = false,
		-qr_home::string = 'qrencode'
	) => {
		.oncreate(#size, #error_collection, #version, #margin, #structured, #kanji, #ignorecase, #eightbit, #qr_home)
	}

	// =========== METHOD
/**!
change
generic set method
**/
	public change(property::string, value::any) => {
		match(#property) => {
			case('size')
				.size = #value
			case('error_collection')
				.error_collection = #value
			case('version')
				.version = #value
			case('margin')
				.margin = #value
			case('structured')
				.structured = #value
			case('kanji')
				.kanji = #value
			case('ignorecase')
				.ignorecase = #value
			case('eightbit')
				.eightbit = #value
			case('qr_home')
				.qr_home = #value
		}
	}

/**!
show_properties
displays properties in a map
**/
	public show_properties() => {

		return map(
			'size' = .size,
			'error_collection' = .error_collection,
			'version' = .version,
			'margin' = .margin,
			'structured' = .structured,
			'kanji' = .kanji,
			'ignorecase' = .ignorecase,
			'eightbit' = .eightbit,
			'qr_home' = .qr_home
		)

	}

/**!
generate
generates the QR code with the supplied location
**/
	public generate(
		path::string, // path has terminal "/"
		filename::string,
		inputstring::string,
		syntax_only::boolean = false
	) => {

		fail_if(!#path -> beginswith('/') || !#path -> endswith('/'), -1, 'Path must start and end with a slash "/"')

		local(site_path = (file_forceRoot(response_Path) -> split('//')) -> removeall('')& -> first)

		if(#site_path -> split('/') -> first !=  #path -> split('/') -> removeall('')& -> first) => {
			// path is probably not pointing to the server root, change that
			#path = '///' + #site_path + #path
		}

		local(syntax = .'qr_home' + ' -o ' + #path + #filename + ' -s ' + .'size' + ' -l ' + .'error_collection' + ' -m ' + .'margin')

		.'kanji' ? #syntax += ' -k'
		.'ignorecase' ? #syntax +=  ' -i'| #syntax += ' -c'
		.'eightbit' ? #syntax += ' -8'
		#syntax += ' '
		#inputString = string_replaceregexp(#inputString, -find = `'`, -replace = `'\'`) // '
		#syntax += "'" + #inputString + "'"
		#syntax_only ? return #syntax

		shell(#syntax) // remember to match up this tagname to shell


	}

	public generate(
		-path::string, // path has terminal "/"
		-filename::string,
		-inputstring::string,
		-syntax_only::boolean = false
	) => .generate(#path, #filename, #inputstring, #syntax_only)

/**!
version
returns version of qrencode
**/
	public version() => shell(.'qr_home' + ' -V') // remember to match up this tagname to shell

}

log_critical('done loading qr type')

]

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net