Page 1 of 1 1
Topic Options
#190329 - 2008-10-27 04:32 PM simple scripting help
mahjohn Offline
Fresh Scripter

Registered: 2004-11-02
Posts: 26
How can I script the following ?

If InGroup ("A") = 1
Run "\\....exe"
If InGroup ("B") = 1
Run "\\....exe"
If Not (InGroup ("A") or InGroup ("B"))
Run "\\....exe"

Top
#190331 - 2008-10-27 04:35 PM Re: simple scripting help [Re: mahjohn]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
You need to close each If with an EndIf, otherwise the opening If must be satisfied for all following If statements.

Consider this, with indenting added:
 Code:
If InGroup ("A") = 1
  Run "\\....exe"
  If InGroup ("B") = 1
    Run "\\....exe"
    If Not (InGroup ("A") or InGroup ("B"))
      Run "\\....exe" 
; missing EndIfs added as Kix would see them
    EndIf
  EndIf
EndIf

What you probably want is really
 Code:
If InGroup ("A") = 1
  Run "\\....exe"
EndIf

If InGroup ("B") = 1
  Run "\\....exe"
EndIf

If Not (InGroup ("A") or InGroup ("B"))
  Run "\\....exe" 
EndIf


Glenn


Edited by Glenn Barnas (2008-10-27 04:38 PM)
Edit Reason: add example
_________________________
Actually I am a Rocket Scientist! \:D

Top
#190333 - 2008-10-27 04:44 PM Re: simple scripting help [Re: mahjohn]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Like Glenn already said you should match the if's with endif's.
Also the parentheses in the third if statement are not necessary and I changed the logic a bit on the third if statement so that it does whatever you specify there when the user is not in A and not in B.

See the example below.

 Code:
If InGroup("A")
	;Do stuff
EndIf

If InGroup("B")
	;Do stuff
EndIf	

If Not InGroup("A") And Not InGroup("B")
	;Do stuff
EndIf



[edit]
Did not see Glenn's example until I submitted \:\(
[/edit]


Edited by Mart (2008-10-27 04:45 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#190334 - 2008-10-27 05:00 PM Re: simple scripting help [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Not that the third statement was wrong.. ;\)

If Not (Test_A Or Test_B)
is equivalent to
If Not Test_A And Not Test_B

In the first, if either test returns a true value, the entire expression in the parens is true, which is negated by the Not, and the If fails.. If both are false, the statement is false, which satisfies the If and the process is evaluated.

In the second, if Test_A is false AND Test_B is false, both If statements succeed and the process is evaluated.

Either way, same result. It really comes down to how you're thinking, and what seems most clear to others that must read your code.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#190336 - 2008-10-27 05:56 PM Re: simple scripting help [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah.
that's why I like the format:
If 0=Test_A+Test_B
_________________________
!

download KiXnet

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
0 registered and 988 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.028 seconds in which 0.011 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