Lua UI Text == multiple string's with or's - arrays

Now im really new to lua and need a little help with this This script checks some text on the player UI, and It works if It equals one thing for example : game:GetService("Players").LocalPlayer.PlayerGui.Main.Border.ClassLabel.Text == "UNIVERSELORD"
But does not work if I add the or game:GetService("Players").LocalPlayer.PlayerGui.Main.Border.ClassLabel.Text == "UNIVERSELORD" or "TANKTOP" It ends up doing it no matter what, and im not sure why, it works if I only put one name though, I would appreciate help thanks!

You already had the same question closed just few days ago due to the lack of details. It's not clear WHY you'd want to add "or" to a text, so you need to explain clearly and provide an example with some context where this usage would make some sense.
In terms of the "or" statement, it doesn't produce the result you want because it returns the first result that is evaluated as non-false, so when you have 1 or 2 expression, the result is 1, as it's evaluated left-to-right and this is a non-false results. Similarly in your case, the expression "UNIVERSELORD" or "TANKTOP" is evaluated to "UNIVERSELORD", as it's the first non-false value that is encountered.
Unfortunately nobody can tell you what to change it to, as there is not enough details in the question about your goal. Possibly an XY Problem.
[updated] Based on your comment, you need to split the or into two complete comparisons: game:GetService("Players").LocalPlayer.PlayerGui.Main.Border.ClassLabel.Text == "UNIVERSELORD" or game:GetService("Players").LocalPlayer.PlayerGui.Main.Border.ClassLabel.Text == "TANKTOP"

In Lua, any value that is not nil or false is considered true.
So in
if (game:GetService("Players").LocalPlayer.PlayerGui.Main.Border.ClassLabel.Text == "UNIVERSELORD" or "TANKTOP") then
getgenv().Spinloop = false print("Stopped!") return 0;
end
"TANKTOP" is a string and hence a true value.
or-ing anything with a true value is always true. So it does not matter if game:GetService("Players").LocalPlayer.PlayerGui.Main.Border.ClassLabel.Text equals "UNIVERSELORD". The result is always true. Hence your if condition is always met regardless of the text value.

Related

Excel: How to negate a boolean array?

I want to use "NOT" for arrays. I.e.:
"NOT"((True, False, True)) = (False, True, False)
I want to use this technique within a sumproduct formula, namely
=SUMPRODUCT(($R$2:$R$9000=$W$5:$AF$5)*($S$2:$S$9000))
Now, I want to use the negated array and am still looking for an elegant version how to do it. I tried:
=SUMPRODUCT(NOT($R$2:$R$9000=$W$5:$AF$5)*($S$2:$S$9000))
and
=SUMPRODUCT(($R$2:$R$9000<>$W$5:$AF$5)*($S$2:$S$9000))
which both did not work out as assumed. I know that I could use
=SUMPRODUCT(($R$2:$R$9000<>$W$5)*($R$2:$R$9000<>$X$5)*...*($R$2:$R$9000<>$AF$5)*($S$2:$S$9000))
But I hope for a more elegant version.
Do you know a more elegant answer?
Many greetings,
Peter
I was hoping for a more elegant solution for this myself, but I think this is the best I've figured so far: --(<bitmask>)=0.
In your case, SUMPRODUCT(--(($R$2:$R$9000=$W$5:$AF$5)*($S$2:$S$9000))=0), or even SUMPRODUCT((($R$2:$R$9000=$W$5:$AF$5)*($S$2:$S$9000))=0) should work since the * operator already converts the bitmask to integers.
The idea is to convert the {TRUE,FALSE,TRUE} bitmask into integers {1,0,1} with the --. Then if they're FALSE (0) the result of the =0 comparison is TRUE. If TRUE (1), then the result is FALSE.
If you use something like <bitmask>+<bitmask> to simulate an element-wise OR, it should still work because the TRUEs (sums) will still be >0.
Does that work for you?

Code Coverage for C

I've been doing a little bit of reviewing the different code coverage testing used on embedded systems. In particular, I'm looking at the MC/DC. From what I understand, one of the objectives is to make sure that each logical clause in a statement should affect the outcome of the statement.
Two questions:
What is gained by independently verifying that each clause has an effect on the outcome?
Why would (A||B) && (A||!C) not be able to achieve 100% MC/DC, while A||(B&&!C) will achieve 100% MC/DC even if they have the exact same functionality?
To answer your questions
You want as little of code as possible and as less complex code as possible. Having unreachable conditions lengthens your code and makes your code unnecessarily complex.
(A||B) && (A||!C) won't achieve 100% because it requires A to be checked twice for no reason. In the condition where A is false and B is true, A's truthiness will be checked for a second time in the (A||!C) expression for no reason in this formulation whereas in the formula A||(B&&!C) has A's truthiness being checked only once.

How to check whether the payload is null within choice component in mule?

I am retrieving some data using stored procedure and calling it within the database connector in mule. I have to include a condition when I pass a value which is not there in the database it should capture the error. For this I am using a choice component where I have to check whether the payload is null. But when running the flow in debug mode I found that the payload holds the value
{resultSet1=[]}. I tried #[message.payload.isEmpty()], #[message.payload!=null] and #[payload.resultSet1 != null]. But they weren't working. Could anyone help to resolve this. Thanks in advance.
You can use empty to check for:
Testing for Emptiness: The special literal empty tests the emptiness of a value. It returns an empty value depending on context. empty evaluates to:
null
boolean false
empty strings or strings containing only white space
zero
empty collections
The expression #[foo == empty] evaluates to true if the value if foo satisfies any of the requirements for emptiness.
Which in your case would be
#[payload.resultSet1 != empty]
The best way is #[payload != null && payload.size()>0]
you can try comparing with 'null" or "0" or, simply, "empty" and it should work fine for you :)
#[payload == empty]
should work.

Negation in AngularJS expression.

I have one very noob question for AngularJS expressions.
I want to check in expression (ngIf in this case) that something is
undefined. Eg:
data-ng-if="typeof obj.property == 'undefined'"
How I can write expression to check this?
I would be very grateful for any ideas and recommendations.
Best regards.
An undefined property will always be falsy, so you don't have to check it specifically unless you only care that it is undefined. A simply check could then be
data-ng-if="!user.email"
That would evaluate to true unless the user object had the property email with non-falsy value (0,'',undefined are all false). Maybe that is what you are after.
You can do this by using the negation operator:
data-ng-if="!(typeof obj.property == 'undefined')"
Also your call to typeof is a noop, it does nothing. You can simply remove it:
data-ng-if="!(obj.property == 'undefined')"
I agreee with #Matt Pileggi
but just to playing around
if('prop' in obj)

Validation rules in access

I recently started learning and using microsoft access. However, I am afraid that there is something really bothering me. It's connected with the validation rules. So here is my problem:
I had to validate a field so that only letters could be written. Of course I googled it and found the proper syntax. (Is Null or Not Like "*[!a-z]*")
At first I tried with (Is Null or Like "*[a-z]*"), which I think should be the same as the above one. It's checking every symbol from the string whether it is between 'a'and 'z' and that is why it is used with the obelisk * symbols from the both sides. Am I right?
My question is: Why is the second one not working, although it is a double negative equivalent to the first one. Will be happy for any explanation. Thanks in advance!
P.S Sorry if the question seems useless for you but I really do want to figure out where I am mistaking.
Consider the string 'a1b'.
Like "*[!a-z]*" will search the string for any character that is not in the range 'a'..'z'. It finds the '1' in the second position and returns True. Therefore, Not Like "*[!a-z]*" returns False.
On the other hand, Like "*[a-z]*" searches the string for any character that is in the range 'a'..'z'. It finds the 'a' in the first position and returns True.

Resources