Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently November 6th, 2024, 9:49 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Help required for script function
PostPosted: April 30th, 2007, 12:00 pm 
Offline

Joined: April 15th, 2007, 6:52 pm
Posts: 5
Hello everyone,

Would it be possible for someone to point me in the correct direction regarding a possible script statement.

If a variable I have on screen is between 10 and 40, variable <figure> should show A.

If the onscreen variable is between 41 and 70, variable <figure> should show B.

If the onscreen variable is between 71 and 100, variable <figure> should show C and so on up to possibly 800 for the onscreen variable.

Can this be done in script?

Thank you for looking


For this message programpal has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 30th, 2007, 1:14 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
The script would be an if then else statement

if (myVariable > 9 && myVariable < 41) DoSomeThing1
else if (myVariable > 40 && myVariable < 71) DoSomeThing2
else if (myVariable > 70 && myVariable < 101) DoSomeThing3

Mackavi

_________________
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:
PostPosted: April 30th, 2007, 1:25 pm 
Offline

Joined: April 15th, 2007, 6:52 pm
Posts: 5
Thank you for your prompt reply.

The operators used in script leave me baffled sometimes. I am picking up scripting as I work but I have unsuccessfully tried to locate a list of script operators and their functions.

This may seem like bread and butter to some guys but it is only easy if you know how !!!


For this message programpal has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 30th, 2007, 1:27 pm 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
Mackavi
How if somone wants it like this:
if 1,3,5,7....etc I mean odd number it shows A
if 2,4,6,8...etc I mean even number it shows B


For this message opuslover has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: April 30th, 2007, 1:49 pm 
Offline

Joined: October 25th, 2004, 3:03 pm
Posts: 540
Location: Tyalgum Creek. Australia
Opus: Opus Pro Latest version 9.02 Build 16458
OS: Won 10
System: Asus laptop Intel Core i5 8 gig ram, big monitor, reading glasses
Hello Programpal

Yes - can be done

Have attached an Opus example imp for you. Note it is OpusV6.

The script could look something like this;

if (number>=10 && number<=40)
{Image1.Show()
}
if (number>=41 && number<=70)
{Image2.Show()
}
if (number>=71 && number<=100)
{Image3.Show()
}

Note: Imagex is the name of the object that you want to show
Hope this helps

Cheers

Graham


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

_________________
Too much coffee can result in frequent toilet breaks!


For this message Graham Baglin has been thanked by : mackavi


Last edited by Graham Baglin on April 30th, 2007, 2:06 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: April 30th, 2007, 1:53 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
taxing the odd gray mater,

if (Math.floor(myNumber/2) == myNumber / 2)
{DoSomethingForEVENNumbers} //Be sure to include the {} braces
else DoSomethingForODDNumbers

Works because when an ODD number is halved, the result always involves a decimal. Therefore, when you compared the rounded (down) result with the result they will not match for ODD numbers, but will match for even.

Mackavi

_________________
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:
PostPosted: April 30th, 2007, 2:45 pm 
Offline

Joined: September 11th, 2006, 2:38 pm
Posts: 125
Thanks Mac for your Great help


For this message opuslover has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: May 1st, 2007, 4:43 pm 
Offline

Joined: April 15th, 2007, 6:52 pm
Posts: 5
Thank you to all for your help. this really is a good forum.
A great product and some good guys on the forum also, what more could you ask for?

I hope that one day I can answer someones query and repay the favour!


For this message programpal has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: May 1st, 2007, 6:51 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
You can also use the modulo operator.

if(NUMBER%2==0){
VARIABLE=A;
}
else {
VARIABLE=B;
}


The if checks your number (NUMBER). If it equals 0, it's an EVEN. Otherwise it's an odd. Basically the same as Mac's example, but a little less coding. It's used in HTML often to create alternating row colors for HTML tables.

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


For this message bwpatric has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: May 3rd, 2007, 11:18 am 
Offline

Joined: October 25th, 2004, 3:03 pm
Posts: 540
Location: Tyalgum Creek. Australia
Opus: Opus Pro Latest version 9.02 Build 16458
OS: Won 10
System: Asus laptop Intel Core i5 8 gig ram, big monitor, reading glasses
Hi Brian

Thought I'd play around with your solution and came up with a slightly modified script as follows;

if(number%2==0)
{
tick.Show()
}
else
{
cross.Show()
}


However, when the publication is run, if you return to the Opus editor, you get an alert window that says;

Action (1, 0) : Undefined identifier 'number'

This window does not appear after publishing and running as a stand-alone executable.

Is there someone who can explain the error message to me please? Imp file is attached for experimentation.

Thanks in advance

Graham


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

_________________
Too much coffee can result in frequent toilet breaks!


For this message Graham Baglin has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: May 3rd, 2007, 11:59 am 
Offline

Joined: October 26th, 2004, 10:23 am
Posts: 666
Location: Digital Workshop
I expect it is because "number" is a reserved word in ecmascript - call it "bob", "jim", "graham" or "aardvark" instead...

_________________
ddww Opus Developer


For this message Duncan Lilly has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: May 3rd, 2007, 12:06 pm 
Offline

Joined: October 25th, 2004, 3:03 pm
Posts: 540
Location: Tyalgum Creek. Australia
Opus: Opus Pro Latest version 9.02 Build 16458
OS: Won 10
System: Asus laptop Intel Core i5 8 gig ram, big monitor, reading glasses
aardvark it is :lol:
Thanks Duncan
You can have the rest of the day off for excellent service!
Enjoy your day
Cheers
Graham

_________________
Too much coffee can result in frequent toilet breaks!


For this message Graham Baglin has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: May 3rd, 2007, 12:21 pm 
Offline

Joined: October 25th, 2004, 3:03 pm
Posts: 540
Location: Tyalgum Creek. Australia
Opus: Opus Pro Latest version 9.02 Build 16458
OS: Won 10
System: Asus laptop Intel Core i5 8 gig ram, big monitor, reading glasses
Whoa!

Before you go, aardvark does not work :D

Get the following message on returning to the editor after testing the publication

Action (1, 0) : Undefined identifier 'aardvark'

The publication works OK but I'm just curious about the error message from a learning perspective.

Don't spend too much time on it Duncan - I've probably done something incorrectly building the sample publication.

Cheers

Graham

_________________
Too much coffee can result in frequent toilet breaks!


For this message Graham Baglin has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: May 3rd, 2007, 1:05 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
You need to unselect the Generate enter on change of focus from the text box :-)

_________________
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:
PostPosted: May 3rd, 2007, 1:22 pm 
Offline

Joined: October 25th, 2004, 3:03 pm
Posts: 540
Location: Tyalgum Creek. Australia
Opus: Opus Pro Latest version 9.02 Build 16458
OS: Won 10
System: Asus laptop Intel Core i5 8 gig ram, big monitor, reading glasses
Error message is Gone!

Thanks Mackavi and Duncan

Learned two things

1. Best to avoid using reserved words for variable names

2. Generating enter on change of focus when using scripts can cause an error message.

Cheers

Graham

_________________
Too much coffee can result in frequent toilet breaks!


For this message Graham Baglin has been thanked by : mackavi


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group