deef99 Posted January 13, 2010 Posted January 13, 2010 I've read and read and read...still not really understanding. This is my test code...I do get the value of $s0 in the Msgbox, but when I go to write it out, $s0 is empty! What am I doing wrong?#include<File.au3>#include "array.au3"#include "Date.au3"#include "String.au3"Global $arrayGlobal $sFileGlobal $al ;array lineGlobal $s0 ;skill 400 levelGlobal $aRecords$sFile = "c:\temp\Test.txt"$read = _FileReadToArray("c:\temp\tt.text", $array)$filenew = FileOpen("c:\temp\tnew.txt",1)If stringRight($array[$al],3) = "400" Then $al = $al+1 $s0 = stringRight($array[$al],1) MsgBox(0,"400",$s0)Endif...FileWriteLine($filenew,"Public Sub Main()")FileWriteLine($filenew,"On Error Resume Next")FileWriteLine($filenew,"set AgMngObj = cvsSrv.AgentMgmt")FileWriteLine($filenew,"ReGlobal SetArr (1,3)")FileWriteLine($filenew,"SetArr(1,1)= 400")FileWriteLine($filenew,"SetArr(1,2)= " & $s0)
omikron48 Posted January 13, 2010 Posted January 13, 2010 (edited) Missing FileClose? #include<File.au3> #include "array.au3" #include "Date.au3" #include "String.au3" Global $array Global $sFile Global $al ;array line Global $s0 ;skill 400 level Global $aRecords $sFile = "c:\temp\Test.txt" $read = _FileReadToArray("c:\temp\tt.text", $array) $filenew = FileOpen("c:\temp\tnew.txt",1) If stringRight($array[$al],3) = "400" Then $al = $al+1 $s0 = stringRight($array[$al],1) MsgBox(0,"400",$s0) Endif ... FileWriteLine($filenew,"Public Sub Main()") FileWriteLine($filenew,"On Error Resume Next") FileWriteLine($filenew,"set AgMngObj = cvsSrv.AgentMgmt") FileWriteLine($filenew,"ReGlobal SetArr (1,3)") FileWriteLine($filenew,"SetArr(1,1)= 400") FileWriteLine($filenew,"SetArr(1,2)= " & $s0) FileClose($filenew) Edited January 13, 2010 by omikron48
deef99 Posted January 13, 2010 Author Posted January 13, 2010 Missing FileClose?I have it ...sorry...forgot to post it . I've been opening the text file once the script is finished to see if the variables are being written out...but they're not. This is frustrating!
Developers Jos Posted January 13, 2010 Developers Posted January 13, 2010 Post a scriptlet that actually reproduces your problem which we can test with. What is posted looks correct so my wild guess would be there is something wrong where you have the "...". Js SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
deef99 Posted January 13, 2010 Author Posted January 13, 2010 Missing FileClose? #include<File.au3> #include "array.au3" #include "Date.au3" #include "String.au3" Global $array Global $sFile Global $al ;array line Global $s0 ;skill 400 level Global $aRecords $sFile = "c:\temp\Test.txt" $read = _FileReadToArray("c:\temp\tt.text", $array) $filenew = FileOpen("c:\temp\tnew.txt",1) If stringRight($array[$al],3) = "400" Then $al = $al+1 $s0 = stringRight($array[$al],1) MsgBox(0,"400",$s0) Endif ... FileWriteLine($filenew,"Public Sub Main()") FileWriteLine($filenew,"On Error Resume Next") FileWriteLine($filenew,"set AgMngObj = cvsSrv.AgentMgmt") FileWriteLine($filenew,"ReGlobal SetArr (1,3)") FileWriteLine($filenew,"SetArr(1,1)= 400") FileWriteLine($filenew,"SetArr(1,2)= " & $s0) FileClose($filenew)
deef99 Posted January 13, 2010 Author Posted January 13, 2010 #include<File.au3> #include "array.au3" #include "Date.au3" #include "String.au3" Global $array Global $sFile Global $al ;array line Global $s0 ;skill 400 level Global $s1 ;skill 401 level Global $s3 ;skill 403 level Global $agt ;701 or 702 ard or cov agent Global $aRecords $sFile = "c:\temp\Test.txt" $read = _FileReadToArray("c:\temp\tt.text", $array) $filenew = FileOpen("c:\temp\tnew.txt",1) $al = 5 While 9 If stringRight($array[$al],3) = "400" Then $al = $al+1 $s0 = stringRight($array[$al],1) $s0 = "2" MsgBox(0,"400",$s0) Else if stringRight($array[$al],3) = "401" Then $al = $al+1 $s1 = stringRight($array[$al],1) $sl = $v1 MsgBox(0,"401",$v1) else if stringRight($array[$al],3) = "403" Then $al = $al+1 $s3 = stringRight($array[$al],1) MsgBox(0,"403",$s3) else if stringRight($array[$al],3) = "701" Then $agt = stringRight($array[$al],1) MsgBox(0,"70x",$agt) Else if stringRight($array[$al],3) = "702" then $agt = stringRight($array[$al],3) MsgBox(0,"70x",$agt) $agt = stringRight($array[$al],3) MsgBox(0,"70x",$agt) EndIf EndIf EndIf EndIf EndIf $al = $al +1 ;MsgBox(0,"",$s0&$s3) ; Write first array to file by string file name FileWriteLine($filenew,$array[1]) FileWriteLine($filenew,"On Error Resume Next") FileWriteLine($filenew,"set AgMngObj = cvsSrv.AgentMgmt") FileWriteLine($filenew,"ReGlobal SetArr (1,3)") filewriteline($filenew,"SetArr(1,1)= 400") filewriteline($filenew,"SetArr(1,2)= " & $s0) filewriteline($filenew,"SetArr(1,3)= 0") filewriteline($filenew,"SetArr(2,1)= 401") filewriteline($filenew,"SetArr(2,2)= " & $s1) filewriteline($filenew,"SetArr(2,3)= 0") filewriteline($filenew,"SetArr(3,1)= 403") filewriteline($filenew,"SetArr(3,2)= " & $s3) filewriteline($filenew,"SetArr(3,3)= 0") filewriteline($filenew,"SetArr(4,1)= " & $agt) filewriteline($filenew,"SetArr(4,2)= 1") filewriteline($filenew,"SetArr(4,3)= 0") filewriteline($filenew,"SetArr(5,1)= 703") filewriteline($filenew,"SetArr(5,2)= 1") filewriteline($filenew,"SetArr(5,3)= 0") filewriteline($filenew,"SetArr(6,1)= 950") filewriteline($filenew,"SetArr(6,2)= 1") filewriteline($filenew,"SetArr(6,3)= 0") FileClose($sFile) FileClose($filenew) WEnd AND HERE IS WHAT IS IN c:\temp\tt.text : Public Sub Main() On Error Resume Next set AgMngObj = cvsSrv.AgentMgmt ReDim SetArr (11,3) SetArr(1,1)= 409 SetArr(1,2)= 8 SetArr(1,3)= 0 SetArr(2,1)= 400 SetArr(2,2)= 1 SetArr(2,3)= 0 SetArr(3,1)= 950 SetArr(3,2)= 1 SetArr(3,3)= 0 SetArr(4,1)= 702 SetArr(4,2)= 1 SetArr(4,3)= 0 SetArr(5,1)= 666 SetArr(5,2)= 52 SetArr(5,3)= 0 SetArr(6,1)= 401 SetArr(6,2)= 4 SetArr(6,3)= 0
Developers Jos Posted January 13, 2010 Developers Posted January 13, 2010 Have you ran it successfully before posting? Unlikely as I get errors from au3check on this line: test.au3(32,13) : WARNING: $v1: possibly used before declaration. $sl = $v1 ~~~~~~~~~^ SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
deef99 Posted January 13, 2010 Author Posted January 13, 2010 Have you ran it successfully before posting? Unlikely as I get errors from au3check on this line: test.au3(32,13) : WARNING: $v1: possibly used before declaration. $sl = $v1 ~~~~~~~~~^ Sorry...that's a stray...I am trying anything at this point to see if I can get the value from the variable. But if you continue, you still don't get any of the other variable data written to the new file.
Developers Jos Posted January 13, 2010 Developers Posted January 13, 2010 (edited) Sorry...that's a stray...I am trying anything at this point to see if I can get the value from the variable. But if you continue, you still don't get any of the other variable data written to the new file. Here is you code formatted. You write the the output after reading the first array entry after which you close the file thus all subsequent writes are failing: expandcollapse popup#include<File.au3> #include "array.au3" #include "Date.au3" #include "String.au3" Global $array Global $sFile Global $al ;array line Global $s0 ;skill 400 level Global $s1 ;skill 401 level Global $s3 ;skill 403 level Global $agt ;701 or 702 ard or cov agent Global $aRecords $read = _FileReadToArray("tt.text", $array) $filenew = FileOpen("tnew.txt", 1) $al = 5 While 9 If StringRight($array[$al], 3) = "400" Then $al = $al + 1 $s0 = StringRight($array[$al], 1) $s0 = "2" MsgBox(0, "400", $s0) Else If StringRight($array[$al], 3) = "401" Then $al = $al + 1 $s1 = StringRight($array[$al], 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s1 = ' & $s1 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console MsgBox(0, "401", $s1) Else If StringRight($array[$al], 3) = "403" Then $al = $al + 1 $s3 = StringRight($array[$al], 1) MsgBox(0, "403", $s3) Else If StringRight($array[$al], 3) = "701" Then $agt = StringRight($array[$al], 1) MsgBox(0, "70x", $agt) Else If StringRight($array[$al], 3) = "702" Then $agt = StringRight($array[$al], 3) MsgBox(0, "70x", $agt) $agt = StringRight($array[$al], 3) MsgBox(0, "70x", $agt) EndIf EndIf EndIf EndIf EndIf $al = $al + 1 ;MsgBox(0,"",$s0&$s3) ; Write first array to file by string file name FileWriteLine($filenew, $array[1]) FileWriteLine($filenew, "On Error Resume Next") FileWriteLine($filenew, "set AgMngObj = cvsSrv.AgentMgmt") FileWriteLine($filenew, "ReGlobal SetArr (1,3)") FileWriteLine($filenew, "SetArr(1,1)= 400") FileWriteLine($filenew, "SetArr(1,2)= " & $s0) FileWriteLine($filenew, "SetArr(1,3)= 0") FileWriteLine($filenew, "SetArr(2,1)= 401") FileWriteLine($filenew, "SetArr(2,2)= " & $s1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s1 = ' & $s1 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console FileWriteLine($filenew, "SetArr(2,3)= 0") FileWriteLine($filenew, "SetArr(3,1)= 403") FileWriteLine($filenew, "SetArr(3,2)= " & $s3) FileWriteLine($filenew, "SetArr(3,3)= 0") FileWriteLine($filenew, "SetArr(4,1)= " & $agt) FileWriteLine($filenew, "SetArr(4,2)= 1") FileWriteLine($filenew, "SetArr(4,3)= 0") FileWriteLine($filenew, "SetArr(5,1)= 703") FileWriteLine($filenew, "SetArr(5,2)= 1") FileWriteLine($filenew, "SetArr(5,3)= 0") FileWriteLine($filenew, "SetArr(6,1)= 950") FileWriteLine($filenew, "SetArr(6,2)= 1") FileWriteLine($filenew, "SetArr(6,3)= 0") FileClose($sFile) FileClose($filenew) WEnd #cs And HERE IS WHAT IS In c:\temp\tt.text : Public Sub Main() On Error Resume Next set AgMngObj = cvsSrv.AgentMgmt ReDim SetArr(11, 3) SetArr(1, 1) = 409 SetArr(1, 2) = 8 SetArr(1, 3) = 0 SetArr(2, 1) = 400 SetArr(2, 2) = 1 SetArr(2, 3) = 0 SetArr(3, 1) = 950 SetArr(3, 2) = 1 SetArr(3, 3) = 0 SetArr(4, 1) = 702 SetArr(4, 2) = 1 SetArr(4, 3) = 0 SetArr(5, 1) = 666 SetArr(5, 2) = 52 SetArr(5, 3) = 0 SetArr(6, 1) = 401 SetArr(6, 2) = 4 SetArr(6, 3) = 0 #ce Move the FileCLose outside the While Wend loop and you know what I mean. By the way: Your script still errors out when you get outside of the Array scope and you never fileclose a filename, only the file Handle returned by FileOpen. Jos Edited January 13, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
deef99 Posted January 13, 2010 Author Posted January 13, 2010 Jos - not sure I totally understand both of your comments [this stuff is greek sometimes!], but I will try to follow this and make the changes. THANK you so very much for your time. I greatly appreciate it! DD Here is you code formatted. You write the the output after reading the first array entry after which you close the file thus all subsequent writes are failing: #include<File.au3> #include "array.au3" #include "Date.au3" #include "String.au3" Global $array Global $sFile Global $al ;array line Global $s0 ;skill 400 level Global $s1 ;skill 401 level Global $s3 ;skill 403 level Global $agt ;701 or 702 ard or cov agent Global $aRecords $read = _FileReadToArray("tt.text", $array) $filenew = FileOpen("tnew.txt", 1) $al = 5 While 9 If StringRight($array[$al], 3) = "400" Then $al = $al + 1 $s0 = StringRight($array[$al], 1) $s0 = "2" MsgBox(0, "400", $s0) Else If StringRight($array[$al], 3) = "401" Then $al = $al + 1 $s1 = StringRight($array[$al], 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s1 = ' & $s1 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console MsgBox(0, "401", $s1) Else If StringRight($array[$al], 3) = "403" Then $al = $al + 1 $s3 = StringRight($array[$al], 1) MsgBox(0, "403", $s3) Else If StringRight($array[$al], 3) = "701" Then $agt = StringRight($array[$al], 1) MsgBox(0, "70x", $agt) Else If StringRight($array[$al], 3) = "702" Then $agt = StringRight($array[$al], 3) MsgBox(0, "70x", $agt) $agt = StringRight($array[$al], 3) MsgBox(0, "70x", $agt) EndIf EndIf EndIf EndIf EndIf $al = $al + 1 ;MsgBox(0,"",$s0&$s3) ; Write first array to file by string file name FileWriteLine($filenew, $array[1]) FileWriteLine($filenew, "On Error Resume Next") FileWriteLine($filenew, "set AgMngObj = cvsSrv.AgentMgmt") FileWriteLine($filenew, "ReGlobal SetArr (1,3)") FileWriteLine($filenew, "SetArr(1,1)= 400") FileWriteLine($filenew, "SetArr(1,2)= " & $s0) FileWriteLine($filenew, "SetArr(1,3)= 0") FileWriteLine($filenew, "SetArr(2,1)= 401") FileWriteLine($filenew, "SetArr(2,2)= " & $s1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s1 = ' & $s1 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console FileWriteLine($filenew, "SetArr(2,3)= 0") FileWriteLine($filenew, "SetArr(3,1)= 403") FileWriteLine($filenew, "SetArr(3,2)= " & $s3) FileWriteLine($filenew, "SetArr(3,3)= 0") FileWriteLine($filenew, "SetArr(4,1)= " & $agt) FileWriteLine($filenew, "SetArr(4,2)= 1") FileWriteLine($filenew, "SetArr(4,3)= 0") FileWriteLine($filenew, "SetArr(5,1)= 703") FileWriteLine($filenew, "SetArr(5,2)= 1") FileWriteLine($filenew, "SetArr(5,3)= 0") FileWriteLine($filenew, "SetArr(6,1)= 950") FileWriteLine($filenew, "SetArr(6,2)= 1") FileWriteLine($filenew, "SetArr(6,3)= 0") FileClose($sFile) FileClose($filenew) WEnd Move the FileCLose outside the While Wend loop and you know what I mean. By the way: Your script still errors out when you get outside of the Array scope and you never fileclose a filename, only the file Handle returned by FileOpen. Jos
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