gcue Posted May 20, 2009 Share Posted May 20, 2009 (edited) hello world. functionA calls functionB functionA (builds an array which is later refered to in functionB and functionC) i have this working in another function but not in the one im currently working on. "FunctionA" (being called on by the other two funnctions - array built that's built and later refered to is $avout)expandcollapse popupFunc Dashboard_AltirisBuildArray() Local $aText[3] = ["Dashboard", @TAB & "Status", @TAB & @TAB & "Building Altiris Array"] Local $aParts[3] = [200, 175, -1] $dSTATUS = _GUICtrlStatusBar_Create($dGUI, $aParts, $aText) ; Read file in binary mode $hFile = FileOpen($sFile, 16) $binFileData = FileRead($hFile) FileClose($hFile) ; Change nulls $sFileData = BinaryToString($binFileData, 1) $sFileData = StringReplace($sFileData, Chr(0), "<null>") ; Split lines $avLines = StringSplit($sFileData, @CRLF, 1) Global $avOut[$avLines[0] + 1][2] = [[$avLines[0], ""]]; Start out with minimum two columns ; First loop - for each row For $n = 1 To $avLines[0] ; Split the line $avSplit = StringSplit($avLines[$n], $DELIM) ; Test if more columns are needed If $avSplit[0] > UBound($avOut, 2) Then ReDim $avOut[$avLines[0] + 1][$avSplit[0]] ; Second loop for each column For $x = 1 To $avSplit[0] $avOut[$n][$x - 1] = $avSplit[$x] Next Next Dashboard_Idle() $altiris = True EndFunc ;==>Dashboard_AltirisBuildArrayoÝ÷ Ú«¨µánËb¢pV94oêº^jëh×6Func User_Add() If GUICtrlRead($location) = "" Then MsgBox(262144, "User Add", "Please select a valid location.") Return EndIf If GUICtrlRead($initials) = "" Then MsgBox(262144, "User Add", "Please enter a person's initials.") Return EndIf GUISwitch($User_Add_child) GUICtrlSetState($CLOSE_btn, $GUI_DISABLE) GUICtrlSetState($OK_btn, $GUI_DISABLE) GUICtrlCreateLabel("Searching for " & GUICtrlRead($initials) & "'s assets...", 10, 150) If $altiris = False Then Dashboard_AltirisBuildArray() EndIf $asset = "" $user_found = False $pc_found = False $pc_count = 0 For $u = 1 To $avOut[0][0] If GUICtrlRead($initials) = $avOut[$u][13] Then If $avOut[$u][3] <> "LAPTOP" And $avOut[$u][3] <> "COMPUTER" Then $user_found = True EndIf If $avOut[$u][3] = "LAPTOP" Then $asset = ("L" & $avOut[$u][0]) $pc_found = True $user_found = True $pc_count = $pc_count + 1 If $pc_count > 1 Then ;MsgBox(262144, "", GUICtrlRead($initials) & $pc_count & " " & $asset) IniWrite($aINI, "LOCATIONS", GUICtrlRead($location), GUICtrlRead($location) & "_ASSETS") IniWrite($aINI, GUICtrlRead($location) & "_ASSETS", GUICtrlRead($initials) & $pc_count, $asset) FileWriteLine($aLOG, @UserName & ' "Altiris User Add ' & '(' & GUICtrlRead($initials) & ' - ' & $asset & ')" ' & @MON & "\" & @MDAY & "\" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) GUICtrlCreateLabel("Adding " & $asset & " to Dashboard ", 10, 150) Else ;MsgBox(262144, "", GUICtrlRead($initials) & " " & $asset) IniWrite($aINI, "LOCATIONS", GUICtrlRead($location), GUICtrlRead($location) & "_ASSETS") IniWrite($aINI, GUICtrlRead($location) & "_ASSETS", GUICtrlRead($initials), $asset) FileWriteLine($aLOG, @UserName & ' "Altiris User Add ' & '(' & GUICtrlRead($initials) & ' - ' & $asset & ')" ' & @MON & "\" & @MDAY & "\" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) GUICtrlCreateLabel("Adding " & $asset & " to Dashboard ", 10, 150) EndIf EndIf If $avOut[$u][3] = "COMPUTER" Then $asset = ("D" & $avOut[$u][0]) $pc_found = True $user_found = True $pc_count = $pc_count + 1 If $pc_count > 1 Then IniWrite($aINI, GUICtrlRead($location) & "_ASSETS", GUICtrlRead($initials) & $pc_count, $asset) FileWriteLine($aLOG, @UserName & ' "Altiris User Add ' & '(' & GUICtrlRead($initials) & ' - ' & $asset & ')" ' & @MON & "\" & @MDAY & "\" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) GUICtrlCreateLabel("Adding " & $asset & " to Dashboard ", 10, 150) Else IniWrite($aINI, GUICtrlRead($location) & "_ASSETS", GUICtrlRead($initials), $asset) FileWriteLine($aLOG, @UserName & ' "Altiris User Add ' & '(' & GUICtrlRead($initials) & ' - ' & $asset & ')" ' & @MON & "\" & @MDAY & "\" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC) GUICtrlCreateLabel("Adding " & $asset & " to Dashboard ", 10, 150) EndIf EndIf EndIf Next GUICtrlCreateLabel("Search Complete. ", 10, 150) If $pc_count = 1 Then MsgBox(262144, "User Add", $pc_count & " PC was added to " & GUICtrlRead($location)) EndIf If $pc_count > 1 Then MsgBox(262144, "User Add", $pc_count & " PCs were added to " & GUICtrlRead($location)) EndIf If $user_found = True And $pc_found = False Then MsgBox(262144, "User Add", "No PCs are associated with " & GUICtrlRead($initials)) EndIf If $user_found = False Then MsgBox(262144, "User Add", GUICtrlRead($initials) & " was not found in database.") EndIf DEL_user_add_child() EndFunc ;==>User_AddoÝ÷ Ú«¨µánËb¢p95D¢ ú®¢×ºÚ"µÍ[ÈRÔØØ[ÔÝX] BRYÕRPÝXY ÌÍØ×ÒT H ÉÝÈ ][ÝÉ][ÝÈ[BPQÔÝX] BQ[YRY ÌÍØ[ÈH[ÙH[BQÕRPÝÙ]]J ÌÍÜÝ]Ë ][ÝÐZ[[È[È^I][ÝÊBBQÚØÐ[ÐZ[^J BQ[YIÌÍØÓÝHÑÕRPÝÛÛXÐÞÑÙ]Ý^J ÌÍØ×ÒT BQÜ ÌÍÞHHÈ ÌÍØÓÝÌBBIÌÍØÒTH ÌÍØÓÝÉÌÍÞBBQÕRTÝÚ]Ú ÌÍÜÝX]ØÚ[ BBQÕRPÝÙ]Ý]J ÌÍÐÐSÑSØ ÌÍÑÕRWÑTÐPJBBQÕRPÝÙ]Ý]J ÌÍÔÐÐSØ ÌÍÑÕRWÑTÐPJBBIÌÍÜÝX]H ÌÍØRT [È ][ÝË][ÝÈ [È ÌÍØT [È ][ÝË][ÝÈ [È ÌÍØÒTBQÛØ[ ÌÍÝ[ÌMWVÌMWBBQÛØ[ ÌÍÚHBQÜ ÌÍÚHHLÈÎBBIÌÍÙTH ÌÍÚH ÈBBBIÌÍÚTH ÌÍÜÝX] [È ][ÝË][ÝÈ [È ÌÍÙTBBQÕRPÝÙ]]J ÌÍÜÝ]Ë ][ÝÐÚXÚÚ[È ][ÝÈ [È ÌÍÚT BBBIÌÍÜØØ[H ÌÍØRT [È ][ÝË][ÝÈ [È ÌÍØT BBBRY ÌÍÛ^RTH ÌÍÜØØ[[BBBIÌÍÝ[Ý]HLBBQ[ÙBBBBIÌÍÝ[Ý]H BBQ[YBBT[Ê ÌÍÚT ÌÍÝ[Ý] BBBRYÜ ÝÈ[BBBPÛÛ[YSÛÜBBQ[ÙBBBBUÔÝ BBBBIÌÍØTÝ[HÕÔÓ[YJ ÌÍÚT BBBBRY ÌÍØTÝ[ ÉÝÈ[BBBBPÛÛ[YSÛÜBBBQ[YBBBIÌÍÜÑÝÚHÝ[ÓY ÌÍØTÝ[JBBBBRY ÌÍÜÑÝÚH ][ÝÑ ][ÝÈÜ ÌÍÜÑÝÚH ][ÝÓ ][ÝÈ[BBBBRYÜ[BBBBBPÛÛ[YSÛÜBBBBQ[YBBBBIÌÍØÚXÚÈHÝ[Ò[Ý ÌÍØTÝ[ ][ÝËÑÕTÑTÐTÔÕTÓÓI][ÝÊBBBBBRY ÌÍØÚXÚÈ ÉÝÈ[BBBBBIÌÍØTÝ[HÝ[ÔXÙJ ÌÍØTÝ[ ][ÝËÑÕTÑTÐTÔÕTÓÓI][ÝË ][ÝÉ][ÝÊBBBBBQ[YBBBBIÌÍÝ[ÉÌÍÚVÌWHH ÌÍØTÝ[BBBBIÌÍÚH ÌÍÚ ÈBBBBQ[YBBQ[YBS^BQ[H ÌÍÚÈHBQÜ ÌÍÚÈHÈ ÌÍÚHBBBQ[[Û]ÜÊ ÌÍÝ[ÉÌÍÚ×VÌWJBBS^S^QÕRPÝÙ]]J ÌÍÜÝ]Ë ][ÝÐÛÛ]K][ÝÊBSÙÐÞ M ][ÝÐYÜÈÛHÝX] ÊI][ÝË ][ÝÔØØ[ÛÛ]K][ÝÊBUÔÚ]ÝÛ BQSÜÝX]ØÚ[ B[[ÈÏOIÝÒRÔØØ[ÔÝX] Edited May 20, 2009 by gcue Link to comment Share on other sites More sharing options...
weaponx Posted May 20, 2009 Share Posted May 20, 2009 Easy just change to KÕRPÝXY Link to comment Share on other sites More sharing options...
gcue Posted May 20, 2009 Author Share Posted May 20, 2009 oops! the edit caused that Link to comment Share on other sites More sharing options...
TurionAltec Posted May 20, 2009 Share Posted May 20, 2009 Define NOT WORKING Error messages, unexpected functioning? Is there a line it's getting hung up on? One thing I can think of is $altiris being declared globally somewhere? It might not hurt to declare all your global variables at the start of your main script if you're not already. Link to comment Share on other sites More sharing options...
gcue Posted May 20, 2009 Author Share Posted May 20, 2009 i am declaring it.. (sorry entire script is over 17k lines long) not working.. meaning that the "functionA" doesnt seem to be running bc the array isnt being built.. Link to comment Share on other sites More sharing options...
TurionAltec Posted May 20, 2009 Share Posted May 20, 2009 Which one's "FunctionA" or is that another function in your 17k lines? I thought Dashboard_AltirisBuildArray() was Function B (because it build an array)? >>"functionA" doesnt seem to be running bc the array isnt being built Rather than relying on it not running because the array isn't being built, if you pop a: msgbox(0,"Function A", "Function A has started") Do you get a msgbox? Link to comment Share on other sites More sharing options...
gcue Posted May 20, 2009 Author Share Posted May 20, 2009 functionA is the one that builds the array (Dashboard_AltirisBuildArray() ) the other functions call it one of them works the other one doesnt. ya i put in a msgbox, doesnt seem like its being built Link to comment Share on other sites More sharing options...
TurionAltec Posted May 20, 2009 Share Posted May 20, 2009 Function A builds arrays? But you said above: functionB (builds an array which is later refered to in functionA)Maybe you should just talk in actual function names rather than assigning them random variables as names. By "the other function" that doesn't work I'm guessing you mean IH_Scan_Subnet()? If $altiris = False Then GUICtrlSetData($status, "Building Altiris Array") Dashboard_AltirisBuildArray() EndIf Does the GUI status indicate that it's building the array? Does this do anything? msgbox(0,"$altiris",$altiris) consolewrite($altiris&@CRLF) If $altiris = False Then GUICtrlSetData($status, "Building Altiris Array") Dashboard_AltirisBuildArray() EndIf Link to comment Share on other sites More sharing options...
gcue Posted May 20, 2009 Author Share Posted May 20, 2009 (edited) oops sorry you're right i mixed up functionA and functionB (made correction in initial post) yes $altiris at that point is false If $altiris = False Then msgbox(0,"$altiris",$altiris) GUICtrlSetData($status, "Building Altiris Array") Dashboard_AltirisBuildArray() EndIf Edited May 20, 2009 by gcue Link to comment Share on other sites More sharing options...
weaponx Posted May 20, 2009 Share Posted May 20, 2009 You need to learn to implement debugging aids into your functions. Any place in your function where something can fail insert "Return SetError(X,0,0)" where X starts at 1. So you would have this: Something() Switch @ERROR Case 1 ConsoleWrite("ERROR: DoStuff" & @CRLF) Case 2 ConsoleWrite("ERROR: DoMoreStuff" & @CRLF) Case 3 ConsoleWrite("ERROR: DoEvenMoreStuff" & @CRLF) EndSwitch Func Something() $result1 = DoStuff() If $result = "" Then Return SetError(1,0,0) $result2 = DoMoreStuff() If $result2 = "" Then Return SetError(2,0,0) $result3 = DoEvenMoreStuff() If $result3 = "" Then Return SetError(3,0,0) EndFunc Not rocket science. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now