Junior Member
Join Date: Mar 2015
Posts: 28
|
I found the post that spelled out how to perform logical comparisons, but I cannot find how to perform AND and OR statements to combine booleans in an IF statement. Can anyone provide an example or a link to a good tutorial with an example of && and ||?
|
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,215
|
What do && and || mean? You'll never see a doubled character as a operator in HL's scripting language. Do you just mean & and |, and you're pulling in terms from another language?
Also, do you want to use booleans with a script, or are you using booleans in a tag expression? The answer is different in each case If your question is about tag expressions, here's that section of the wiki: http://hlkitwiki.wolflair.com/index....ag_Expressions For scripts, you'll have to be clever with addition and subtraction and multiplication, because the standard if () then can't take booleans. But, if (A + B <> 0) then ends up meaning A or B, as long as both A and B are things that are false at 0 and true if <> 0, and if (A + B = 2) then ends up meaning A & B, as long as both A and B are things that are false at 0 and true at 1 (but in this case, it doesn't work if they can be values > 1). |
#2 |
Senior Member
Volunteer Data File Contributor
Join Date: Jan 2010
Location: Chicago, IL (USA)
Posts: 10,729
|
Quote:
FYI ISO standards for SQL uses || to concatenate strings together. The fun of working in many different languages. Hero Lab Resources: Pathfinder - d20pfsrd and Pathfinder Pack Setup 3.5 D&D (d20) - Community Server Setup 5E D&D - Community Server Setup Hero Lab Help - Hero Lab FAQ, Editor Tutorials and Videos, Editor & Scripting Resources. Created by the community for the community - Realm Works kickstarter backer (Alpha Wolf) and Beta tester.- d20 HL package volunteer editor. |
|
#3 |
Junior Member
Join Date: Mar 2015
Posts: 28
|
Suppose I have a numeric variable "delta" and I want to test to see if it is within a given range:
Code:
if (delta > 3 AND delta <=6) then do stuff endif Suppose I want to know if delta is one of two values: Code:
if (delta = 3 OR delta = 6) then do stuff endif |
#4 |
Senior Member
Volunteer Data File Contributor
Join Date: Nov 2009
Posts: 1,502
|
For AND
Code:
if (delta > 3) then if (delta <=6) then ~ do stuff endif endif Code:
if (delta = 3) then ~ do stuff endif if (delta =6) then ~ do stuff endif |
#5 |
Junior Member
Join Date: Mar 2015
Posts: 28
|
Quote:
To summarize the takeaway from this, I need to nest any if statements for logical AND or OR? |
|
#6 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,215
|
Depending on how things are stored, tagexpr may work:
Code:
if (tagexpr[(fieldval:trtUser >= 3) & (fieldval:trtUser <= 6)] <> 0) then |
#7 |
|
|