Page 1 of 1 1
Topic Options
#37571 - 2003-03-07 07:25 PM if statements
howyadoing Offline
Getting the hang of it

Registered: 2002-06-01
Posts: 86
Loc: Cincinnati
I have a script that has multiple if else next statements in it. What command would I use to link this to a group with out if ingroup interfering with the other if statements? Example

IF INGROUP (GROUP)
do this with other if statements
else
endif

Top
#37572 - 2003-03-07 07:29 PM Re: if statements
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
IF is just IF regardless of what context you use it in. Ingroup has nothing to do with it.

Just follow the rules of having an ENDIF for every IF and nest them to suit the need.

Perhaps you should provide a better example.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#37573 - 2003-03-07 07:37 PM Re: if statements
howyadoing Offline
Getting the hang of it

Registered: 2002-06-01
Posts: 86
Loc: Cincinnati
This is what I have been working on.
IF INGROUP (group)
code:
 $directory='\\nas1\DFS\SOFTWARE\APPLICATIONS\TEMPLATES'
$destination='%appdata%\MICROSOFT\TEMPLATES'
$templates=enumdir($directory)
FOR EACH $file IN $templates
IF NOT Exist('$destination\$file')
COPY '$directory\$file' '$destination'
ENDIF
NEXT
FUNCTION enumdir($directory, OPTIONAL $mask, OPTIONAL $subdir)
IF $subdir $subdir='/s'
ENDIF
IF Exist("$directory")
$e=wshpipe('%comspec% /c dir "$directory\$mask" /b $subdir',1)
FOR $element = 0 TO UBound($e)
$e[$element]=Left($e[$element],Len($e[$element])-1)
NEXT
$enumdir=$e
ELSE
EXIT 1
ENDIF
ENDFUNCTION
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $WshShell, $oExec, $AllOutput, $Exit, $WshExitCode
$WshErrorMsg=""
$WshShell=CreateObject("WScript.Shell")
$oExec=$WshShell.Exec($ShellCMD)
While $Exit<>1
Dim $Output
Select
Case Not $oExec.StdOut.AtEndOfStream
$Output=$oExec.StdOut.ReadAll
Case Not $oExec.StdErr.AtEndOfStream
$Output=$oExec.StdErr.ReadAll
$WshErrorMsg = $Output
Case 1
$Output=-1
EndSelect
If $Output=-1
If $oExec.Status=1
$Exit=1
Endif
Else
If $NoEcho<>1
? $Output
Endif
$AllOutput = $AllOutput + $Output
Endif
Loop
$WshExitCode=$oExec.ExitCode
$WshPipe=split($AllOutput,chr(10))
Exit($WshExitCode)
EndFunction

ELSE
ENDIF

With the IF statments in the middle it will cause a problem. I need a way to run this based on group membership. Can I do something with a variable?

Top
#37574 - 2003-03-07 07:41 PM Re: if statements
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Your main problem is that you are not using UDFs correctly. The appropriate post in the FAQ Forum has already pointed out to you in the other thread initiated by you, so please read it.
_________________________
There are two types of vessels, submarines and targets.

Top
#37575 - 2003-03-07 07:46 PM Re: if statements
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You shouldn't wrap the UDFs inside the IF condition.
code:
IF INGROUP (group)
FOR EACH $file IN $templates
IF NOT Exist('$destination\$file')
COPY '$directory\$file' '$destination'
ENDIF
NEXT
ENDIF
FUNCTION...

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#37576 - 2003-03-07 08:13 PM Re: if statements
howyadoing Offline
Getting the hang of it

Registered: 2002-06-01
Posts: 86
Loc: Cincinnati
Thanks LLigetfa that worked great. It does exactly what I wanted it to do.
Top
#37577 - 2003-03-07 09:23 PM Re: if statements
howyadoing Offline
Getting the hang of it

Registered: 2002-06-01
Posts: 86
Loc: Cincinnati
I want to do the following.
code:
 IF INGROUP("NOREVERYONE") AND EXIST ("%appdata%\MICROSOFT\TEMPLATES") <> 0

Is there something special I have to put so that both ingroup and exist have to be true for it to go to the next step? Thanks in advance.

Top
#37578 - 2003-03-07 09:25 PM Re: if statements
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please take a look at the FAQ Forum under File Operations
_________________________
There are two types of vessels, submarines and targets.

Top
#37579 - 2003-03-07 09:25 PM Re: if statements
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
that is it...
_________________________
How to ask questions the smart way <-----------> Before you ask

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 696 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.058 seconds in which 0.023 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