Brenda1 Posted April 7, 2008 Share Posted April 7, 2008 Hello, I hope you can help me, I am using an array to store users information in order to compare it with another one, every think is ok but when the condition is met, is giving me an error. =s here is the code: While 1 $Labinal_emp = FileReadLine($RH_List) If @error = -1 Then ExitLoop $array = StringSplit($Labinal_emp,";") If $Name = $array[4] Then FileWriteLine($file,"Error en Cmp" & ";" & $Logon & ";" & $Name & ";" & $mail & ";" & $Cmp) EndIf Wend ERROR MSG: D:\Trabajo\AutoIt\ActiveDScript.au3 (87) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $Name = $array[4] Then If $Name = ^ ERROR Note:$Name is having diferent names until the condition is met, and all the files I am using are already open, so that is not the problem. Helppp =) Link to comment Share on other sites More sharing options...
d4rk Posted April 7, 2008 Share Posted April 7, 2008 don't have your code to test, but If $Name[0] = $array[4] Then [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
martin Posted April 7, 2008 Share Posted April 7, 2008 Hello, I hope you can help me, I am using an array to store users information in order to compare it with another one, every think is ok but when the condition is met, is giving me an error. =s here is the code: While 1 $Labinal_emp = FileReadLine($RH_List) If @error = -1 Then ExitLoop $array = StringSplit($Labinal_emp,";") If $Name = $array[4] Then FileWriteLine($file,"Error en Cmp" & ";" & $Logon & ";" & $Name & ";" & $mail & ";" & $Cmp) EndIf Wend ERROR MSG: D:\Trabajo\AutoIt\ActiveDScript.au3 (87) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $Name = $array[4] Then If $Name = ^ ERROR Note:$Name is having diferent names until the condition is met, and all the files I am using are already open, so that is not the problem. Helppp =) Welcome to AutoIt forums I assume that $RH_List is the handle returned by FileOpen. The problem could just be your spelling mistake $array = StringSplit($Labinal_emp,";");<--------missing 't' Otherwise you just need to add some protection against errors and add some debugging code to find out what's wrong. While 1 $Labinal_emp = FileReadLine($RH_List) If @error = -1 Then ExitLoop ConsoleWrite($Labinal_temp & @LF);show the line we just read $array = StringSplit($Labinal_emp, ";") ;if the line had ";" at least 4 times If UBound($array) >= 5 Then If $Name = $array[4] Then;check the the 5th element FileWriteLine($file, "Error en Cmp" & ";" & $Logon & ";" & $Name & ";" & $mail & ";" & $Cmp) EndIf Else ConsoleWrite("$array has " & UBound($array) & " elemnts!" & @CRLF) EndIf WEnd Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Triblade Posted April 7, 2008 Share Posted April 7, 2008 You sure the input ($Labinal_emp) has 4 delimited fields? Use a messagebox to determine $array[0] Simply put, it sounds as if the array doesn't have a [4]. Is the last line it reads complete? Anyway, try this: #include <Array.au3> _ArrayDisplay ( $ar_2DArray [, $sTitle [, $i_ShowOver4000 [, $i_Transpose [, $GUIDataSeparatorChar [, $GUIDataReplace] ] ] ] ] ) Use the _ArrayDisplay($array) just before the If statement where it goes wrong. You will see a table with the array each time it passes. Maybe there is some wrong in the array? Check it out with the above. My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
Brenda1 Posted April 7, 2008 Author Share Posted April 7, 2008 Martin I check if the line had the ";" at least 4 times, and it works thanks , now I have another problem, when the script is at the end of the file and tries to open it to write the information, the "Unable to open file" error msg appears, I tried to put the code in other place but didn't work. do $RH_List = FileOpen("RHList1.csv",0) If $RH_List = -1 Then MsgBox(0,"Error","Unable to open file.") Exit EndIf While 1 $Labinal_emp = FileReadLine($RH_List) If @error = -1 Then ExitLoop $array = StringSplit($Labinal_emp, ";") If UBound($array) >= 5 Then If $Name = $array[4] Then FileWriteLine($file,"Error en Cmp" & ";" & $Logon & ";" & $Name & ";" & $mail & ";" & $Cmp) EndIf Else ConsoleWrite("$array has " & UBound($array) & " elements!" & @CRLF) ConsoleWrite($Labinal_emp & @LF); EndIf Wend EndIf $objRecordSet.MoveNext() Until $objRecordSet.EOF() $objConnection.Close() FileClose($RH_List) FileClose($file) thanks everyone for the help Link to comment Share on other sites More sharing options...
martin Posted April 7, 2008 Share Posted April 7, 2008 Martin I check if the line had the ";" at least 4 times, and it works thanks , now I have another problem, when the script is at the end of the file and tries to open it to write the information, the "Unable to open file" error msg appears, I tried to put the code in other place but didn't work. do $RH_List = FileOpen("RHList1.csv",0) If $RH_List = -1 Then MsgBox(0,"Error","Unable to open file.") Exit EndIf While 1 $Labinal_emp = FileReadLine($RH_List) If @error = -1 Then ExitLoop $array = StringSplit($Labinal_emp, ";") If UBound($array) >= 5 Then If $Name = $array[4] Then FileWriteLine($file,"Error en Cmp" & ";" & $Logon & ";" & $Name & ";" & $mail & ";" & $Cmp) EndIf Else ConsoleWrite("$array has " & UBound($array) & " elements!" & @CRLF) ConsoleWrite($Labinal_emp & @LF); EndIf Wend EndIf $objRecordSet.MoveNext() Until $objRecordSet.EOF() $objConnection.Close() FileClose($RH_List) FileClose($file) thanks everyone for the helpYou have the file open with the read mode if $file is the same file you can't write to it. So instead of writing to the file when there might be more to read, just keep a string which is the total of what has to be written. Start with $ToBeAdded = '' then instead of FileWreiteLine say $ToBeAdded &= "blahblah.." Then when all the reading is finished close the file, open it with mode set to 1 and filewrite($hf,$ToBeAdded) FileClose($hf) Or I misunderstood perhaps. BTW apologies for thinking you had a spelling mistake, I had got my eyes crossed. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Brenda1 Posted April 8, 2008 Author Share Posted April 8, 2008 You have the file open with the read mode if $file is the same file you can't write to it. So instead of writing to the file when there might be more to read, just keep a string which is the total of what has to be written.Start with $ToBeAdded = '' then instead of FileWreiteLine say $ToBeAdded &= "blahblah.."Then when all the reading is finished close the file, open it with mode set to 1 and filewrite($hf,$ToBeAdded)FileClose($hf)Or I misunderstood perhaps.BTW apologies for thinking you had a spelling mistake, I had got my eyes crossed. I found the problem, $file is not the same file, I read from $RH_List and I open $file to write on it, the problem was that I am using an $objRecordSet and a loop, so when the script found the EOF it was trying to open the file again but with no info to write thank youuu. 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