Sie sind nicht angemeldet.

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