Sie sind nicht angemeldet.

1

Montag, 17. September 2012, 11:11

Using txtadd with multiple text parameters in "for" loop

Hi!
I try to adding text to a variable int "for" by get an empty result if using multiple text parameters: txtadd(destination,txt1,txt2,txt3,...)
Example:
set(media_list,'');
for(set(i,0), i LT skin_media_list.count, inc(i),
txtadd(media_list, get(i), '. ', get(skin_media_list[get(i)].name), '<br />');
);
copy(layer[skin_media].html, media_list);

But if I write such manner (single text parameter), there is concatenated string in results:
set(media_list,'');
for(set(i,0), i LT skin_media_list.count, inc(i),
txtadd(media_list, get(i));
txtadd(media_list, '. ');
txtadd(media_list, get(skin_media_list[get(i)].name));
txtadd(media_list, '<br />');
);
copy(layer[skin_media].html, media_list);

Help me, please, what's wrong?

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

2

Montag, 17. September 2012, 11:48

first try instead of:

set(media_list,'');

set(media_list, );

Tuur *thumbsup*

3

Montag, 17. September 2012, 14:07

Tuur, thanx for your answer. But unfortunately I got the same results :(
Even if I remove this string away, the results does not change!

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Yren« (18. September 2012, 06:52)


4

Mittwoch, 19. September 2012, 16:19

Hi,

here an example that should explain how the txtadd() action works:when using this is the code:
txtadd(destination, txt1, txt2, txt3)
;

it means that:
destination = txt1 + txt2 + txt3

the txt1 and txt2 and txt3 will be connected, added together and then saved into the destination variable,


that means further, when you want to add text to destination variable itself, you need to use the content of the destination variable as parameter,

e.g. to add additional text to the destination variable :
txtadd(destination, get(destination), txt2, txt3);


in your case this would be:
txtadd(media_list, get(media_list), get(i));
txtadd(media_list, get(media_list), '. ');
txtadd(media_list, get(media_list), get(skin_media_list[get(i)].name));
txtadd(media_list, get(media_list), '<br />');


Best regards,
Klaus

5

Mittwoch, 2. September 2020, 12:03

this construction in not work ((( :
for examle %1=1 (and <data name="question1" answered="0">'test question'</data>)

txtadd(question_nm, 'data:question', %1);
txtadd(question_nm, get(question_nm), 'aaaa', 'bbb');


set(layer['question_text'].html, get(question_nm)); - is not work((

i have data:question1aaaabbb instead "test questionaaaabbbbb"


what am I doing wrong? thank!

6

Mittwoch, 2. September 2020, 12:31

if %1 is "1" :
txtadd(question_nm, get(data[calc("question" + "%1")].content), 'aaaa', 'bbb');
txtadd(question_nm, get(data[question%1].content), 'aaaa', 'bbb'); // maybe works, too

if %1 is "question1" :
txtadd(question_nm, get(data[%1].content), 'aaaa', 'bbb');

documentation :
https://krpano.com/docu/xml/#data

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

7

Mittwoch, 2. September 2020, 12:44

perhaps like this works too.
untested.

calc(question_nm, data[question%1].content + 'aaaa' + 'bbb');

or

calc(question_nm, data[%1].content + 'aaaa' + 'bbb');

Tuur *thumbsup*

8

Mittwoch, 2. September 2020, 20:01

solved! )
txtadd(question_ans, 'data[question', %1,'_ans',get(i),'].content');

9

Mittwoch, 2. September 2020, 20:09

...and new problem((

I have array:
currq_array[1].value='test value1'
currq_array[2].value='test value2'
...
this expression:
1) trace('test value=',get(currq_array[get(i)].value)); - returns a correct "test value1", "test value2"...
and
2) txtadd(newtext, get(currq_array[get(i)].value));
set(layer['question_text'].html, get(newtext));
returns to layer "data.content"

the mind does not understand why so ??? *confused* *blink*

help who knows please!

10

Mittwoch, 2. September 2020, 22:57

txtadd(a, get(b));
makes no sense, you're not adding anything :)

for this you could simply use
copy(a, b);

also this
txtadd(newtext, get(currq_array[get(i)].value));
set(layer['question_text'].html, get(newtext));
is too complicated.

the same is done much easier with
copy(layer[question_text].html, currq_array[get(i)].value);

study:
https://krpano.com/docu/actions/#set
https://krpano.com/docu/actions/#get
https://krpano.com/docu/actions/#copy
https://krpano.com/docu/actions/#calc

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »indexofrefraction« (2. September 2020, 23:11)


11

Donnerstag, 3. September 2020, 09:48

many thanks! You helped me a lot!
now it works !!
SOLVED!
Result:
copy(tmp, get(currq_array[get(i)].value));
txtadd(newtext, get(tmp));

Ähnliche Themen