Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 9:54 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Custom Variable for the Score Value Total
PostPosted: June 11th, 2010, 4:03 pm 
Offline

Joined: December 13th, 2008, 3:15 pm
Posts: 152
Location: Brasil
Opus: 7
OS: Windows 7 x64
System: Asus P5Q3 Deluxe, Core 2 Duo E8500, 8 Gb DDR3 1333 mhz, His IceQ5 5770 HD Graphic Card, Samsung T220 Monitor; Lenovo G550 T6600, 4 GB DDR3 - 15,6".
Hy, Opus Lovers...

I'm creating a scoring system in which conditionals can happen in three different situations and in the bellow situation, the conditional checks if the user reached that band that points (greater than or equal to 21 and less than or equal to 29) to display the result.

I need to create a variable which includes a specific range of values between 21 and 29 (numbers) for the conditional if - Perform action is true, is satisfied.
The idea is to use the variable attached to conditional if
Perform action is true - score_value_total - contains - compare with variable (variable X (numeric values >= 21 and <= 29));

I know think the idea but do not know how to put it into a functional script, because I understand very little opusscript, then ask the valuable knowledge of the wise partners of this forum.

I am grateful for the help.

_________________
"To the ignorant, old age is the winter of life, for the wise, is the season of harvest."
It is not easy to translate the world into a binary code of 0s and 1s, but in scripts, anything is possible!


For this message NilsonBrasil has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 11th, 2010, 8:45 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Why not do something like this?

Code:
//initialize an Array variable once (for the Page or the Pub)
//example for 4 scores in each of 3 bands
BandArray1 = new Array("","Level_1","Level_1","Level_1","Level_1","Level_2","Level_2","Level_2","Level_2","Level_3","Level_3","Level_3","Level_3");
UserIsInBand = BandArray1[ UserNumericalScore ] ;
//Result is:  if user score is 7, user is in "Level_2"
//later

if( UserIsInBand == "Level_2" )
{
displayMessage = "Keep going" ;
}
The idea is you set up the array to 'define' the boundaries of the Bands. As the User increases or decreases his Score (numeric value), that can be used as the INDEX value to lookup the Band/Label in the Array. You can test on that string value very simply as shown.

[Lar EDIT:] I cleaned up syntax above about an hour after posting...

[Lar EDIT June 16th:] There is a previous forum Post that gives a more basic or direct answer to this OP. See my 6/16/10 Post below for link.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Last edited by Lar_123 on June 16th, 2010, 9:38 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 11th, 2010, 11:09 pm 
Offline

Joined: December 13th, 2008, 3:15 pm
Posts: 152
Location: Brasil
Opus: 7
OS: Windows 7 x64
System: Asus P5Q3 Deluxe, Core 2 Duo E8500, 8 Gb DDR3 1333 mhz, His IceQ5 5770 HD Graphic Card, Samsung T220 Monitor; Lenovo G550 T6600, 4 GB DDR3 - 15,6".
Lar, thanks for the reply, but I do not know if I can apply that concept.

I know I need a variable (which is an array - which incidentally also not sure how to do, containing the range of values - 21, 22, 23, 24, 25, 26, 27, 28, 29) for the case of score achieved by the user is one of these values, the screen shows a graphic and a text message - in script: graphic_object.Show() and Txt_mensage.Show().

The variable can be of publication but must contain these values to be checked by the function already ready at the Opus Value Total Score, as the picture frame attached.

See what you can do for me. I will be grateful.


You do not have the required permissions to view the files attached to this post.

_________________
"To the ignorant, old age is the winter of life, for the wise, is the season of harvest."
It is not easy to translate the world into a binary code of 0s and 1s, but in scripts, anything is possible!


For this message NilsonBrasil has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 12th, 2010, 5:17 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Hi Nilson,

I will not have any time to spend on extra development right now. Perhaps I can clarify so you can get through it.
First, the "bands".
You do not need to 'store' the values: 21, 22, 23 etc.

The approach I outlined does this instead:
myArray[0] = "" ; // empty
myArray[1] = "Level_1" ; // i.e., 'band 1'
myArray[2] = "Level_1" ;
myArray[3] = "Level_1" ;
myArray[4] = "Level_1" ;
myArray[5] = "Level_2" ; // note the change to the 'next band'
myArray[6] = "Level_2" ;
myArray[7] = "Level_2" ;
myArray[8] = "Level_2" ;
myArray[9] = "Level_3" ;

Explanation. the values you are focusing on, e.g. 21, 22, 23..., will be the INDEX numbers of the array.

- - - - - -
Let me add this observation.
The array variable does not need to be created to be a Publication variable or a Page variable that you declare in 'Page Properties' for example. You can simply write it into the Script Object. HOWEVER, each Opus Page that needs this DATASET for lookup... should have that array created and populated for that Page (one way to do this is to use a Master Page which holds that Script Object (and the functions you want also)).

If that's not quite clear, go ahead and use a Publication variable. ( Think of it this way: all of the data that the Array holds is quite 'static'. It does not change... it is a virtual LOOK-UP TABLE )


Your attachment (image) does not tell me much. Except you are still wanting to test on the numeric value, 21, and I suggest you test on the string value in myArray[21]. I do not know how to do that in standard triggers and actions -- because I do not practice that method. But you could do it this way (as a workaround if needed):

1. insert an earlier action which sets an added Page variable, 'currentscore', equal to one Array element. For example:
Code:
currentscore = myArray[ SCORE_VALUE_TOTAL ] ;

2. now change your standard actions test condition to test the variable, currentscore, equal to "band 3" or whatever you set that up to be.

cheers,
larry

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi, NilsonBrasil


Top
 Profile  
 
 Post subject: Custom Variable for the Score Value Total
PostPosted: June 12th, 2010, 6:16 am 
Offline

Joined: December 13th, 2008, 3:15 pm
Posts: 152
Location: Brasil
Opus: 7
OS: Windows 7 x64
System: Asus P5Q3 Deluxe, Core 2 Duo E8500, 8 Gb DDR3 1333 mhz, His IceQ5 5770 HD Graphic Card, Samsung T220 Monitor; Lenovo G550 T6600, 4 GB DDR3 - 15,6".
Great Larry!

Great tips, I'll try implement this arrays in my score-values!

Thanks!!!

_________________
"To the ignorant, old age is the winter of life, for the wise, is the season of harvest."
It is not easy to translate the world into a binary code of 0s and 1s, but in scripts, anything is possible!


For this message NilsonBrasil has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 12th, 2010, 9:50 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Nilson,

I thought of another way you can solve this. You might like this approach better.
In principle it is somewhat similar in that the INDEX VALUE will correspond (as before) with your User SCORE value, e.g. 21

It may be simpler for you to set up:
1. Create a Listbox_1 (Note: you can keep this object 'off-page'... outside the Page so the User does not see it. Or just set it to Hidden.)
1a. set up the Listbox options to have both an Index variable and a Selection variable. e.g., LBindex and LBselection

2. Fill the Listbox with a few lines of text. Use the same 'dataset' as you would use for the Array we discussed above. for example:
""
Level_1
Level_1
Level_1
Level_1
Level_2
Level_2
Level_2

and so on.

3. Now I think you just need one line of code in an Action Script, again this is similar how we would use the Array. But we're using a Listbox instead of an Array.

It is done in 1 step (assuming you are already taking care of the Scoring).

Code:
Listbox_1.SetListBoxSelection( SCORE_VALUE_TOTAL )


4. Use your standard Action to test your IF STATEMENT. Test it on that variable assigned to Listbox.
for example: test for LBselection EQ "Level_2" (remember above we set LBselection in the listbox set-up).


Maybe this will be simpler for you.


- - - - - -
Explanation.
Normally Listbox objects are used to display a set of choices. When the User clicks on a line in the Listbox, he is making a 'selection'. The Listbox can keep track of both the LINE Number and the TEXT value.

In the way we are 'manipulating' the Listbox here, the User will not see it. The User will not be making choices in it.
Instead, we use the current SCORE value as an Index value... and WE SET THE CHOICE based on that number e.g., 21.
We have essentially created a look-up table.
Once we made the 'choice' (step #3 above), we can use the variable that holds the TEXT Value ( in your case, LBselection will be "Band 3" when user's Score is 21)

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 12th, 2010, 11:57 am 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Have you looked at 'SELECT and 'CASE' actions?

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 12th, 2010, 4:44 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Not available in Opus 6 script - although you could use the actions.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 12th, 2010, 7:32 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
I think Nilson has the trial version of Opus 7, but I meant the actions anyway. I wasn't 100% sure what he was trying to do, but the select and case may do it.

Nilson,
here is a function to convert decimal seconds to sexagesimal (HH:MM:SS) and tenths:hundredths.


Code:
function TConvert(Dec)
{
//This function converts decimal units to a sexagesimal display with tenths and hundreds.Hours:Mins:sec:tenths:hundredths.
// in the format 00:00:00:00:00
Hours=String.format("02.0",Math.floor(Dec/3600))
Mins=String.format("02.0",Math.floor((Dec-Hours*3600)/60))
Secs=String.format("02.0",Math.floor(Dec-Hours*3600-Mins*60))
Fract=String.format("02.0",(100*(Dec-Math.floor(Dec))))//gets the bit after the decimal point
Tenths=String.format("02.0",Fract.charAt(0))
Huns=String.format("02.0",Fract.charAt(1))

Debug.trace(Hours+":"+Mins+":"+Secs+":"+Tenths+":"+Huns+"\n")

}


not very elegant, but seems to work ok
To use the function, you feed your video time into the function by using
TConvert(vidPosSecs)
You can select which units you want to display Hours:Mins:Secs:Tenths:Huns.
Just insert the variables into a text box "<Hours>:<Mins>:<Secs>:<Tenths>:<Huns>"


Sandy

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi, NilsonBrasil


Top
 Profile  
 
 Post subject: Custom Variable for the Score Value Total
PostPosted: June 12th, 2010, 8:19 pm 
Offline

Joined: December 13th, 2008, 3:15 pm
Posts: 152
Location: Brasil
Opus: 7
OS: Windows 7 x64
System: Asus P5Q3 Deluxe, Core 2 Duo E8500, 8 Gb DDR3 1333 mhz, His IceQ5 5770 HD Graphic Card, Samsung T220 Monitor; Lenovo G550 T6600, 4 GB DDR3 - 15,6".
Ok, here we go again ... :mrgreen:

Based on Lar' script, adapted and enter in the action OnShow - script in results page, where I have data ready to score actions such as score_value_total, score_percent and score_incorrect. There are three bands of score, where each one can show objects previously placed.

How am weak in scripts, I would like is verified that there are no syntax errors in my script, as well as the adaptation is correct.

One question: as the total score of points is shown by score_value_total, this script automatically detects the amount shown to display the objects that need to show, according to scores achieved by the user?

Following the script:

//initialize an Array variable once (for the Page or the Pub)
//example for 30 scores in 3 bands, where band 1 have scores 0 - 20; band 2 have scores 21 - 29 and band 3 have score 30
BandArray1 = new Array("","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_1","Level_2","Level_2","Level_2","Level_2","Level_2","Level_2","Level_2","Level_2","Level_3");
UserIsInBand = BandArray1[ UserNumericalScore ] ;
//Result is: if user score is 20, user is in "Level_1", if user score is 26, user is in "Level_2" and if user score is 30, user is in "Level_3"
//later

if( UserIsInBand == "Level_1" )
{ wait (4); //time to show opus score_actions
LIGHT_RED.Show(); //graphical object display in result page
TxtC_Bad.Show(); //graphical object display in result page
}

if( UserIsInBand == "Level_2" )
{ wait (4); //time to show opus score_actions
LIGHT_YELLOW.Show(); //graphical object display in result page
TxtB_Best.Show(); //graphical object display in result page
}

if( UserIsInBand == "Level_3" )
{ wait (4); //time to show opus score_actions
LIGHT_GREEN.Show(); //graphical object display in result page
TxtC_God.Show(); //graphical object display in result page
}

There is that beautiful script! The question is whether it will work ... :shock:

Ops, I had not seen the last post of sandy.

Thank you for the great tip, as needed only minutes and seconds, will try to adapt the script. I was here "eating fly." :mrgreen:

Let's go rock!!!

_________________
"To the ignorant, old age is the winter of life, for the wise, is the season of harvest."
It is not easy to translate the world into a binary code of 0s and 1s, but in scripts, anything is possible!


For this message NilsonBrasil has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 12th, 2010, 9:18 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Hi Nilson,

It seems you have good work. Cheers!
I only did a quick read-through for syntax and basics. It seems good.

Some thoughts.
* in case I did not mention it before, the first value in the Array is ""... since the Array is zero-indexed and you want to start with 1.
* For the script... I think you need to change the first part of the sample code to something like here (since User's 'Numerical Score' is in a different variable than I used in the example)
Code:
UserIsInBand = BandArray1[ UserNumericalScore ] ;
//should be either this
UserNumericalScore  = SCORE_VALUE_TOTAL ;
UserIsInBand = BandArray1[ UserNumericalScore ] ;

//or more directly like this
UserIsInBand = BandArray1[ SCORE_VALUE_TOTAL ] ;


* The main thing for you to do now is to think through your triggers. If you are executing this code in the Trigger and Action (screenshot you first posted), then you probably have it already working. That was an 'On Show' trigger on a Text object... so I think that will only run once (unless you are hiding and showing).

One alternative is to set up a Trigger on the Page object. Use a 'variable changed' trigger --- and set it to 'watch' the variable, SCORE_VALUE_TOTAL
...that way whenever the Score is changed, you could run the script code. Here's an outline:

__trigger: Page04 variable_changed trigger on SCORE_VALUE_TOTAL
____action: delay 4 sec
____action: Action Script (you won't need the wait(4) if you have the 'delay' above)

* last point... in the script you are 'showing' different Text objects. I guess you will want to 'hide' them at some point.
An alternative to this is to place each of those 3 Text objects in 3 Frames within a MULTIFRAME object. Then your IF statements can just cause the MultiFrame to show one of those three. e.g., MultiFrame007.ToFrame( 1 ) //it is zero indexed... so 0, 1, 2 are your values to use

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Custom Variable for the Score Value Total
PostPosted: June 13th, 2010, 4:31 pm 
Offline

Joined: December 13th, 2008, 3:15 pm
Posts: 152
Location: Brasil
Opus: 7
OS: Windows 7 x64
System: Asus P5Q3 Deluxe, Core 2 Duo E8500, 8 Gb DDR3 1333 mhz, His IceQ5 5770 HD Graphic Card, Samsung T220 Monitor; Lenovo G550 T6600, 4 GB DDR3 - 15,6".
Lar, I could implement the script what I was posted here and according to the suggested change for you everything is running cool.

I can only ask a question, it is necessary to consider all possibilities. And if the user reaches score 0?

Is something difficult but not impossible! We can not leave this hole open.

How can I make this array also includes the value "0" if the value "0", in your words - is the "indexer"?

I tested with several points - of 1 to 30 and everything is according to need, except ... "0"! where nothing happens...

_________________
"To the ignorant, old age is the winter of life, for the wise, is the season of harvest."
It is not easy to translate the world into a binary code of 0s and 1s, but in scripts, anything is possible!


For this message NilsonBrasil has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 14th, 2010, 1:18 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Hi Nilson,

Quote:
ask a question, it is necessary to consider all possibilities. And if the user reaches score 0?
Well, first change the initial values that are loaded into the Array. I originally suggested: ""
for that first element's value.
But you can change that to "Level_0"
or make it anything else you wish.

Then simply add another IF Statement to test for: == "Level_0"
and show or do whatever you want.

Do you plan to upgrade to Opus v7? If so, there is a nice way to streamline the coding for multiple IFs.

Larry

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Custom Variable for the Score Value Total
PostPosted: June 14th, 2010, 5:59 pm 
Offline

Joined: December 13th, 2008, 3:15 pm
Posts: 152
Location: Brasil
Opus: 7
OS: Windows 7 x64
System: Asus P5Q3 Deluxe, Core 2 Duo E8500, 8 Gb DDR3 1333 mhz, His IceQ5 5770 HD Graphic Card, Samsung T220 Monitor; Lenovo G550 T6600, 4 GB DDR3 - 15,6".
Thanks Lar.

With its valuable tips, the problem is solved, including the "zero point".

So, one more point to the object-oriented programming of Opus!

What happiness! OOP is all good!

_________________
"To the ignorant, old age is the winter of life, for the wise, is the season of harvest."
It is not easy to translate the world into a binary code of 0s and 1s, but in scripts, anything is possible!


For this message NilsonBrasil has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Custom Variable for the Score Value Total
PostPosted: June 16th, 2010, 9:35 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
I was searching the forum for some other topics/info, and came across this Nilson.
viewtopic.php?f=6&t=2627&hilit=variable+html

For others who tackling a similar problem (setting up upper and lower boundaries for 'scoring zones', or 'bands as Nilson calls them), the above link shows the very simple scripting of the IF STATEMENTS for that. It also provides a sample .IMP file you can download and use in Opus.

Take your pick.... which approach you want to use. In Opus, so many options.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi, NilsonBrasil


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 36 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group