You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

nosferatu

Trainee

  • "nosferatu" started this thread

Posts: 80

Location: Ukraine

  • Send private message

1

Thursday, September 5th 2013, 3:27am

Out of the loop

Hi Klaus!
Why in krpano no escape of the loop?
I can stop the cycle only through interaction with the user.
And it only works if the loop "asyncfor"
Is it possible some decision early exit without interaction?

Source code

1
2
3
4
5
6
7
8
<events onmousedown="breakall();" />

<action name="test">
    asyncfor(set(i,0), i LT 200, inc(i),
      trace('i = ', i);
      if(i GT 10, breakall()); // does not work
    );
</action>


Sorry for the many questions!
Thank you!

nosferatu

Trainee

  • "nosferatu" started this thread

Posts: 80

Location: Ukraine

  • Send private message

2

Thursday, September 5th 2013, 7:51am

I have found a workaround.
But Is there a more native way?

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<action name="test">
    showlog();
    asyncfor(set(i,0), i LT 20, inc(i),
      if(i == 10, js(pass()); );	  
      trace('i = ', i);
    );
</action>
----------
<script>
    function pass() {
      krpano().call("breakall();");
    }
</script>

This post has been edited 1 times, last edit by "nosferatu" (Sep 5th 2013, 8:30am)


Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

3

Monday, September 9th 2013, 1:40am

Use a second action to check if a variable has been set.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

nosferatu

Trainee

  • "nosferatu" started this thread

Posts: 80

Location: Ukraine

  • Send private message

4

Monday, September 9th 2013, 7:03am

Use a second action to check if a variable has been set.

sachagriffin, thanks for the reply!
Can you write an example?
I do not quite understand...

Thank You!

nosferatu

Trainee

  • "nosferatu" started this thread

Posts: 80

Location: Ukraine

  • Send private message

5

Saturday, September 14th 2013, 11:42pm

Who can comment on this.
Why it does not work?

Source code

1
if(i == 10, breakall());

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

6

Sunday, September 15th 2013, 12:36am

Because those are queued actions. You need stopall()

http://krpano.com/docu/actions/#breakall

http://krpano.com/docu/actions/#stopall
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

nosferatu

Trainee

  • "nosferatu" started this thread

Posts: 80

Location: Ukraine

  • Send private message

7

Sunday, September 15th 2013, 8:45am

sachagriffin sorry, but it does not work:

Source code

1
2
3
4
5
showlog();
asyncfor(set(i,0), i LT 50, inc(i),
  if(i == 20, stopall());
  trace('i = ', i);
);

stopall() and breakall() do not work inside the loop.
Only through

Source code

1
krpano().call("breakall();");

Unfortunately there is no information about the syntax breakall and stopall.
Could you bring the right example?
Thank you!

8

Monday, September 16th 2013, 5:29pm

Hi,

sorry, neither stopall nor breakall are indented to work for asyncfor or asyncloop.
The next loop call will be added to the internal queue after executing the inner code, so it can't be removed by any of these calls.

I would recommend using a 'stop' condition, e.g. in your case set 'i' to 50 to stop the loop.

Alternatively a - delayedcall(0,breakall()); - might also work, but the 'stop condition' would be the better solution.

Best regards,
Klaus

nosferatu

Trainee

  • "nosferatu" started this thread

Posts: 80

Location: Ukraine

  • Send private message

9

Monday, September 16th 2013, 7:43pm

Klaus, thank you!
This works fine *smile*

Source code

1
2
3
4
5
showlog();
asyncfor(set(i,0), i LT 50, inc(i),
  trace('i = ', i);
  if(i == 20, set(i,50));
);

Is there any future plans to implement a function to break cycle in krpano, as in JavaScript?

10

Tuesday, September 17th 2013, 3:05pm

Is there any future plans to implement a function to break cycle in krpano, as in JavaScript?
Yes, there are already plans for a completely new and more functional actions-system, but that's more something for 'krpano 2.0' or so. The whole action system is internally only one single module which could be optionally (e.g. for version=2.0 in the xml) swapped-out to a newer one (with slightly different syntax and keywords), and this is what is planed for future version.

Extending the current action system with more basic functionality is a bit difficult, because in such case it's almost impossible to keep the compatibility with the current actions-codes. Therefore a new actions system with new own rules would be probably the better solution. But more about this when that would be ready, that will probably still need some time.

Best regards,
Klaus

nosferatu

Trainee

  • "nosferatu" started this thread

Posts: 80

Location: Ukraine

  • Send private message

11

Tuesday, September 17th 2013, 7:53pm

Oh, that's great!! *rolleyes* *w00t* *squint*