(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Tutorials > JASS/AI Scripts Tutorials

JASS/AI Scripts Tutorials Contains tutorials regarding JASS scripting and the AI editor.
Read the Rules before posting.

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 11-21-2007, 03:45 AM   #1 (permalink)
 
Earth-Fury's Avatar

Inside You <3
 
Join Date: Feb 2004
Posts: 555

Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)

PayPal Donor: This user has donated to The Hive. 

Precedence in JASS

Precedence in JASS

Definition of Precedence
In a programming language, the precedence of an operator determines in what order it will be evaluated. An operator with a higher precedence will be evaluated before another with a lower precedence. For instance multiplication has a higher precedence than addition.
http://www.google.ca/search?q=define%3A+precedence

The rules of precedence are important if you don’t want your code littered with needless parenthesis. JASS has only a few operators, so remembering their precedence is not so hard:

Precedence:
( )
not
* /
+ -
<= >= > < == !=
and or

The higher on the list, the higher an operators precedence. If two operators are in the same row, they share the same precedence and are thus executed from left-to-right. By this chart, the following examples are all true:

a == b != c // Is the same as…
(a == b) != c

a != b == c // Is the same as…
(a != b) == c

1 + 2 * 3 – 4 / 2 // Is the same as…
1 + (2 * 3)(4 / 2)

false == 1 > 2 // This will fail to even compile, as it’s the same as…
(false == 1) > 2

not 4 > 3 // This will also fail to compile, as it’s the same as…
(not 4) > 3

a == b or c == d // Is the same as…
(a == b) or (c == d)


The or and the and operators are executed in a short circuit manner. This means that if from the current execution, an answer is determinate, execution stops. By this, the following are both true:

f() // Returns false
t() // Returns true

t() or f() // f() will never be executed.

f() and t() // t() will never be executed.



Much credit to PurplePoot for helping me test precedence
Edit: Tiny formatting edit and removal of signature

Last edited by Earth-Fury; 02-29-2008 at 02:29 PM.
Earth-Fury is offline  
Old 11-21-2007, 05:28 AM   #2 (permalink)
 
PurgeandFire111's Avatar

User Title
 
Join Date: Nov 2006
Posts: 1,059

PurgeandFire111 is a jewel in the rough (153)


I never even knew this. =D

Thanks.

Seems good to me.
__________________
Vote For The Hive Workshop!
Funny but the TRUTH! :
Quote:
Originally Posted by Sopho
Unprotecting maps is not right its like crime and YOU GO MAKE YOUR OWN MAP AND BE HAPPY! Don't be gay n00b!

1. You can if it is yours but you should not if it is not. It is like stealing information and using it as if it is your own. It si gay stuff and people who unprotect maps are gay themselves.
PurgeandFire111 is offline  
Old 11-21-2007, 09:00 PM   #3 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,908

PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)

Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Really no reason not to approve this, IMO.

~Guess what?
PurplePoot is offline  
Old 12-03-2007, 11:35 PM   #4 (permalink)
 
Herman's Avatar

Need to buy myself a comp
 
Join Date: Aug 2007
Posts: 1,061

Herman has little to show at this moment (34)Herman has little to show at this moment (34)Herman has little to show at this moment (34)Herman has little to show at this moment (34)


Woah, thats really useful to reference to

+rep
Herman is offline  
Old 05-04-2008, 05:36 PM   #5 (permalink)

Anozer jasser
 
Join Date: Apr 2008
Posts: 231

Troll-Brain has little to show at this moment (13)Troll-Brain has little to show at this moment (13)


you have forgotten to write the t() and f() functions
Else, nice to know but i think for my mental sanity (to keep the code easily readable) i will still use () ^^

Last edited by Troll-Brain; 05-04-2008 at 06:13 PM.
Troll-Brain is offline  
Old 05-08-2008, 01:54 AM   #6 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,908

PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)

Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Quote:
you have forgotten to write the t() and f() functions
Both will be executed, of course.
PurplePoot is offline  
Old 05-08-2008, 11:54 PM   #7 (permalink)
 
Herman's Avatar

Need to buy myself a comp
 
Join Date: Aug 2007
Posts: 1,061

Herman has little to show at this moment (34)Herman has little to show at this moment (34)Herman has little to show at this moment (34)Herman has little to show at this moment (34)


Uhhh, wait a second....

Does that mean if you have a function for converting indexes, only the first function will fire, bugging out your JASS???

Ex.
udg_UnitArray[IndexFunction(u1)] == udg_UnitArray[IndexFunction(u2)]

Or maybe...

udg_UnitArray[IndexFunction(u1)] == udg_UnitArray[IndexFunction(u2)] and udg_UnitArray[IndexFunction(u3)] == udg_UnitArray[IndexFunction(u4)]
__________________
Half of the worlds population is below average intelligence
Herman is offline  
Old 05-09-2008, 02:39 PM   #8 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,908

PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)

Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Ands and Ors are short circuit, meaning in any circumstance where the answer is known after one of the two booleans is evaluated, they will immediately finish execution.
PurplePoot is offline  
Old 05-09-2008, 11:01 PM   #9 (permalink)
 
Herman's Avatar

Need to buy myself a comp
 
Join Date: Aug 2007
Posts: 1,061

Herman has little to show at this moment (34)Herman has little to show at this moment (34)Herman has little to show at this moment (34)Herman has little to show at this moment (34)


Ohhh, I gotcha, so if lets say it is an Or, and the first one is true, it will.... oh thats what the example means ><

So, if your second boolean function has some kind of unrelated call statement in there, you should be careful, because it will not always go through that secondary conditional function
__________________
Half of the worlds population is below average intelligence
Herman is offline  
Old 05-12-2008, 01:34 PM   #10 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,908

PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)PurplePoot is a name known to all (737)

Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

Yes, exactly.
PurplePoot is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
JASS: Moving From GUI to Jass, the Start Rheias JASS/AI Scripts Tutorials 61 07-22-2008 11:06 AM
I'm a JASS noob so I would like to find out if something is possible with JASS Aoen Triggers & Scripts 14 01-06-2007 09:38 PM
[JASS Request] Trigger to JASS AztraL- Requests 0 10-08-2006 03:02 PM
passing local variable in JASS? Channeled effects with JASS? kuraruka Triggers & Scripts 2 02-10-2006 11:38 PM
[JASS] Converting GUI to JASS !! PLEASE HELP !! Learning JASS HELP ApM Triggers & Scripts 7 03-10-2005 12:42 PM

All times are GMT. The time now is 05:25 PM.






Your link here 
Problem Mortgage | Verizon Ringtones | Debt Consolidation | Send Money Online | Fast Loans
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle