EndFunc Posted April 6, 2007 Share Posted April 6, 2007 I have the function I'm trying to do which is supposed to read lines in a txt file but its not working. I tried to use arrays to do it below but its not working. I need it to read everline until its done and output it to an edit box. Is there a way to do this with Arrays? Should I even use arrays to do this? Any help or suggestions is appreciated. Func iRetrieve() ;Retrieve individual files or folders saved during transfer GUICtrlSetData($Console,"Checking for individual files or folders to retrieve." & @CRLF & @CRLF, 1) If FileExists(@ScriptDir & "\statusf") Then $sFile = FileOpen(@ScriptDir & "\statusf", 0) Local $iFRet = FileReadLine(@ScriptDir & "\statusf") Local $fArray = _ArrayCreate($iFRet) For $s = 1 To $fArray[0] ;_ArrayDisplay($fArray[0], $AppTitle) GUICtrlSetData($Console, "Retrieving individual file " & $fArray[$s] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next ElseIf FileExists(@ScriptDir & "\statusd") Then $rFile = FileOpen(@ScriptDir & "\statusd", 0) Local $iDRet = FileReadLine(@ScriptDir & "\statusd") Local $rArray = _ArrayCreate($iDRet) For $r = 1 To $rArray[0] GUICtrlSetData($Console, "Retrieving indiviual folder " & $rArray[$r] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next Else GUICtrlSetData($Console,"No individual files or folders to retrieve." & @CRLF, 1) EndIf EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
BrettF Posted April 6, 2007 Share Posted April 6, 2007 I edit you code to be correct... Spot the difference! Func iRetrieve() ;Retrieve individual files or folders saved during transfer GUICtrlSetData($Console,"Checking for individual files or folders to retrieve." & @CRLF & @CRLF, 1) If FileExists(@ScriptDir & "\statusf.txt") Then $sFile = FileOpen(@ScriptDir & "\statusf.txt", 0) Local $iFRet = FileReadLine(@ScriptDir & "\statusf.txt") Local $fArray = _ArrayCreate($iFRet) For $s = 1 To $fArray[0] _ArrayDisplay($fArray[0], $AppTitle) GUICtrlSetData($Console, "Retrieving individual file " & $fArray[$s] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next ElseIf FileExists(@ScriptDir & "\statusd.txt") Then $rFile = FileOpen(@ScriptDir & "\statusd.txt", 0) Local $iDRet = FileReadLine(@ScriptDir & "\statusd.txt") Local $rArray = _ArrayCreate($iDRet) For $r = 1 To $rArray[0] GUICtrlSetData($Console, "Retrieving indiviual folder " & $rArray[$r] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next Else GUICtrlSetData($Console,"No individual files or folders to retrieve." & @CRLF, 1) EndIf EndFunc I thinks thats what you want... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
EndFunc Posted April 6, 2007 Author Share Posted April 6, 2007 I edit you code to be correct... Spot the difference! Func iRetrieve() ;Retrieve individual files or folders saved during transfer GUICtrlSetData($Console,"Checking for individual files or folders to retrieve." & @CRLF & @CRLF, 1) If FileExists(@ScriptDir & "\statusf.txt") Then $sFile = FileOpen(@ScriptDir & "\statusf.txt", 0) Local $iFRet = FileReadLine(@ScriptDir & "\statusf.txt") Local $fArray = _ArrayCreate($iFRet) For $s = 1 To $fArray[0] _ArrayDisplay($fArray[0], $AppTitle) GUICtrlSetData($Console, "Retrieving individual file " & $fArray[$s] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next ElseIf FileExists(@ScriptDir & "\statusd.txt") Then $rFile = FileOpen(@ScriptDir & "\statusd.txt", 0) Local $iDRet = FileReadLine(@ScriptDir & "\statusd.txt") Local $rArray = _ArrayCreate($iDRet) For $r = 1 To $rArray[0] GUICtrlSetData($Console, "Retrieving indiviual folder " & $rArray[$r] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next Else GUICtrlSetData($Console,"No individual files or folders to retrieve." & @CRLF, 1) EndIf EndFunc I thinks thats what you want... Thanks, but the difference I see is that you put the files with .txt ext on them. I actually left them off on purpose becaues it still writes to it fine but now I'm just trying to read from it. I end up getting nothing. It doesn't error but it doesn't read the file and put the data in the edit box. Any other suggestions? EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
BrettF Posted April 6, 2007 Share Posted April 6, 2007 Thanks, but the difference I see is that you put the files with .txt ext on them. I actually left them off on purpose becaues it still writes to it fine but now I'm just trying to read from it. I end up getting nothing. It doesn't error but it doesn't read the file and put the data in the edit box.Any other suggestions?Ok.... Is there any chance of the full code? It'll make it easier to see how to fix the problem. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
EndFunc Posted April 6, 2007 Author Share Posted April 6, 2007 (edited) Ok.... Is there any chance of the full code? It'll make it easier to see how to fix the problem. Hey ok, I redid after finding _Filereadtoarray() and it half way works now. The problem is it only does the first Case and not both even though both conditions are true. Any suggestions with the Case? The code is pretty long but if you need it can post. While 1 $rMsg = GUIGetMsg() Select Case $rMsg If FileExists(@ScriptDir & "\statusf") Then Local $iFRet If Not _FileReadToArray(@ScriptDir & "\statusf",$iFRet) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $f = 1 To $iFRet[0] GUICtrlSetData($Console, "Retrieving individual file " & $iFRet[$f] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next EndIf Case $rMsg If FileExists(@ScriptDir & "\statusd") Then Local $iDRet If Not _FileReadToArray(@ScriptDir & "\statusd",$iDRet) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $r = 1 To $iDRet[0] GUICtrlSetData($Console, "Retrieving individual folder" & $iDRet[$r] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next EndIf EndSelect ExitLoop WEnd Edited April 6, 2007 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
randallc Posted April 6, 2007 Share Posted April 6, 2007 hi,Case $rMsg; you have not shown the case options "Case $rMsg="1" or whatever, to let a case be chosen?Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
EndFunc Posted April 6, 2007 Author Share Posted April 6, 2007 (edited) hi, ; you have not shown the case options "Case $rMsg="1" or whatever, to let a case be chosen? Randall Geez, all along I had it. I guess I'm tired and need sleep. It works pefect if I just take it out of the loop because its a function. Thanks for the help If FileExists(@ScriptDir & "\statusf") Then Local $iFRet If Not _FileReadToArray(@ScriptDir & "\statusf",$iFRet) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $f = 1 To $iFRet[0] GUICtrlSetData($Console, "Retrieving individual file " & $iFRet[$f] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next EndIf If FileExists(@ScriptDir & "\statusd") Then Local $iDRet If Not _FileReadToArray(@ScriptDir & "\statusd",$iDRet) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $r = 1 To $iDRet[0] GUICtrlSetData($Console, "Retrieving individual folder" & $iDRet[$r] & " saved to " & @ComputerName & @CRLF & @CRLF, 1) Next EndIf Edited April 6, 2007 by EndFunc EndFuncAutoIt is the shiznit. I love it. 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