Page 1 of 1 1
Topic Options
#128239 - 2004-10-21 01:51 PM Case / Ingroup
Larve_Q Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 8
Hi,

Can I use a Ingroup under a case, like this script below?Because I can't get it to work.

Case $Gateway="10.113.0.1"

If InGroup("Pri-NL-Administratie")
If AddPrinterConnection ("\\amssrv050\HP4300 IFS Administratie PCL6") = 0
EndIf
EndIf

Case $Gateway="10.113.0.1"

If InGroup("Pri-NL-Automatisering")
If AddPrinterConnection ("\\amssrv050\HP4000TN Administratie RAYE PS") = 0
EndIf
EndIf

EndSelect

Grt.

Larve

Top
#128240 - 2004-10-21 02:00 PM Re: Case / Ingroup
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Larve,

I guess it's not the complete code (please use tags from now on) cause I'm missing the select entry

Also both cases have the same $gateway value...
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#128241 - 2004-10-21 02:00 PM Re: Case / Ingroup
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Case statements are mutually exclusive - as the gateway check value (10.113.0.1) is the same in both, only the script in the first case statement will be executed.
Top
#128242 - 2004-10-21 02:02 PM Re: Case / Ingroup
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Sure you can, but why the conditional check on Addprinterconnection? There is nothing the script does either if or if not, so you can also omit that.

Back to your problem, I'd go ahead and place some check marks in there to see what happens :

Code:
select

Case $Gateway="10.113.0.1"
"We're in CASE Gateway=10.113.0.1" ?
If InGroup("Pri-NL-Administratie")
"And yes, we're ingroup Pri-NL-Administratie" ?
$nul = AddPrinterConnection ("\\amssrv050\HP4300 IFS Administratie PCL6")
EndIf

Case $Gateway="10.113.0.1"
"We're in CASE Gateway=10.113.0.1, HUH???" ?
If InGroup("Pri-NL-Automatisering")
$nul = AddPrinterConnection ("\\amssrv050\HP4000TN Administratie RAYE PS")
EndIf

EndSelect



Allright ... the second case won't made it as the condition is the very same as in first case.
Think you need some reminder of what a select case statement does

Select case statements are mutually exclusive and processed from top: If the first case condition is met the script executes what is in there and continues right after the endselect keyword, all other cases will be ignored

hth

_________________________



Top
#128243 - 2004-10-21 02:09 PM Re: Case / Ingroup
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
beaten again ... by 2
Have to keep it shorter next time
_________________________



Top
#128244 - 2004-10-21 02:40 PM Re: Case / Ingroup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

but why the conditional check on Addprinterconnection?



My guess is to silence the return, or it was a simple copy/paste from the manual.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#128245 - 2004-10-21 10:44 PM Re: Case / Ingroup
Larve_Q Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 8
Thnx for the script… Again (Going to try it first thing in the morning)

I saw there was a little copy/paste error in my sample script. Off course the second case uses a different gateway.

Grtz

Larve


Top
#128246 - 2004-10-21 10:50 PM Re: Case / Ingroup
Larve_Q Offline
Fresh Scripter

Registered: 2004-10-14
Posts: 8
Quote:

Quote:
--------------------------------------------------------------------------------

but why the conditional check on Addprinterconnection?


--------------------------------------------------------------------------------


My guess is to silence the return, or it was a simple copy/paste from the manual.





I’m afraid it’s a simple copy/paste from the manual….

Gtr.

Larve

Top
Page 1 of 1 1


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

Who's Online
1 registered (mole) and 1300 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.028 seconds in which 0.011 seconds were spent on a total of 12 queries. Zlib compression enabled.

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