Sign in to follow this  
Followers 0
Silvinho

Can anybody it help me in a mistake?

10 posts in this topic

obs.: The txt file and the software that I am using are enclosed

change the file cadcli.txt for cadcli.exe

Error

*******************************************************************************************

==> 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 OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

While 1

$Whole_Line = FileReadLine($File)

$Columns = StringSplit($Whole_Line, "|")

$First_Column = $Columns[1]

$Second_Column = $Columns[2]

If @error = -1 Then ExitLoop

WinWaitActive("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}")

Wend

FileClose($file)

************************************************************************************************

The format and content of the txt file are this way:

Silvio Aulik|42

Rosangela Zeni|47

Pedro Zeni|20

Snoopy|08

Nininha|06

Lord|02

CadCli.txt

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 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!"

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0