Sie sind nicht angemeldet.

1

Samstag, 26. April 2014, 15:43

OOP style scripting in KRPano

Hi, everyone.
I found a way how to write Object Oriented Programing style in KRPano script.
This is just for fun.

----------
<pre>

Quellcode

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
<krpano version="1.16" onstart="startup();">

	<!-- class difinition -->
	<class name="test"
		property="123"
		action="trace('action called:', %1 );"
	/>
	
	<action name="startup">
		showlog();
		
		<!-- create instances -->
		copy( instance1.property, class['test'].property );
		copy( instance2.property, class['test'].property );
		copy( instance1.action, class['test'].action );
		copy( instance2.action, class['test'].action );

		<!-- set values to each property -->
		set( instance1.property, 'def' );
		set( instance2.property, 'ghi' );

		<!-- call each method -->
		instance1.action( instance1.property );
		instance2.action( instance2.property );
	</action>

</krpano>

</pre>


----
bye

jordi

Profi

Beiträge: 583

Wohnort: Barcelona

Beruf: creating ideas & coding them

  • Nachricht senden

2

Samstag, 26. April 2014, 15:51

Nice !!!
everpano.com step beyond 360

3

Samstag, 26. April 2014, 16:01

This is not so beautiful code.
Especially 'creating new instance' will be better.

At first, I wrote
copy( instance1, class['test'] );
copy( instance2, class['test'] );

But this isn't work.Because this copy worked as reference ( not deep copy ).

>Klaus
Could you please add new commands like 'new' and 'this' ?
(just joking. I think there are more important wishes from users.)