Brenda1 Posted April 9, 2008 Share Posted April 9, 2008 Hi, Having problems with my script, I am opening a file and comparing the data with other information, if some information match, I open another file in order to write that information, the script works ok just for a couple of min, then an error appears saying the file i am reading, can not be open, I was openening the file inside a loop, since I don't know if this is happening because I am able to open the file certain times, I put the "FileOpen"outside the loop, but now the IF in my script is doing nothing, I debugged the code and the 2 files opened normal, the data I am evaluating is ok, but the main IF doesn't work!!!!$RH_List = FileOpen("RHList1.csv",0)If $RH_List = -1 Then MsgBox(0, "Error", "The file RH List can not be open.") ExitEndIf;$logonFile = FileOpen("LogonFile.csv",2)$file = FileOpen("LabinalEmployees.csv",2)If $file = -1 Then ; check if the file is open MsgBox(0, "Error", "The file can not be open.") ExitEndIfDo $objUser = ObjGet("GC://" & $objRecordSet.Fields("distinguishedname").Value)If $objUser.Get("c") = "fr" and $objUser.Get("Company")<> "SVC Labinal" then ;and StringInStr($objUser.Get("Company"),"Labinal")=0 Then While 1 $Labinal_emp = FileReadLine($RH_List) If @error = -1 Then ExitLoop $array = StringSplit($Labinal_emp, ";") If UBound($array) >= 5 Then ;if the line had ";" at least 4 times If $Name = $array[4] Then if StringInStr($Cmp,"Labinal")=0 then If StringInStr($mail,"ext")=0 Then if $Logon= StringStripWS("LF" & StringTrimLeft($array[1],2),8) Then FileWriteLine($file,"Outsourcing in HRList" & ";" &"Company Name is Wrong" & ";" & $Logon & ";" & $Name & ";" & $mail & ";" & $Cmp & ";" & $DName) Else FileWriteLine($file,"Outsourcing in HRList" & ";" &"Company and Logon are Wrong" & ";" & $Logon & ";" & StringStripWS("LF" & StringTrimLeft($array[1],2),8) & ";" & $Name & ";" & $mail & ";" & $Cmp & ";" & $DName) EndIf Else if $Logon= StringStripWS("LF" & StringTrimLeft($array[1],2),8) Then FileWriteLine($file,"Outsourcing in HRList" & ";" & "Company and E-Mail are Wrong" & ";" & $Logon & ";" & $Name & ";" & $mail & ";" & $Cmp & ";" & $DName) Else FileWriteLine($file,"Outsourcing in HRList" & ";" & "Company,Logon and E-Mail are Wrong" & ";" & $Logon & ";" & StringStripWS("LF" & StringTrimLeft($array[1],2),8) & ";" & $Name & ";" & $mail & ";" & $Cmp & ";" & $DName) EndIf EndIf Else If StringInStr($mail,"ext")<>0 Then if $Logon= StringStripWS("LF" & StringTrimLeft($array[1],2),8) Then FileWriteLine($file,"employee in HRList" & ";" &"e-mail is Wrong" & ";" & $Logon & ";" & $Name & ";" & $mail & ";" & $Cmp & ";" & $DName) Else FileWriteLine($file,"employee in HRList" & ";" &"e-mail and Logon are Wrong" & ";" & $Logon & ";" & StringStripWS("LF" & StringTrimLeft($array[1],2),8) & ";" & $Name & ";" & $mail & ";" & $Cmp & ";" & $DName) EndIf Else if $Logon <>StringStripWS("LF" & StringTrimLeft($array[1],2),8) Then ($file,"employee in HRList" & ";" & "Logon is Wrong" & ";" & $Logon & ";" & StringStripWS("LF" & StringTrimLeft($array[1],2),8) & ";" & $Name & ";" & $mail & ";" & $Cmp & ";" & $DName) EndIf EndIf EndIf Else ConsoleWrite("$array has " & UBound($array) & " elements!" & @CRLF) EndIf Wend EndIf ;first if $objRecordSet.MoveNext()Until $objRecordSet.EOF() Link to comment Share on other sites More sharing options...
weaponx Posted April 9, 2008 Share Posted April 9, 2008 I don't see FileClose() called anywhere, without this subsequent attempts to access the file with FileOpen() will fail. Link to comment Share on other sites More sharing options...
TheCreator Posted April 9, 2008 Share Posted April 9, 2008 I'm noticing way to many else statements. An if statement should look like this: if (statement1==statement2) then execute tasks else execute tasks if (statement1<>statement2) endif ~~TheCreator~~Visit http://tysdomain.com for personal software and website solutions. Link to comment Share on other sites More sharing options...
Brenda1 Posted April 9, 2008 Author Share Posted April 9, 2008 I don't see FileClose() called anywhere, without this subsequent attempts to access the file with FileOpen() will fail.I didn't paste but I have them in my code like this:FileClose($RH_List)FileClose($file)So I think that's not the problem, do you know if the "fileopen" function has a limit for reading files? I think that's my problem, in the file I am reading is too much information.... Link to comment Share on other sites More sharing options...
TheCreator Posted April 9, 2008 Share Posted April 9, 2008 something you might wannt to try is _FileReadToArray. it splits up by lines. useful for something like this. ~~TheCreator~~Visit http://tysdomain.com for personal software and website solutions. Link to comment Share on other sites More sharing options...
Brenda1 Posted April 9, 2008 Author Share Posted April 9, 2008 something you might wannt to try is _FileReadToArray. it splits up by lines. useful for something like this.Thanks 4 ur help sta8mnd!!!! you are right, I think this is going to help me too much, I'll test it and comment after. Link to comment Share on other sites More sharing options...
Brenda1 Posted April 10, 2008 Author Share Posted April 10, 2008 something you might wannt to try is _FileReadToArray. it splits up by lines. useful for something like this. Hello again, I am working with this function, and I have all the information I need in the array like this: _FileReadToArray ( "Info.csv", $Iarray ) $Iarray[1]-----> line 1: employeeNumber;EmployeeName line 2 line 3 .... I need to read the array line by line and use this fields(employeeNumber and EmployeeName) separated for me to make some comparisons, how can I do that? Link to comment Share on other sites More sharing options...
weaponx Posted April 10, 2008 Share Posted April 10, 2008 For $X = 0 to $Iarray[0] $temp = StringSplit($Iarray[$X], ";") ConsoleWrite("Name: " & $temp[1] & " Number: " & $temp[2] & @CRLF) Next Link to comment Share on other sites More sharing options...
Brenda1 Posted April 10, 2008 Author Share Posted April 10, 2008 For $X = 0 to $Iarray[0] $temp = StringSplit($Iarray[$X], ";") ConsoleWrite("Name: " & $temp[1] & " Number: " & $temp[2] & @CRLF) Next thanks but it didn't work, maybe I was not very clear with my question, I found the solution anyway, the code is like this: _FileReadToArray ( "HRInfo.csv", Iarray ) $Pos = _ArraySearch (Iarray, $Name, 0, 0, 0, True) Select Case $Pos = -1 MsgBox(0, "Not Found", '"' & $Name & '" was not found in the array.') Case Else $var1= StringMid(Iarray[$Pos],3,6) $var2=StringMid(Iarray[$Pos],StringInStr($barray[$Pos],";")+1) EndSelect the $var1 and $var2 are the variables I want separated, it works!!!! thanks anyway 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