Sie sind nicht angemeldet.

1

Dienstag, 2. Januar 2018, 11:25

Help~About array operation

Hi, i have a question about array operation:

Quellcode

1
2
3
4
5
def(arr,array);
def(arr[0],string,"value1");def(arr[1],string,"value2");
trace(arr.length); <!--here always return "1"--> 
trace(arr[0]); <!--here always return the last value: "value2"--> 
trace(arr[1]); <!--here always return the last value: "value2"-->


is it my problem?


thx

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »boxui« (2. Januar 2018, 11:46)


2

Dienstag, 2. Januar 2018, 12:21

Have you tried with ' instead of "? def(s, string, 'text');
See Example here

3

Dienstag, 2. Januar 2018, 12:27

for arrays you always construct elements like
<element name="name" propery="something" />

for property you often use value,
because also txtsplit() creates arrays with this property

set(arr[0].value, 'value1');
set(arr[1].value, 'value2');
debug(arr.count); <!-- 2 -->

maybe this works, too:
def(arr[0].value, string, "value1");
def(arr[1].value, string, "value2");
debug(arr.count); <!-- 2? i never use this syntax -->

or
txtsplit('value1|value2', '|', arr);
debug(arr.count); <!-- 2 -->

note: any array element can have multiple props
set(arr[0].value, 'value1');
set(arr[0].note, 'this is a nice value');
set(arr[0].align, left);
debug(arr.count); <!-- 1 -->

ps result is:
<arr name="0" value="value1" note="this is a nice value" align="left" />

pps..
arr[0] is an object containing all properties!
you can explore with
debugvar(arr);
debugvar(arr[0]);
debugvar(arr[0].value);

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »indexofrefraction« (2. Januar 2018, 12:39)


4

Dienstag, 2. Januar 2018, 17:28

is it my problem?
That code should work!
Is your krpano version up-to-date? (1.19-pr14)

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

5

Dienstag, 2. Januar 2018, 19:26

That code should work!
Is your krpano version up-to-date? (1.19-pr14)
I confirm that it works on pr14 on my PC.


Piotr
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*