misty
(Fresh Scripter)
2004-11-03 04:01 PM
Problem with 'if' and OR logic

I can't seem to get the syntax right for this. I'm trying to test if someone is in the group Engr or Truss or Receptionist, and if they are in one of those, to do some condition. Here is what I have but it doesn't work:

IF INGROUP("Engr") OR INGROUP("Truss") OR INGROUP("Receptionist")


JochenAdministrator
(KiX Supporter)
2004-11-03 04:12 PM
Re: Problem with 'if' and OR logic

Syntactically and logically correct, but you miss the conditional code plus the endif

Only half kidding here, can you show us a bit more ?

Additionally, have you added your user to one of these groups just to test and haven't refreshed the token cache of KiX (hint: run kix32 with /f) ?

If you did refresh the cache, does anything change if you add the domain name to your ingroup statements ?


Cybex
(Getting the hang of it)
2004-11-03 04:14 PM
Re: Problem with 'if' and OR logic

IF trys every statement so the or is not needed.
Code:
IF INGROUP("Engr")
EndIf
IF INGROUP("Truss")
EndIf
IF INGROUP("Receptionist")
EndIf




Select finds the first true statement and then stops looking.
Code:
 SELECT
CASE expression
statement1
CASE expression
statement2
ENDSELECT




JochenAdministrator
(KiX Supporter)
2004-11-03 04:21 PM
Re: Problem with 'if' and OR logic

Quote:

IF trys every statement so the or is not needed.
Code:
IF INGROUP("Engr")
EndIf
IF INGROUP("Truss")
EndIf
IF INGROUP("Receptionist")
EndIf







Eh? So you promote writing the conditional code 'thrice'


Cybex
(Getting the hang of it)
2004-11-03 04:28 PM
Re: Problem with 'if' and OR logic

No I was trying to explain that IF keeps steping through and and case can be used if you have only one possible statement that could be true. I wa s not recommending the use of the code as written.

JochenAdministrator
(KiX Supporter)
2004-11-03 04:50 PM
Re: Problem with 'if' and OR logic

Allrighty then

**DONOTDELETE**
(Lurker)
2004-11-03 05:26 PM
Re: Problem with 'if' and OR logic

IF INGROUP("Engr") or INGROUP("Truss") or INGROUP("Receptionist")
; Make sure the user can run MATLIST -- they need a .get file and it gets
; created automatically if they don't have one (copied from one that works)
IF NOT EXIST("\\corpsrv\data\batch\paths\@USERID.get")
;cp \\corpsrv\data\batch\paths\jenny.get \\corpsrv\data\batch\paths@USERID.get
ENDIF

; The program was written to use a variable that exists in Novell but not NT, so we set it here
SETM "LINAME=@USERID"
? "LINAME set to @USERID" ; for MATLIST program -- look in %L\DATA\BATCH\PATHS\username.get

; Set up drive mappings here (X will go away eventually)
USE L: \\corpsrv\engr
USE G: \\corpsrv\apps
USE Q: \\corpsrv\data
USE U: \\corpsrv\utils
use X: \\corpsrv\X
ENDIF

I get an error in the kixtart script if I have the IF line setup that way. If I take out everything but INGROUP("Engr") it works fine.


JochenAdministrator
(KiX Supporter)
2004-11-03 05:29 PM
Re: Problem with 'if' and OR logic

What's the error then ? Is there a line number specified ?



Les
(KiX Master)
2004-11-03 05:36 PM
Re: Problem with 'if' and OR logic

No need to OR it unless you have a very old version of KiX. InGroup supports the passing of multiple group names.
Quote:

InGroup( )

Action: Checks whether the current user is a member of a group.

Syntax: INGROUP ("group name" [<,> "group name 2"], mode)

Parameters: Group name, group name 2, group name X…
Identifies the group(s) in which to check the user's membership. You may pass multiple group names as arguments -or- a single array who's element(s) are the names of one or more groups to test. Note: This function does not currently support passing multiple arrays as arguments.







**DONOTDELETE**
(Lurker)
2004-11-03 05:46 PM
Re: Problem with 'if' and OR logic

As usual I was making it too difficult!! Thank you!

JochenAdministrator
(KiX Supporter)
2004-11-03 05:56 PM
Re: Problem with 'if' and OR logic

Anyway the if line shouldn't have thrown an error in the first place ... as said, it was syntactically correct