Increment In Advanced Actions

August 9, 2018
Officer / Course Developer for Federal Law Enforcement Agency
Guide 9 posts
Followers: 0 people
UX Designer
10

Increment In Advanced Actions

Officer / Course Developer for Federal Law Enforcement Agency
Guide 9 posts
Followers: 0 people
August 9, 2018

I have built an advanced action that uses a variable to change the state of a shape and to hide/show some links based upon the value of the variable.  The advanced action is executed each time the “Continue” button is selected.

The variable (v_introCntr) starts with a value of 0 and the first action in the Advanced Action increments the variable by 1.  From there I have a series of “If” statements that check the value of the variable and are supposed to execute the corresponding actions accordingly.  The problem is that the only result I’m seeing is the last action…the value of v_introCntr seems to keep incrementing up until it hits 15 and then the corresponding states & hide/shows for 15 are displayed.

It’s not executing any of the other actions….I added some test variables in there just to see and they aren’t effected.

Here’s what my Adv Actions looks like:

Thanks in advance for any help you can provide.  This one is driving me crazy!

Jay

Comments (10)
2018-08-10 15:26:08
2018-08-10 15:26:08

I have requested in the past a <break> type action. I would love to see it in the next version of Captivate. By <break> I mean that when going along a series of conditions in an advanced action, that we can add a <break> when we have met a condition and don’t want to continue checking subsequent conditions. This would allow us to avoid using silly solutions like creating a variable just to stop checking.

Like
(1)
(1)
>
Joe S Ganci
's comment
2018-08-10 21:26:21
2018-08-10 21:26:21
>
Joe S Ganci
's comment

Agree partially, Joe, but that could be an added difficulty for most users to understand what ‘break’ means. Most cases like this can be solved without that ‘break’. It is question of balance: keep advanced actions as simple as possible or add more functionality like you find in a real programming language?

Like
2018-08-10 08:07:20
2018-08-10 08:07:20

A usual problem I see often on the forums is due to an important difference between a programming script and advanced actions.  You cannot ‘break out’ of an advanced action, every decision and every command will always be evaluated in the strict sequence: from top to bottom and (for decisions) from left to right.  Changing the sequence can sometimes fix this, as I illustrated in this very old post where a wrong sequence and/or ignorance of that behavior caused problems:http://blog.lilybiri.com/blog-after-posterous-clickclickScroll immediately down to the ClickClick example. As a trainer/coach I strongly believe you can learn most from failures and bugs….I will have a closer look later on…. have some other priorities first to do.

Like
(1)
(4)
>
Lieve Weymeis
's comment
2018-08-10 10:40:18
2018-08-10 10:40:18
>
Lieve Weymeis
's comment

Thanks Lieve.  Something left out of the first post…I tried moving the first decision (increment the variable) to the end.  I got the same result except this time the var v_introCntr ended up = 16.

Like
(1)
>
Jay Cooper
's comment
2018-08-10 10:43:25
2018-08-10 10:43:25
>
Jay Cooper
's comment

I had added some more to my first post, but it seems not to have updated.

Another tip: avoid ELSE parts when you have so many decisions. The ELSE part will be executed always when the condition is not fulfilled, and in your case probably overrides previous decision commands. Can you try to check?

You can always replace THEN parts by more decisions.

 

 

Like
(1)
>
Lieve Weymeis
's comment
2018-08-10 10:55:17
2018-08-10 10:55:17
>
Lieve Weymeis
's comment

Thanks Lieve!  I must have clicked on that bar without realizing it…there shouldn’t be any “Else” statements anywhere in here.

As always, I appreciate the help.

Jay

Like
(1)
>
Jay Cooper
's comment
2018-08-10 10:57:52
2018-08-10 10:57:52
>
Jay Cooper
's comment

Sorry, I am frustrated now by the portal. Again I edited my reply because of a typo: it needs to be ELSE part in the last sentence. I saved the edited reply, but update was not done. Already cannot reply in Chrome anymore, now Edge is also getting wonky.

Like
(1)
2018-08-10 05:55:25
2018-08-10 05:55:25

Hi, it looks as if the problem is in your last conditions, where you’re checking if var == 13 or var == 14. In both cases, if the condition isn’t true, you’re setting v_IntroCtr to 15. Because that condition is true the first time through, you’re forcing the variable to 15 right away. If you don’t want to check that condition when a prior condition is true, you’ll need to set another variable in each of the conditions. At the start, where you’re incrementing v_IntroCtr, also assign a variable v_done to 0 (zero). Then in each true condition, set v_done to 1. In each condition after the first one, add the condition v_done == 0. So when you hit a condition that is true, you’re setting v_done to 1 and you’re checking if the variable is still 0 in each condition. If it isn’t, because you’ve set it to 1 in a prior condition, it will skip the rest of the conditions, at least until the next time you call the action.

Like
(1)
(2)
>
Joe S Ganci
's comment
2018-08-10 10:48:44
2018-08-10 10:48:44
>
Joe S Ganci
's comment

Joe…thanks for the input.  Your comments made me look at the code a little closer and I realized I had “Else” statements in the latter decisions that shouldn’t have been there!  I must have clicked that bar without realizing it.  I appreciate your weighing in!Jay

Like
>
Jay Cooper
's comment
2018-08-10 15:23:35
2018-08-10 15:23:35
>
Jay Cooper
's comment

You’re welcome!

Like
Add your comment