kor 5 Posted January 18, 2011 (edited) expandcollapse popupFor $i = 0 to UBound($data)-1 $varaction = $data[$i][6] Select Case $varaction = "new hire" _FormatNameProper() _CreateNewUser() _WaitToExist() _SetADAttributes() Case $varaction = "termination" msgbox(0, '', "user is leaving") Case Else ; error EndSelect Next Func _CreateNewUser() ; Check first to see if user already exists $getattribute = _AD_GetObjectAttribute($username, "sAMAccountName") $doesexist = _AD_ObjectExists($username, "sAMAccountName") If $doesexist = 1 Then EXIT FUNCTION AND MOVE ON ElseIf @error = 1 Then ; do nothing and continue) Else ; dont know what to do EndIf ; Create new user Global $createnewuser = _AD_CreateUser($ou, $username, $firstname & " " & $lastname) If $createnewuser = 1 Then ; success ElseIf @error = 1 Then ; user already exists ElseIf @error = 2 Then ; OU does not exist ElseIf @error = 3 Then ; common name is missing ElseIf @error = 4 Then ; username is missing Else ; dont know what to do EndIf EndFunc ;==> _CreateNewUser() I need to exit the function _CreateNewUser() if the user already exists, but continue is the user doesn't exist. the problem is that _CreateNewUser() is a function that is inside a loop at the top. that loop calls a series of functions. I don't want to exit the script completely because the loop still needs to run through the other users in my excel sheet. How would I exit the function and move onto other functions in the loop without exiting the script entirely? I've searched and seen people use return. But everytime I try and mess around with I get a Scite error saying "Invalid keyword at the start of this line" Edited January 18, 2011 by kor Share this post Link to post Share on other sites
MvGulik 86 Posted January 18, 2011 (edited) nm. Edited January 18, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)"Believing what you know ain't so" ...Knock Knock ... Share this post Link to post Share on other sites
kor 5 Posted January 19, 2011 I figured it out. What I did was create a new function that tests the condition, then assigns a value to a var. Then in the case statement I have a If Then Else to either quit the loop or move on to the other functions. Works great. I'll post the code tomorrow for anyone that stumbles across this thread. Share this post Link to post Share on other sites