Page 1 of 1 1
Topic Options
#207376 - 2013-05-29 12:19 PM Weird Issue
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
I'm trying to do a simple If statement, but kix seems to validate this all the time, here's the Example:
 Code:
If NOT InGroup("Some group") OR @WKSTA="PCNAME"
  ? "Condition met"
Else
  ? "Condition not met"
EndIf

Now the InGroup evaluates fine, but you can change PCNAME to anything you want, and it'll always evaluate to "Condition met"

Top
#207377 - 2013-05-29 12:55 PM Re: Weird Issue [Re: Arend_]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I've never been good at explaining this, as I never took a "Programing 101" class, but it is one of the reasons why I tried to stop using NOT. I try to evaluate things using positive logic and I have had much better success.

Basically this is how your code is evaluating...

 Code:
? not 1 or 1 ;=1
? not 0 or 1 ;=1
? not 1 or 0 ;=0
? not 0 or 0 ;=1



_________________________
(... better days ahead)

Top
#207378 - 2013-05-29 01:20 PM Re: Weird Issue [Re: Allen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Well as much as I'd like to, I need the example condition in practice.
I need something to happen when a user is NOT member of a specific group, this part works fine. However today an issue arises where this must remain in effect, except on a certain PC.

Top
#207379 - 2013-05-29 01:23 PM Re: Weird Issue [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Let's say the thing to happen is drive mappings.
When a user is a member of the specific group, the drive mappings do not take place.
And when the user is NOT a member, it does take place. This works fine.
But I need it it to take place on a certain PC regardless of the group membership.

Top
#207380 - 2013-05-29 01:55 PM Re: Weird Issue [Re: Arend_]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I have a feeling AND is what is needed for your code...

however, changing the code to this should do it.
 Code:
If InGroup("Some group") OR @WKSTA<>"PCNAME"
  ;do nothing
Else
  ? "Map Drives"
EndIf


_________________________
(... better days ahead)

Top
#207381 - 2013-05-29 04:11 PM Re: Weird Issue [Re: Allen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Nope. I need "NOT InGroup" \:\)
Top
#207382 - 2013-05-29 04:17 PM Re: Weird Issue [Re: Arend_]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
That is "not in group"... but using positive logic.
_________________________
(... better days ahead)

Top
#207383 - 2013-05-29 05:32 PM Re: Weird Issue [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
 Code:
If NOT (InGroup("Some group") OR @WKSTA="PCNAME")
  ? "Condition met"
Else
  ? "Condition not met"
EndIf
_________________________
!

download KiXnet

Top
#207384 - 2013-05-30 08:55 AM Re: Weird Issue [Re: Lonkero]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Unfortunatly Lonk, that doesnt work either.
Top
#207385 - 2013-05-30 11:55 AM Re: Weird Issue [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
I am mistaken Lonk, your solution DOES work. Thanks! \:\)
Top
#207391 - 2013-06-04 12:31 PM Re: Weird Issue [Re: Arend_]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Are you sure? It's been a long time since I had my logic class, but your original code looks correct to me. If I understand your statement, you need the condition to be true if the user is not a member of a particular group or if the workstation name is a given name.

So simple truth table:

 Code:
In Group    PCNAME=
0           0
0           1
1           0
1           1


If we NOT the In Group and then or the results:

 Code:
Not In Group   PCNAME=   OR
1              0         1
1              1         1
0              0         0
0              1         1


Which is what Allen pointed out. If the person is not in the group, the condition is met. If the person is in the group and the workstation name is the given pcname, the condition is met. If the person is in the group and the workstation name is not the given pcanme, the condition is not met. That seems exactly correct.

Looking at Lonk's code would give (remember we are first OR'ing the values and then NOT'ing the OR'd value):

 Code:
In Group    PCNAME=   OR   NOT
0           0         0    1
0           1         1    0
1           0         1    0
1           1         1    0


Which says the condition is only met when the person is not in the group and the workstation name is not pcname.

Did I miss something?

Top
#207393 - 2013-06-04 02:48 PM Re: Weird Issue [Re: BradV]
Henriques Online   content
Fresh Scripter

Registered: 2007-09-13
Posts: 43
To me it's like this
If NOT InGroup("Some group") OR @WKSTA="PCNAME"
? "Condition met"
Else
? "Condition not met"
EndIf

the or statement is of a higher order so what happens is this
If NOT ( InGroup("Some group") OR @WKSTA="PCNAME" )
What you want is possibly
If ( NOT InGroup("Some group") ) OR ( @WKSTA="PCNAME" )

Top
#207394 - 2013-06-04 04:25 PM Re: Weird Issue [Re: Henriques]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Yes, If ( NOT InGroup("Some group") ) OR ( @WKSTA="PCNAME" ) is how I was interpreting it. \:\)
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.065 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org