Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

jordi

Profi

  • »jordi« ist der Autor dieses Themas

Beiträge: 583

Wohnort: Barcelona

Beruf: creating ideas & coding them

  • Nachricht senden

1

Samstag, 15. Juli 2017, 02:18

; syntax issue

I just recognised that sometimes (calc) we have to use ; mandatory

like in this case, where that would work :

Quellcode

1
2
3
set(myOtherVar, 10);
if(%1 !== null, calc(myVar, %1 + myOtherVar); );
debug('myVar value', myVar);


and that would not :

Quellcode

1
2
3
set(myOtherVar, 10);
if(%1 !== null, calc(myVar, %1 + myOtherVar));
debug('myVar value', myVar);


With set and other actions you can just skip these "extra" semicolon, am I right ?
everpano.com step beyond 360

2

Samstag, 15. Juli 2017, 23:22

Hi,

yes, when no action call is following the ';' at the end of the action is optional.

That means both of your code examples would work.

Best regards,
Klaus

jordi

Profi

  • »jordi« ist der Autor dieses Themas

Beiträge: 583

Wohnort: Barcelona

Beruf: creating ideas & coding them

  • Nachricht senden

3

Donnerstag, 27. Juli 2017, 13:26

I know, but just copy and execute my code and you will see that not both of them work... in 1.19-pr0
everpano.com step beyond 360

4

Mittwoch, 2. August 2017, 21:33

Hi,

that's different reason / special case here - calc(...) (without the ';') has a special meaning when used as parameter - please see here:
https://krpano.com/docu/actions/#calc

In this case (without ';'):

Quellcode

1
if(%1 !== null, calc(myVar, %1 + myOtherVar));
it would be that situation - using calc() to resolve a parameter (the parameter of the if() action):

Quellcode

1
action( calc(expression), ... )
and 'myVar, %1 + myOtherVar' would be an invalid expression - mainly because of the ',' character.

But in this case (with the ';'):

Quellcode

1
if(%1 !== null, calc(myVar, %1 + myOtherVar););
it would be that situation - that means a normal action call:

Quellcode

1
calc(variable, expression)
and therefore this case is working.

That means it works basically as intended but I agree that can be confusing ;-).

Best regards,
Klaus