Il sito non verrà più aggiornato

Buongiorno,

a causa della politica dei prezzi che LiveCode sta adottando, arrivando a far pagare ben 999$ la licenza indie nel 2017, ed alzando costantemente i prezzi (usando tale rialzo come “arma” inducendo gli utenti a rinnovare i contratti prima possibile), ho deciso di sospendere la scrittura di articoli per questo prodotto.

Grazie

Realizzare un TCP network scanner

Introduzione

Stavolta ci dedicheremo ad un progetto più impegnativo: realizzeremo un semplicissimo TCP network scanner.

Si tratta di un programma che tenta di aprire una connessione TCP con i computers collegati all’interno di un network. Le porte a cui ci si riesce a connettere con successo vengono poi elencate in una lista.

Il

Network Scanner
Network Scanner

Tutorial:

Questo è il video che mostra come realizzarlo, passo dopo passo:

Codice sorgente:

Questo è il codice sorgente completo da agganciare al pulsante “Start Scan”:

local locCurrentIp
local locPort

on mouseUp
    put empty into field "fldResult"
    
    put empty into field "fldCurrentIp"
    
    get field "fldStartIp"
    split it using ":"
    
    put it[1] into locCurrentIp
    put ":" & it[2] into locPort
    
    sendPingSocket
end mouseUp

on sendPingSocket 
    set the itemDelimiter to "."
    
    open socket to (locCurrentIp & locPort) with message "socketIsOpen"
    put (locCurrentIp & locPort) into field "fldCurrentIp"
    
    if item 4 of locCurrentIp < 255 then         add 1 to item 4 of locCurrentIp         send "sendPingSocket" to me in 0.1 seconds     end if end sendPingSocket on socketError tSocket, theError     put "[ERROR]" && tSocket && "-->" && theError & cr after field "fldResult"
    checkScanCompleted tSocket
end socketError

on socketIsOpen tSocket
    put "[OPEN]" && tSocket & cr after field "fldResult"
    checkScanCompleted tSocket
end socketIsOpen

on checkScanCompleted tSocket
    close socket tSocket
end checkScanCompleted

on socketTimeout tSocket
    checkScanCompleted tSocket
end socketTimeout

Come aggiungere il numero di riga ad un testo

Talvolta potrebbe far comodo aggiungere il numero di riga ad un testo arbitrario.

Per esempio:

LiveCode è il
più bel linguaggio
di programmazione
del mondo!

 

Diverrebbe:

1) LiveCode è il
2) più bel linguaggio
3) di programmazione
4) del mondo!

 

Questa operazione può essere svolta in modo molto semplice, grazie alle avanzate funzioni di LiveCode per il trattamento testi. Ecco il codice:

repeat with i=1 to the number of lines of myText
put i & “) ” before line i of myText
end repeat

 

REPEAT è una istruzione di inizio ciclo (al pari di una FOR nei linguaggi come Java, C#, basic, etc…). Il ciclo andrà da 1 al numero di righe contenute nel mio testo, memorizzato in myText.

All’interno del ciclo viene messo il numero di riga “i”, una parentesi “) ” PRIMA (BEFORE) della riga (quindi all’inizio della riga stessa).

In questo breve video mostro alcune varianti e possibili usi di questo mini-programma.

Come realizzare un risolutore di formule matematiche

Ciao a tutti!

Stavolta alziamo il tiro con un tutorial avanzato.

Faremo un programma completo, che permetterà ad un utente di inserire una formula matematica e di calcolarne il risultato. Per esempio: “( 5*sin(123) ) / 12”

Si tratta di qualcosa che va ben oltre la normale calcolatrice, e permette invece di calcolare rapidamente risultati di complessi calcoli matematici.

Mostreremo quali avanzati strumenti ha LiveCode per risolvere in modo brillante questo complesso problema. Tratteremo anche la gestione avanzata degli errori, usando le eccezioni.

Infine vedremo come creare una form ben fatta, e che si adatti si ridimensionamenti della form stessa.

Ecco il video e… buon divertimento!

Qui trovate invece la lista dei codici di errore della try… catch di LiveCode con associati i messaggi di errore:

 

1	Handler: Running low on memory, script aborted
2	recursionLimit: Recursion limit reached
3	abs: error in source expression
4	accept: bad expression
5	aclip: playLoudness is not an integer
6	acos: error in source expression
7	acos: domain error
8	add: error in matrix operation
9	add: destination has a bad format (numeric?)
10	add: error in source expression
11	add: can't set destination
12	add: can't add array to scalar
13	aliasReference: error in file expression
14	Operators and: error in left operand
15	Operators and: error in right operand
16	Operators bitAnd: error in left operand
17	Operators bitAnd: error in right operand
18	annuity: error in period expression
19	annuity: error in rate expression
20	answer: error in question expression
21	answer: error in response expression
22	answer: error in title expression
23	split: error in expression
24	arrowKey: error in direction expression
25	arrowKey: not a direction
26	asin: error in source expression
27	asin: domain error
28	ask: error in question expression
29	ask: error in reply expression
30	ask: error in title expression
31	atan2: error in first expression
32	atan2: error in second expression
33	atan2: domain error
34	atan: error in source expression
35	atan: domain error
36	average: error in source expression
37	base64Decode: error in source expression
38	base64Encode: error in source expression
39	baseConvert: bad destination base
40	baseConvert: error in source expression
41	baseConvert: bad source base
42	baseConvert: can't convert this number
43	baseConvert: destination is not base 10
44	beep: error in expression
45	binaryDecode: destination is not a variable
46	binaryDecode: invalid data for parameter
47	binaryDecode: not enough parameters
48	binaryDecode: error in source expression
49	binaryEncode: invalid data for parameter
50	binaryEncode: not enough parameters
51	binaryEncode: error in source expression
52	Button: bad accelerator modifier
53	Button: family is not an integer
54	Button: menuButton is not an integer
55	Button: menuHistory is not an integer
56	Button: menuLines is not an integer
57	Button: mnemonic is not an integer
58	cancel: message id is not an integer
59	charToNum: error in source expression
60	choose: error in expression
61	choose: not a tool
62	Chunk: error in background expression
63	Chunk: error in card expression
64	Chunk: error in character range
65	Chunk: container is not a button or field
66	Chunk: error in chunk expression
67	Chunk: error in item range
68	Chunk: error in line range
69	Chunk: error in object expression
70	Chunk: error in range end expression
71	Chunk: error in range start expression
72	Chunk: error in stack expression
73	Chunk: error in text string
74	Chunk: can't separate tokens
75	Chunk: can't separate words
76	Chunk: can't delete object
77	Chunk: can't find object
78	Chunk: can't get object attributes
79	Chunk: can't get value of destination container
80	Chunk: can't get number
81	Chunk: can't get source string
82	Chunk: can't get substring
83	Chunk: can't find substring
84	Chunk: can't set attributes
85	Chunk: can't store to destination container
86	Chunk: can't set as a number
87	Chunk: can't find background
88	Chunk: can't find card
89	Chunk: no such object
90	Chunk: can't set property
91	Chunk: can't find stack
92	Chunk: no target found
93	Chunk: can't select object that isn't open
94	Chunk: source is not a container
95	Chunk: can't find object to store into
96	Chunk: can't get source from container
97	Chunk: destination is not a container
98	click: script aborted
99	click: expression is not a button number
100	click: error in point expression
101	click: expression is not a point
102	click: stack is not open
103	clone: error in name expression
104	clone: can't clone this object
105	clone: stack is locked
106	clone: can't find object to clone
107	close: error in name expression
108	close: can't find stack
109	color: error setting selectedColor
110	compact: can't find stack to save
111	compact: object is not a stack
112	compound: error in periods expression
113	compound: error in rate expression
114	compress: error in source expression
115	compress: error occurred during compression
116	Operators &&: error in left operand
117	Operators &&: error in right operand
118	Operators &: error in left operand
119	Operators &: error in right operand
120	Operators contains: error in left operand
121	Operators contains: error in right operand
122	convert: can't read from container
123	convert: can't set container
124	copy: invalid destination object
125	copy: can't find destination object
126	copy: can't copy source object
127	copy: can't find source object
128	copy: stack is password protected
129	cos: error in source expression
130	cos: domain error
131	create: error in bad parent or background expression
132	create: error in name expression
133	create: error in file name expression
134	create: stack is locked (cantModify)
135	crop: error in image expression
136	crop: object is not an image
137	crop: error in rectangle expression
138	crop: expression is not a rectangle
139	cut: can't find or copy object
140	decompress: error in source expression
141	decompress: string is not compressed data
142	decompress: error during decompression
143	delete: error in file or url name expression
144	delete: can't find object
145	disable: can't find object
146	Stack: stack has not been given a file name
147	divide: error in matrix operation
148	divide: destination has a bad format (numeric?)
149	divide: error in source expression
150	divide: can't set destination
151	divide: can't divide scalar by array
152	divide: range error (overflow)
153	divide: divide by zero
154	Operators div: error in matrix operation
155	Operators div: error in left operand
156	Operators div: error in right operand
157	Operators div: can't divide scalar by matrix
158	Operators div: range error (overflow)
159	Operators div: divide by zero
160	do: aborted
161	do: error in source expression
162	do: error in statement
163	do: error in expression
164	do: error in language expression
165	do: unexpected end of line in source expression
166	do: can't find command
167	do: not a command
168	do: license limit exceeded
169	doMenu: error in expression
170	doMenu: don't know this menu item
171	drag: script aborted
172	drag: bad "button" number
173	drag: bad end point expression
174	drag: end point is not a point
175	drag: bad start point expression
176	drag: start point is not a point
177	driverNames: error in type expression
178	drives: error in type expression
179	edit: can't find object
180	encrypt: error in source expression
181	Operators =: error in operand
182	exp10: error in source expression
183	exp10: domain error
184	exp1: error in source expression
185	exp1: domain error
186	exp2: error in source expression
187	exp2: domain error
188	export: error in file (or mask file) name expression
189	export: can't open file (or mask file)
190	export: can't write to file, mask file, or container
191	export: no image selected, or image not open
192	export: selected object is not an image
193	Expression: error in numeric factor
194	Expression: error in string factor
195	exp: error in source expression
196	exp: domain error
197	extents: error in variable expression
198	Factor: error in left operand
199	Factor: error in right operand
200	Field: bad text attributes
201	Field: hilitedLine is not an integer
202	Field: scrollbarWidth is not an integer
203	Field: shift is not an integer
204	Field: tabstops is not a positive integer
205	files: no permission to list files or directories
206	filter: bad source string
207	filter: bad pattern string
208	filter: can't set destination
209	find: bad source string
210	flip: can't find image
211	flip: object is not an editable image
212	flushEvents: bad event type
213	focus: not a valid control
214	fontNames: error in type expression
215	fontSizes: bad font name
216	fontStyles: bad font name
217	fontStyles: bad font size
218	format: bad format string or parameter mismatch
219	Function: error in function handler
220	Function: error in source expression
221	Function: source is not a number
222	Function: is not a number
223	get: error in expression
224	get: can't set destination
225	globalLoc: coordinate is not a point
226	go: error in background expression
227	go: error in card expression
228	go: error in stack expression
229	go: error in window expression
230	go: can't attach menu to this object type
231	go: can't find destination
232	grab: can't find object
233	graphic: not an integer
234	Operators >=: error in operands
235	Operators >: error in operands
236	Group: backSize is not a point
237	Group: hilitedButton is not an integer
238	Group: bad object type
239	Operators (): error in right operand
240	Handler: aborted
241	Handler: error in statement
242	Handler: error in parameter expression
243	Handler: not a valid parameter index
244	hasMemory: bad amount expression
245	hide: error in visual effect expression
246	hide: can't find object
247	hostAddress: error in socket expression
248	hostAddressToName: error in address expression
249	hostName: error in name expression
250	hostNameToAddress: error in name expression
251	if-then: aborted
252	if-then: error in condition expression
253	if-then: error in statement
254	Image: bad pixmap id
255	Image: hotspot is not an integer
256	Image: id is not an integer
257	Image: id is already in use by another object
258	Image: image must be open to set id
259	Image: hotSpot x is not an integer
260	Image: hotSpot y is not an integer
261	import: error in expression
262	import: can't open file, mask file or display
263	import: can't read file, mask file or display
264	import: destination stack is locked (cantModify)
265	insert: can't find object
266	insert: license limit exceeded
267	intersect: two objects required
268	Operators is: error in left operand
269	Operators is: error in right operand
270	Operators is: can't compare operands
271	Operators is: left operand of 'within' is not a point
272	Operators is: right operand of 'within' is not a rectangle
273	isNumber: error in source expression
274	isoToMac: error source expression
275	Operators ,: error in left operand
276	Operators ,: error in right operand
277	keys: parameter is not a variable
278	kill: no such process
279	kill: bad number
280	launch: error in application expression
281	length: error in source expression
282	Operators <=: error in operands
283	Operators <: error in operands
284	ln1: error in source expression
285	ln1: domain error
286	ln: error in source expression
287	ln: domain error
288	load: error in url expression
289	load: error in message expression
290	localLoc: coordinate is not a point
291	log10: error in source expression
292	log10: domain error
293	log2: error in source expression
294	log2: domain error
295	longFilePath: error in file expression
296	macToIso: error source expression
297	mark: bad card expression
298	mark: error in find expression
299	matchChunk: can't set destination variable
300	matchChunk: bad or missing parameter
301	matchChunk: error in pattern expression
302	matchChunk: error in source expression
303	matrix: range error in matrix operation
304	matrixMultiply: error in source expression
305	matrixMultiply: can't multiply these arrays
306	max: error in source expression
307	MCISendString: error in source expression
308	MD5digest: error in source expression
309	median: error in source expression
310	merge: error in source expression
311	Operators -: can't subtract array from scalar
312	Operators -: error in left operand
313	Operators -: error in right operand
314	Operators -: range error (overflow) in array operation
315	Operators -: range error (overflow)
316	min: error in source expression
317	Operators mod: error in matrix operation
318	Operators mod: error in left operand
319	Operators mod: error in right operand
320	Operators mod: can't divide scalar by matrix
321	Operators mod: range error (overflow)
322	Operators mod: divide by zero
323	mouse: error in source expression
324	move: script aborted
325	move: can't find object
326	move: bad end point expression
327	move: bad duration expression
328	move: duration is not a number
329	move: end point is not a point
330	move: bad start point expression
331	move: start point is not a point
332	multiply: error in matrix operation
333	multiply: destination has a bad format (numeric?)
334	multiply: error in source expression
335	multiply: can't set destination
336	multiply: can't multiply scalar by array
337	multiply: range error (overflow)
338	Operators <>: error in operands
339	Operators not: error in right operand
340	Operators bitNot: error in right operand
341	numToChar: error in source expression
342	Object: bad textAlign expression
343	Object: unknown color
344	Object: error in colors
345	Object: can't set layer (card not open, or control in group)
346	Object: not a textStyle
347	Object: stack locked, or object's script is executing
348	Object: object does not have this property
349	Object: height is not an integer
350	Object: layer is not an integer
351	Object: margin is not an integer
352	Object: value is not a boolean (true or false)
353	Object Name:
354	Object: property is not an integer
355	Object: coordinate is not a point
356	Object: rectangle does not have 4 points
357	Object: no Home stack
358	Object: pixel value is not an integer
359	Object: pixmap is not an integer
360	Object: can't set script while it is executing
361	Object: can't set this property
362	Object: textheight is not an integer
363	Object: textsize is not an integer
364	offset: error in start offset expression
365	offset: error in part expression
366	offset: error in whole expression
367	open: error in message expression
368	open: error in name expression
369	open: no permission to open files or processes
370	Operators or: error in left operand
371	Operators or: error in right operand
372	Operators bitOr: error in left operand
373	Operators bitOr: error in right operand
374	Operators /: error in matrix operation
375	Operators /: error in left operand
376	Operators /: error in right operand
377	Operators /: can't divide scalar by matrix
378	Operators /: range error (overflow)
379	Operators /: divide by zero
380	param: error in expression
381	param: bad parameter index
382	param: error in source expression
383	param: is not a number
384	paste: stack is locked (cantModify)
385	peerAddress: error in socket expression
386	place: group is not in this stack or is already on this card
387	place: can't find group
388	place: can't find card
389	place: source is not a group, or cannot be used as a background
390	place: destination is not a card
391	play: can't get sound or movie name
392	play: bad movie location
393	play: bad movie options
394	Operators +: error in left operand
395	Operators +: error in right operand
396	Operators +: range error (overflow)
397	pop: can't set destination
398	post: can't get source
399	post: can't get destination
400	pow: error in left operand
401	pow: error in right operand
402	pow: range error (overflow)
403	print: can't get 'from' or 'to' coordinates
404	print: can't get number of cards
405	print: can't get rectangle
406	print: error printing
407	print: error writing file (disk full?)
408	print: coordinate not a point
409	print: expression is not a rectangle
410	print: not a card
411	print: card or stack must be open to print it
412	print: no card specified
413	arcAngle: not an integer
414	blinkRate: not a number
415	penColor: bad color
416	colormap: bad color name or value
417	Object: error counting objects as number
418	Object: error counting objects as text
419	dragSpeed: not a number
420	effectRate: not a number
421	extendKey: not a number
422	Property: bad array expression
423	gridSize: not an integer
424	idleRate: not a number
425	lineSize: not an integer
426	moveSpeed: not a number
427	multiSpace: not a number
428	polySides: not an integer
429	repeatDelay: not a number
430	repeatRate: not a number
431	doubleClickDelta: not an integer
432	doubleClickTime: not a number
433	roundRadius: not an integer
434	slices: not an integer
435	startAngle: not an integer
436	traceDelay: not a number
437	traceStack: not a stack name
438	print: bad property value
439	syncRate: not a number
440	tooltipDelay: not a number
441	typeRate: not a number
442	userLevel: not an integer
443	beep: not an integer
444	brush: not an integer
445	brush: can't find image
446	brushPattern: not a valid image id
447	brushPattern: can't find image
448	Object: no object to set property
449	Object: can't set object property
450	cursor: not an integer
451	cursor: can't find image
452	Property: value is not a boolean ("true" or "false")
453	Property: value is not a number
454	defaultStack: can't find stack
455	defaultMenuBar: can't find group
456	Object: does not have this property
457	Object: property is not an integer
458	penPattern: not a valid image id
459	penPattern: can't find image
460	randomSeed: property is not an integer
461	socketTimeout: not a number
462	umask: property is not an integer
463	push: object is not a card
464	push: can't find card
465	put: error in expression
466	put: can't set destination
467	put: can't put into destination
468	queryRegistry: error in source expression
469	random: error in source expression
470	read: aborted
471	read: error in 'at' expression
472	read: error in condition expression
473	read: error in count expression
474	read: error reading
475	read: count is not an integer
476	read: error in 'until' expression
477	read: file is not open
478	read: error in 'for' expression
479	read: process is not open
480	record: error in file expression
481	recordCompression: type must be 4 characters
482	recordInput: type must be 4 characters
483	remove: can't find object
484	remove: object is not a group
485	remove: object is not a card
486	rename: error in source expression
487	rename: error in destination expression
488	repeat: aborted
489	repeat: error in 'for' condition expression
490	repeat: error in statement
491	repeat: error in 'until' condition expression
492	repeat: error in 'while' condition expression
493	repeat: error in 'with' end condition expression
494	repeat: error in 'with' start condition expression
495	repeat: error in 'with' step condition expression
496	repeat: error setting 'with' variable
497	replace: can't set container
498	replace: error in pattern expression
499	replace: error in replacement expression
500	replace: error in container expression
501	replaceText: bad parameter
502	replaceText: bad source string
503	reply: error in keyword expression
504	reply: error in message expression
505	request: error in keyword expression
506	request: error in message expression
507	request: error in program expression
508	request: no permission to request that
509	getResources: error in expression
510	getResources: no permission to get that
511	return: error in expression
512	revert: can't revert Home stack
513	rotate: error in object expression
514	rotate: object is not an editable image
515	rotate: error in angle expression
516	round: error in source or digit expression
517	save: error in file name expression
518	save: saving disabled
519	save: can't find stack to save
520	save: object is not a stack
521	seek: error in file name expression
522	seek: error in offset expression
523	seek: file is not open
524	select: can't select target
525	selectedChunk: error in button or field expression
526	selectedButton: bad family expression
527	selectedButton: bad parent object expression
528	send: error in message handler execution
529	send: error in message expression
530	send: error in 'in' expression
531	send: error in program expression
532	send: bad target expression
533	send: no permission to send that
534	set: error in source expression
535	set: can't set property
536	setRegistry: no permission to get or set registry
537	setRegistry: error in source expression
538	shell: aborted
539	shell: can't run shell command
540	shell: error in source expression
541	shell: no permission to run commands
542	shortFilePath: error in file expression
543	show: error in visual effect expression
544	show: error in location expression
545	show: error in number of cards expression
546	show: location is not in proper x,y form
547	show: can't find object
548	sin: error in source expression
549	sin: domain error
550	sort: can't find object to sort
551	sort: error sorting
552	sort: can't find field
553	specialFolderPath: error in type expression
554	sqrt: error in source expression
555	sqrt: domain error
556	Stack: bad decoration
557	Stack: invalid id (must be greater than current id)
558	Stack: invalid key
559	Stack: bad substack name
560	Stack: can't set mainStack (has substacks?)
561	Stack: deskIcon is not an integer
562	Stack: userLevel is not an integer
563	Stack: size is not an integer
564	Stack: stack is password protected
565	Stack: can't find mainStack
566	Stack: stack is not a mainStack
567	Stack: error in external function handler
568	start: can't find object
569	start: stack is locked
570	start: expression is not a group
571	start: license limit exceeded
572	Handler: error in source expression
573	Handler: can't find handler
574	stdDev: error in expression
575	stop: error in expression
576	stop: target is not a group
577	subtract: error in matrix operation
578	subtract: destination has a bad format (numeric?)
579	subtract: error in source expression
580	subtract: can't set destination
581	subtract: can't subtract array from scalar
582	subwindow: error in expression
583	subwindow: can't find stack or button
584	sum: error in source expression
585	switch: error in condition expression
586	switch: error in case expression
587	switch: error in statement
588	textHeightSum: can't find object
589	tan: error in source expression
590	tan: domain error
591	there: error in source expression
592	throw: error in source expression
593	Operators *: error in matrix operation
594	Operators *: error in left operand
595	Operators *: error in right operand
596	Operators *: range error (overflow)
597	toLower: error in source expression
598	topStack: error in source expression
599	toUpper: error in source expression
600	transpose: source is not a variable
601	transpose: can't transpose this array
602	trunc: error in source expression
603	try: error in statement
604	type: script aborted
605	type: bad string expression
606	ungroup: can't find group
607	ungroup: target is not a group
608	uniDecode: error in language expression
609	uniDecode: error in source expression
610	uniEncode: error in language expression
611	uniEncode: error in source expression
612	unload: error in url expression
613	unlock: expression is not a visual effect
614	urlDecode: error in source expression
615	urlEncode: error in source expression
616	urlStatus: error in url expression
617	value: error in source expression
618	value: error executing expression
619	value: can't find object
620	Array: bad index expression
621	Chunk: source is not a character
622	Chunk: source is not a number
623	visual: bad effect expression
624	wait: aborted
625	wait: error in expression
626	wait: expression is not a number
627	within: can't find control
628	within: not a point
629	write: error in expression
630	Operators bitXor: error in left operand
631	Operators bitXor: error in right operand
632	Property stackFileVersion: not a valid version
633	Property stackFileVersion: version not supported
634	External handler: exception
635	export: Empty rectangle
636	import: Empty rectangle
637	Property dragAction: Unknown action
638	Property dragImageOffset: Not a point
639	Property dragDelta: Not a number
640	clipboard: invalid mix of data types
641	clipboard: invalid text
642	wrap: bad array
643	wrap: illegal type for left operand
644	wrap: illegal type for right operand
645	wrap: type mismatch
646	wrap: overflow
647	wrap: division by zero
648	begins/ends with: illegal type for right operand
649	begins/ends with: illegal type for left operand
650	load extension: bad filename
651	UNUSED
652	UNUSED
653	UNUSED
654	UNUSED
655	UNUSED
656	UNUSED
657	UNUSED
658	graphic: not a boolean
659	graphic: bad fill rule
660	graphic: bad gradient type
661	graphic: bad gradient ramp
662	graphic: bad gradient point
663	graphic: bad gradient quality
664	graphic: bad gradient key
665	graphic: bad cap style
666	graphic: bad join style
667	byteToNum: bad expression
668	numToByte: bad expression
669	arrayEncode: bad expression
670	arrayEncode: failure
671	arrayDecode: bad expression
672	arrayDecode: failure
673	parentScript: bad object
674	dispatch: bad message
675	dispatch: bad command
676	dispatch: bad target
677	queryRegistry: bad destination
678	parentScript: loop in hierarchy
679	Security: disk access not allowed
680	Security: network access not allowed
681	Security: external command access not allowed
682	Security: registry access not allowed
683	
684	Security: printer access not allowed
685	Security: audio and camera access not allowed
686	
687	
688	
689	
690	
691	
692	
693	
694	
695	
696	Security: AppleScript access not allowed
697	Security: alternate script execution not allowed
698	processType: bad value
699	processType: cannot change
700	
701	
702	do in browser: not supported
703	do in browser: failed
704	editMode: Bad value
705	export: Bad palette
706	export: Invalid palette size
707	printing: Bad options array
708	
709	printing: Unknown destination
710	object: cannot change id while in group edit mode
711	print: bad anchor name
712	print: bad anchor location
713	print: anchor location not a point
714	print: bad link destination
715	print: bad link area
716	print: link area not a rectangle
717	randomBytes: bad count
718	sha1Digest: bad source
719	stackLimit: not a number
720	could not load security library
721	group: cannot be background or shared (it is nested)
722	group: must be shared (it is placed on more than one card, or unplaced)
723	group: cannot group background or shared groups
724	print: bad bookmark title
725	print: bad bookmark level
726	print: bad bookmark position
727	print: bad bookmark initial state
728	Script File Index:
729	include: could not find file
730	script: parsing error
731	script: bad statement
732	include: not supported in this environment
733	include: bad filename
734	include: nesting depth limit reached
735	require: not supported in this environment
736	
737	
738	errorMode: bad value
739	outputEncoding: bad value
740	outputLineEnding: bad value
741	Script Error Position:
742	defaultNetworkInterface: network interface must be an IPv4 address
743	layerMode: must be 'static', 'dynamic' or 'scrolling'
744	tileSize: must be a power of two between 16 and 256
745	tileCompositor: unknown type
746	tileCompositor: not supported on this platform
747	intersects: error in threshold expression
748	intersects: threshold must be a non-negative number, "bounds", "pixels" or "opaque pixels"
749	session: not supported in this environment
750	sessionSavePath: bad value
751	sessionLifetime: bad value
752	sessionName: bad value
753	sessionId: bad value
754	lock: bad rect expr
755	lock: not a rectangle
756	field: bad listStyle value
757	field: firstIndent must be an integer
758	field: leftIndent must be an integer
759	field: rightIndent must be an integer
760	field: spaceBefore must be an integer
761	field: spaceAfter must be an integer
762	field: listDepth must be an integer between 1 and 16.
763	field: borderWidth must be an integer
764	field: listIndent must be an integer
765	field: padding must be an integer
766	Chunk: can't store unicode to destination container
767	relayer: target not a container
768	relayer: couldn't resolve target object
769	relayer: couldn't resolve source control
770	relayer: source not a control
771	relayer: source and target not on the same card
772	relayer: layer not an integer
773	relayer: bad layer expression
774	relayer: target not a control
775	relayer: cannot move a control into a descendent
776	relayer: required objects disappeared while processing
777	controlAtLoc: location not a point
778	do: no caller
779	read: invalid command for datagram socket
780	field: listIndex must be an integer
781	image cache limit: not a number
782	controls don't have the same owner
783	uuid: bad type expression
784	uuid: wrong number of arguments for specified type
785	uuid: unsupported type
786	uuid: bad namespace expression
787	uuid: namespace not a uuid
788	uuid: bad name expression
789	uuid: not enough randomness available
790	avgDev: error in source expression
791	geometricMean: error in source expression
792	harmonicMean: error in source expression
793	pStdDev: error in source expression
794	pVariance: error in source expression
795	variance: error in source expression
796	group: object cannot be grouped
797	measureText: no object
798	font: couldn't find font
799	edit script: bad at expression
800	fullscreenmode: not a valid mode
801	pixelScale: not a valid scale value
802	scaleFactor: not a valid scale value
803	pixelScale: the pixelScale property cannot be set on this platform
804	usePixelScaling: the usePixelScaling property cannot be set on this platform
805	secure: error in socket expression
806	paramCount: could not find handler

TUTORIAL 01 – “Hello World!” – Il nostro primo programma

Informazioni preliminari

In questo tutorial vedremo come scaricare ed installare LiveCode. Inoltre scriveremo il nostro primo programma con questo nuovo sistema di sviluppo!

Esistono due versioni di LiveCode: una gratuita ed una a pagamento. Entrambi le potete trovare a questo indirizzo:

http://livecode.com

La versione gratuita, chiamata Community Edition, scaricabile QUI differisce da quella a pagamento per diversi elementi (confronto delle edizioni):

  1. I programmi sviluppati con la community edition dovranno essere rilasciati sotto licenza GPL.
  2. La loro distribuzione (deploy) dovrà avvenire per canali compatibili con suddetta licenza
  3. Può essere usato da un numero illimitato di programmatori (seats)
  4. Il supporto tecnico è limitato al forum
  5. Non c’è alcun supporto tecnico da parte dell’azienda produttrice di LiveCode.

Essa comunque è ottima sia per sviluppare prodotti GPL sia per imparare l’uso del prodotto stesso.

L’ambiente di sviluppo

LiveCode è composto da diverse finestre, ognuna delle quali con un compito specifico:

Livecode: Panoramica ambiente di sviluppo
Livecode: Panoramica ambiente di sviluppo

A sinistra abbiamo i TOOLS, cioè gli strumenti che utilizzeremo per creare le nostre form (le maschere per inserimento e visualizzazione dati). In alto si trova il PANNELLO PRINCIPALE. Da esso si possono poi richiamare gli altri strumenti. A destra abbiamo il PROJECT BROWSER: esso mostrerà i dettagli di ogni singola schermata (form) che prepareremo. Mostrerà gli oggetti immessi nelle form in forma gerarchica (stack, card, gruppi).

Ogni programma LiveCode usa il concetto di stackcard. Uno STACK altro non è che una form, una finestra. Mentre possiamo pensare alle CARD come a pagine di un libro: una serie di fogli posti uno sopra l’altro, delle stesse dimensioni dello stack che le contiene (in questo caso potremmo pensare allo stack come alla copertina del libro). Ecco un grafico che mostra la struttura di stack e card:

livecode_structureIl MAIN STACK è lo stack principale: è la finestra principale dell’intera applicazione. Esiste un solo MAIN STACK per ogni applicazione creata. Ogni MAIN STACK può contenere diversi SUB-STACK (sotto-finestre).

Ogni stack, in generale, contiene una o più card: ogni stack contiene almeno una card. Noi inseriremo i componenti (pulsanti, campi di inserimento, liste, etc… tutte all’interno di una card).

Il nostro primo programma!

Compresa la struttura di LiveCode, iniziamo allora con il creare uno stack principale, un MAIN STACK. Si deve andare sul menu File e scegliere l’opzione NEW MAIN STACK:

screen02

 

Nella form che è apparsa, trasciniamo (drag and drop) un pulsante (push-button) dai TOOLS al centro della form appena creata:

screen03

Abbiamo creato il nostro primo pulsante (oggetto)!

Ogni elemento visuale (pulsanti, aree per inserimento testo, griglie per mostrare dati in righe e colonne, etc…) sono chiamati oggetti: essi hanno caratteristiche uniche, che noi potremo manipolare modificando le loro proprietà (testo mostrato, colore, dimensioni, etc…).

Ora selezioniamo il pulsante appena creato (con il mouse clicchiamoci sopra): apparirà attorno ad esso una “cornicetta” con dei quadratini (quello indica che la selezione è avvenuta nel modo corretto). Una volta fatto ciò, nella barra in alto clicchiamo su Code (edit script). In questo modo apriremo l’editor per scrivere il nostro primo programma:

screen04

LiveCode crea un handler, cioè una specie di funzione, preceduta dalla parola on (nel nostro caso si chiama mouseUp), che verrà eseguita ogni volta che un utente clicca sul pulsante. Scriviamo il seguente codice:

on mouseUp
    answer “Hello world!”
end mouseUp

 

Una volta scritto il codice, premiamo il pulsante “Apply”, così LiveCode compilerà il programma, e controllerà se nel codice scritto ci siano eventuali errori. Se tutto andrà bene, la “lucetta” gialla diventerà verde, e noi saremo pronti ad eseguire la nostra prima applicazione!

screen05

Chiudiamo la finestra del codice, e selezioniamo il tool che LiveCode chiama:
Run (browse) Tool

In questo modo lasceremo la modalità Edit (pointer) Tool, cioè la modalità di modifica:

screen06

 

Infine, premendo il pulsante Button appena creato vedremo il risultato delle nostre fatiche!

screen07

Un box apparirà sul video con la scritta Hello World!

Conclusioni

Il nostro primo tutorial finisce qui. Abbiamo fatto una panoramica sull’ambiente di sviluppo, sfiorando diversi argomenti.

LiveCode è un sistema completo, adatto sia a chi si avvicina per la prima volta ad un linguaggio di programmazione sia per utenti esperti: permette lo sviluppo di programmi su Windows, Mac, Linux, IOS, Android e Windows Phone. Ci si possono creare giochi, applicazioni per la gestione di database, sistemi client/server, rich-clients, pannelli per il controllo di dispositivi elettronici, e molto altro ancora. Il suo linguaggio di programmazione, simile all’inglese scritto (lo vedremo nei prossimi tutorial) è semplice ma completo, forse un po’ prolisso, ma con alcune caratteristiche difficilmente riscontrabili in altri linguaggi.

Vi aspetto per il prossimo tutorial! Se avete domande o volete chiarimenti scrivete un commento, e cercherò di aiutarvi al meglio delle mie possibilità!

A presto!

 

Conversioni decimale-esadecimale-binario

Per convertire da una base ad un’altra esiste la comoda funzione baseConvert(). Con essa si puo` convertire da qualunque base a qualunque altra!

 

Converte il numero “11” da decimale (base 10) a binario (base 2).

Potete provare questi comandi nel tool “message” anteponendo la parola “put” davanti ai comandi: put baseConvert(16,10,2)

put baseConvert(11,10,2) into message

 

 

Mette il risultato della funzione “baseConvert()” nella variabile “it”

get baseConvert(11,10,2)

 

 

Converte il numero “11” da decimale a esadecimale

get baseConvert(11,10,16)

 

 

Converte il numero “11” da binario ad ottale e mette il risultato nella variabile “myConvertedValue”

put baseConvert(11,2,8) into myConvertedValue

 

Scaricare pagine web ed altro da internet

Scarica la pagina HTML e la memorizza nella variabile “it”

 

 

Scarica l’immagine “livecode_logo.png”, la memorizza in “it”
A questo punto il contenuto di “it” viene salvato in un file locale in formato binario