Silvinho Posted November 22, 2007 Share Posted November 22, 2007 obs.: The txt file and the software that I am using are enclosedchange the file cadcli.txt for cadcli.exeError*******************************************************************************************==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:$Second_Column = $Columns[2]$Second_Column = ^ ERROR********************************************************************************************Run("CadCli.exe")$file = FileOpen("c:\temp\Familia.txt", 0); Check if file opened for reading OKIf $file = -1 ThenMsgBox(0, "Error", "Unable to open file.")ExitEndIfWhile 1$Whole_Line = FileReadLine($File)$Columns = StringSplit($Whole_Line, "|")$First_Column = $Columns[1]$Second_Column = $Columns[2]If @error = -1 Then ExitLoopWinWaitActive("Cadastro de Clientes")ControlClick("Cadastro de Clientes", "", "[CLASS:TEdit;INSTANCE:2]")Send($First_Column)ControlClick("Cadastro de Clientes", "", "[CLASS:TEdit;INSTANCE:1]")Send($Second_Column)ControlClick("Cadastro de Clientes", "", "[CLASS:TButton; TEXT:Gravar; INSTANCE:2]")Send("{ENTER}")WendFileClose($file)************************************************************************************************The format and content of the txt file are this way:Silvio Aulik|42Rosangela Zeni|47 Pedro Zeni|20 Snoopy|08 Nininha|06 Lord|02CadCli.txt Link to comment Share on other sites More sharing options...
Valuater Posted November 22, 2007 Share Posted November 22, 2007 (edited) Just change the error checking from While 1 $Whole_Line = FileReadLine($File) $Columns = StringSplit($Whole_Line, "|") $First_Column = $Columns[1] $Second_Column = $Columns[2] If @error = -1 Then ExitLoop to While 1 $Whole_Line = FileReadLine($File) If @error = -1 Then ExitLoop $Columns = StringSplit($Whole_Line, "|") $First_Column = $Columns[1] $Second_Column = $Columns[2] 8) Edited November 22, 2007 by Valuater Link to comment Share on other sites More sharing options...
Silvinho Posted November 22, 2007 Author Share Posted November 22, 2007 Did not yet solve The mistake still is reproduced. Execute my script.. thanks Just change the error checking from While 1 $Whole_Line = FileReadLine($File) $Columns = StringSplit($Whole_Line, "|") $First_Column = $Columns[1] $Second_Column = $Columns[2] If @error = -1 Then ExitLoop to While 1 $Whole_Line = FileReadLine($File) If @error = -1 Then ExitLoop $Columns = StringSplit($Whole_Line, "|") $First_Column = $Columns[1] $Second_Column = $Columns[2] 8)Le_file_text_FinalVersion.au3 Link to comment Share on other sites More sharing options...
Uten Posted November 22, 2007 Share Posted November 22, 2007 The script has to be ran by people with your kind of locales. So either you have to change it to a English speaking version. Or you have to elaborate with the people trying to help you. 1: Do you understand the error message you posted? Try this code and compare the error messages. local $a[1] $a[0] = "this is the only line" ConsoleWrite($a[1] & @CRLF) Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Uten Posted November 22, 2007 Share Posted November 22, 2007 PS: You allso have a Spanish talking forum at www.autoit.es.. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Silvinho Posted November 23, 2007 Author Share Posted November 23, 2007 I unfortunately do not be getting C:\Documents and Settings\rosesqa\Meus documentos\scr-autoit3\Le_file-text-FinalVersion.au3 (11) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $Second_Column = $Columns[2] $Second_Column = ^ ERROR The script has to be ran by people with your kind of locales. So either you have to change it to a English speaking version. Or you have to elaborate with the people trying to help you. 1: Do you understand the error message you posted? Try this code and compare the error messages. local $a[1] $a[0] = "this is the only line" ConsoleWrite($a[1] & @CRLF) Link to comment Share on other sites More sharing options...
Uten Posted November 23, 2007 Share Posted November 23, 2007 Does not the sample I provided return about the same error message you get in your own project? D:\code\au3\foo.au3 (8) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: ConsoleWrite($a[1] & @CRLF) ConsoleWrite(^ ERROR This error message tels you that you try to access a place in the array that does not exist! So you have to figure out how big your error is and where the information you want in it is. You also have to test if it is as big as you think it is. Or if the function creating the array did return an error? Try this Local $a[1] ArrDump($a) Func ArrDump(ByRef $arr, $err=@error, $line=@ScriptLineNumber) If $err <> 0 then ConsoleWrite("(" & $line & "):=ERROR: (@error:=" & $error & ")" & @CRLF) If Not IsArray($arr) Then ConsoleWrite("(" & $line & "):=WARNING $arr is not an array!!!") Else ConsoleWrite("Array size ->" & UBound($arr) & " Lasst accessible item is: $arr[" & UBound($arr) & @CRLF) EndIf EndFunc Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Silvinho Posted November 23, 2007 Author Share Posted November 23, 2007 I do not believe!!! I added more items in the txt file and there were not anymore problems!!!. Then I just let as 02 items and the script executed without problems... thank's Does not the sample I provided return about the same error message you get in your own project? D:\code\au3\foo.au3 (8) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: ConsoleWrite($a[1] & @CRLF) ConsoleWrite(^ ERROR This error message tels you that you try to access a place in the array that does not exist! So you have to figure out how big your error is and where the information you want in it is. You also have to test if it is as big as you think it is. Or if the function creating the array did return an error? Try this Local $a[1] ArrDump($a) Func ArrDump(ByRef $arr, $err=@error, $line=@ScriptLineNumber) If $err <> 0 then ConsoleWrite("(" & $line & "):=ERROR: (@error:=" & $error & ")" & @CRLF) If Not IsArray($arr) Then ConsoleWrite("(" & $line & "):=WARNING $arr is not an array!!!") Else ConsoleWrite("Array size ->" & UBound($arr) & " Lasst accessible item is: $arr[" & UBound($arr) & @CRLF) EndIf EndFunc Link to comment Share on other sites More sharing options...
Uten Posted November 24, 2007 Share Posted November 24, 2007 Add a linefeed in your file and see the problem reapare.. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
GEOSoft Posted November 24, 2007 Share Posted November 24, 2007 (edited) I was just thinking the same thing Uten. Best to check for blank lines $Columns = StringSplit($Whole_Line, "|") If $Columns[0] >= 2 Then EDIT: better yet $Whole_Line = FileReadLine($File) If StringInStr($Whole_Line, '|') Then $Columns = StringSplit($Whole_Line, "|") Rest of that Code Else ContinueLoop EndIf EDIT 2: (Because I'm brain dead) $Whole_Line = FileReadLine($File) If NOT StringInStr($Whole_Line, '|') Then ContinueLoop Rest of the loop code Edited November 24, 2007 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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