Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 11:47 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: if and
PostPosted: May 19th, 2014, 12:48 am 
Offline

Joined: February 11th, 2005, 1:03 am
Posts: 185
Location: Yorkshire UK
Opus: Pro 9.3
OS: Windows 7
I've used this kind of conditional expression in other languages but I can't
figure out how Opus Script deals with it.

Here's part of my code:
if (counter == 4) and (score1 == 4)
{
PlaySound("C:\\Program Files (x86)\\Opus Pro 9\\Resources\\Sounds\\Sliders\\bell up.ogg")
GotoPage("First1")
}

if (score1 <=3)and (score1 == 4)
{ PlaySound ("C:\\Program Files (x86)\\Opus Pro 9\\Resources\\Sounds\\Sliders\\bell up.ogg")
GotoPage("Sorry")
}


I'm puzzled by the "and" - is this not part of Opus Script?
In JavaScript, for example, "and" is replaced by "&&".
And I can't see an if......then.... else.

How can I sort this please in Opus Script?
Regards

_________________
I'd like to begin by saying, " It gives me great pleasure.....
Plato award winner 1999.
Several computers.
HP - Phenom Quad 2.3Ghz; RAM 4Gb, Windows 7 - 64 bit; 3Tb collective Hard disks; Nvidia Geforce 9600 GSO; Opus 9.3; Tascam2488


For this message Kingell has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: if and
PostPosted: May 19th, 2014, 7:52 am 
Offline

Joined: January 28th, 2014, 4:38 pm
Posts: 54
Location: Czech Republic
Opus: OpusPro 9.75 - HTML5 exports, Evolution
OS: Win 7 x64 CZ
System: FUJITSU
You can find it in OpusScript help under "Syntax: Operators"

AND = &&
OR = ||
NOT = !

so it should be:
Code:
if (counter == 4 && score1 == 4){...}

this could be usefull from help:
Quote:
OpusScript is based on a JavaScript standard produced by the European Computer Manufacturers Association (ECMA), commonly known as ECMAScript or ECMA-262.

ECMA-262 is equivalent to JavaScript version 1.1. In other words, programming with OpusScript is like programming with JavaScript version 1.1 but obviously it has been extended with commands and functions specific to Opus publication objects.


o.


For this message ovo has been thanked by : Kingell, mackavi


Top
 Profile Visit website  
 
 Post subject: Re: if and
PostPosted: May 19th, 2014, 8:59 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
!= NOT =!

You should really also use strict equality to avoid unnecessary / unwanted type conversion.

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: if and
PostPosted: May 19th, 2014, 9:49 am 
Offline

Joined: January 28th, 2014, 4:38 pm
Posts: 54
Location: Czech Republic
Opus: OpusPro 9.75 - HTML5 exports, Evolution
OS: Win 7 x64 CZ
System: FUJITSU
sure it should be !=. it was copy paste from help but not the best part
Quote:
x = !true will set x as false
for requested help.


For this message ovo has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: if and
PostPosted: May 19th, 2014, 10:04 am 
Offline

Joined: February 11th, 2005, 1:03 am
Posts: 185
Location: Yorkshire UK
Opus: Pro 9.3
OS: Windows 7
Quote:
ECMA-262 is equivalent to JavaScript version 1.1. In other words, programming with OpusScript is like programming with JavaScript version 1.1 but obviously it has been extended with commands and functions specific to Opus publication objects.


Yup - I bought the JavaScript book but sometimes as you say there are extensions peculiar to Opus.
The layout in my book does not put the && inside the same brackets as the first condition.
This, I expect, is the problem. :)
Thanks very much - I'll give it a try.

I use an Opus 4 book for guidance perhaps I should use the help file. :roll:
Regards

_________________
I'd like to begin by saying, " It gives me great pleasure.....
Plato award winner 1999.
Several computers.
HP - Phenom Quad 2.3Ghz; RAM 4Gb, Windows 7 - 64 bit; 3Tb collective Hard disks; Nvidia Geforce 9600 GSO; Opus 9.3; Tascam2488


For this message Kingell has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 17 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