jabbadahutt Posted June 5, 2008 Share Posted June 5, 2008 Hi,I am new to AutoIT and this is the first time I have made a post so apologies if it isn't correct.ProblemI have had this a couple of times now, when using FileReadLine to read in the contents of a text file. The text file is only 59kb in size and holds the output from a Net View command. The problem (Error Allocating Memory) occurs when executed in a While loop. Has anyone any ideas?A snapshot of the code is below.....RunWait("h:\DomList.bat" ,"",@SW_HIDE);msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - Net view has run!")$strFile = FileOpen($strDomainList, 0)While 1 $strLine = FileReadLine($strFile) ;msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - $strLine is:" & $strLine) If StringInStr($strLine, "\\SVR") Then $intCharSpaceCount = 0 $intCharCount = 1 $intClientNameFound = 0 While $intClientNameFound <> 1 If StringMid($strLine, $intCharCount, 1) = " " Then ;msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - Character is a space!") $intCharSpaceCount = $intCharSpaceCount + 1 ;msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - Space count is:" & $intCharSpaceCount) If $intCharSpaceCount >= 2 Then ;msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - Space count is:" & $intCharSpaceCount) $intSvrNameEndsAt = $intCharCount - 2 ;msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - $intSvrNameEndsAt is:" & $intSvrNameEndsAt) $strClient = StringMid($strLine,3,($intSvrNameEndsAt - 2)) ;msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - $strClient is:" & $strClient) $intClientNameFound = 1 ExitLoop Else EndIf Else EndIf $intCharCount = $intCharCount + 1 ;msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - $intCharCount is:" & $intCharCount) WEnd $intCharCount = 0 $intCharSpaceCount = 0 $intSvrNameEndsAt = 0 ToolTip("Checking " & $strClient, 0, 0) $strDatVer = RegRead("\\" & $strClient & "\HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\VirusScan Enterprise\CurrentVersion", "szVirDefVer") $strDatDate = RegRead("\\" & $strClient & "\HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\VirusScan Enterprise\CurrentVersion", "szVirDefDate") $strText = $strClient & "," & $strDatVer & "," & $strDatDate & @CRLF OutputToLog($strFileName, $strText) $strText = "" $strDatVer = "" $strDatDate = "" $strClient = "" $intClientCount = $intClientCount + 1 $strText = $strClient & "," & $strDatVer & "," & $strDatDate & @CRLF ;msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - Data should be null!:" & $strText) Else EndIf If @error = -1 Then ExitLoopWendmsgbox(0,"Debug Info","L" & @ScriptLineNumber & " - End of program, " & $intClientCount & " clients scanned!") Func OutputToLog($strFileName, $strText);msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - Entered OutputToLog" & @CRLF & @CRLF & "$strFile is:" & $strFile & @CRLF & "$strText is:" & $strText)$file = FileOpen($strFileName, 1)FileWrite($file, $strText)FileClose($file)$strText = "";msgbox(0,"Debug Info","L" & @ScriptLineNumber & " - Check Output Log")EndFunc Link to comment Share on other sites More sharing options...
Zedna Posted June 5, 2008 Share Posted June 5, 2008 (edited) I don't know reason for memory allocation error but:- for reading file use FileRead() and StringSplit() and FOR NEXT loop- for getting NET VIEW result look at my NET Send GUI wrapper function LoadComputers(): http://www.autoitscript.com/forum/index.ph...st&p=343332EDIT: corrected link Edited June 5, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
jabbadahutt Posted June 5, 2008 Author Share Posted June 5, 2008 I don't know reason for memory allocation error but:- for reading file use FileRead() and StringSplit() and FOR NEXT loop- for getting NET VIEW result look at my NET Send GUI wrapper function LoadComputers(): http://www.autoitscript.com/forum/index.php?s=&showtopic=46016&view=findpost&p=343332Thanks Zedna, I will try that ASAP. Have had a quick look at your code, its interesting to see how many different ways there are to do things. Thanks, will let you know how it works. 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