
maxcronjob
Active Members-
Posts
44 -
Joined
-
Last visited
maxcronjob's Achievements

Seeker (1/7)
0
Reputation
-
Adding up a column of numbers
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Okay, I broke out the function that sums up the textfile into a separate script, and sho' nuff, it works as it should. It adds up all the numbers correctly. Now, why the heck does it work OUTSIDE the script? If I have a function that writes to a file, then closes that file, then sleeps for a second, then the next function opens that file with a DIFFERENT filehandle and opens it for reading - it just won't add up the numbers correctly. weird. anyone have any explanations for this behavior? -max -
Adding up a column of numbers
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Hi, I caught that one earlier, with the filenames, and made the adjustment. Thanks. I'm running this as a function within my script right now and it's still only pulling in the first line of the text file. I just included the flag, but I'm still only able to sum the first line of the textfile. I keep thinking it might be the call I'm making in the function preceeding this one: $outputfilename1 = _ArrayToString($aAttrValue, @CR, 3, 3) but I'm just not sure. I'm taking an xml file, writing out the array values above to a text file and then trying to sum up the lines in the textfile, but it's just not happening. _I've tried a bunch of things and I keep getting the same results. I'll try to break this out into its own script, but not sure how I'll do that yet since this function calls other sub-functions. I've been wrapped around this for many hours now and haven't been successful. I'll do some more things and let you know. Thanks for all the help!! -max -
Adding up a column of numbers
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Well, it's adding up the first two rows... but that's it. ?? max -
Adding up a column of numbers
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Not sure why, but it's only reading the first line of the textfile and using that as a 'total', but if I run my main script again, it'll sum up all the lines and include the first line again in the sum too. Now, I'm reading in my values from an array like this, so I'm not using @CRLF. If I use @CRLF in the _ArrayToString, I don't seem to get ANYTHING dumped out into the .txt file: $outputfilename1 = _ArrayToString($aAttrValue, @CR, 3, 3) The function and the textfile are both below: Here's the function: ********************** Func Sum_TestCases1 () $outputfile1 = FileOpen(@ScriptDir & "\Scorecard_Testcases1.csv", 0) sleep(1000) FileClose($outputfile1) $outputfile1 = FileOpen(@ScriptDir & "\Scorecard_Testcases1.csv", 0) sleep(1000) $total = 0 $var = StringSplit(FileRead("C:\A_working\sprint3\Scorecard_Testcases1.txt", FileGetSize("C:\A_working\sprint3\Scorecard_Testcases.txt")), @CR) ;FileWriteLine($Debuglog, "$var = " & $var) For $i = 1 To $var[0] $total = $total + $var[$i] Next FileClose($outputfile1) FileWriteLine($Debuglog, @CRLF & "") FileWriteLine ($Debuglog, "total testcases: " & $total) EndFunc ***************************************** Here's the textfile: *********************************** 5 3 8 15 6 7 9 7 7 8 4 4 7 9 7 5 4 8 12 5 5 5 5 6 5 5 5 5 11 5 5 5 5 5 5 9 6 7 3 3 7 7 3 14 2 5 18 3 6 1 5 **************************************** -max -
Adding up a column of numbers
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
I get an AutoIt Error: $var = StringSplit(FileRead("myfile.txt"), @CRLF) $var = StringSplit(^ ERROR Error: Incorrect number of parameters in function call. I'm using Beta 3.1.1.74 -max -
I have a textfile that contains a column of numbers. I could've even saved this to a .csv file, but in either case, I just don't know how to go about adding up these numbers. This script could dump out a hundred or more lines. any suggestions? thanks! max
-
You guys are awesome! I used the code above and used an _ArrayToString to pull out the piece of the array I was interested in. The piece of code allowed me to roll through the entire xml file and grab exactly what I needed. A simple math function on the end added up the column (separated by @CR) and I'm golden. Thanks much for all the help! -max
-
Dick, I'm using the Dec 15, 2005 version and I don't see it anywhere within that version of the _XMLDomWrapper. -max
-
Dick, Nice work! The popup gave the me the correct number of <testsuite> sections to work with. You included a reference to a function called _XMLGetAllAttribIndex and I'm not seeing that in my _XMLDomWrapper. -max
-
Right on Steve, thanks for the reply. Nice UI, but I'm not sure it's pulling out the right data for me. What I'm trying to do is parse through the entire xml file and hit every <testsuite> section and just pull out the "tests=" value. If you see from the xml I posted, the first section has a "5", meaning 5 tests ran. The second <testsuite> has "3". There might be 20 or 50 more of these and I just want to extract that one value from each section. any ideas? thanks! -max
-
Hmmm.... I'm struggling to figure out a way to step through an xml file and pull values out of a number of sections that look somewhat like this. I'm trying to pull out the tests= values from each section, then my plan is to dump them into a textfile and add them up. First, I'm just not sure how to step through the xml file and pull out just the "tests" value for each section. Any help would be awesome! <testsuite errors="0" failures="0" name="test.com.test.1" tests="5" time="0.274"> <testcase classname="test.com.test.1" name="testGetSessionParmLong" time="0.0050" /> <testcase classname="test.com.test.1" name="testGetSessionParmString" time="0.0" /> <testcase classname="test.com.test.1" name="testChecked" time="0.0" /> <testcase classname="test.com.test.1" name="testParseBoolean" time="0.0" /> <testcase classname="test.com.test.1" name="testGetInitParam" time="0.0" /> <system-out /> <system-err /> </testsuite> <testsuite errors="0" failures="0" name="test.com.test.2" tests="3" time="0.274"> <testcase classname="test.com.test.2" name="testGetSessionParmLong" time="0.0050" /> <testcase classname="test.com.test.2" name="testGetSessionParmString" time="0.0" /> <testcase classname="test.com.test.2" name="testChecked" time="0.0" /> <system-out /> <system-err /> </testsuite> ... ... ... Thanks! Max
-
Read from an array in an .ini file?
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Outstanding reply!!! I didn't think it could be that simple! Thanks!!!! max -
Read from an array in an .ini file?
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
That's all good, but how does one read values from an .ini file into an array? from .ini: [section] string1 string2 string3 .... from code: $ini_test = IniReadSection(@ScriptDir & "\my.ini", "Section") $ini_array = StringSplit($ini_test, @CRLF, 1) For $i = 1 To $ini_array[0] If $ini_array[$i] = $MyTest Then (write output...) Else (write other output...) EndIf Next Thanks, max -
Is this do-able? Has anyone ever created an array from a list in an .ini file and pulled it into a loop in their script? I have a list of strings (123456, ABCDEF, KB890046....) and a huge Case statement that checks for each one of these strings. I'd like to dump all of these strings into an .ini file - somehow - and reduce the Case statement to a single Case that checks for values in the array. I'm not sure how to go about this. Thanks, max
-
Hi, Perhaps I'm going about this the wrong way. I have a script that reads in lines from the "systeminfo" command, then assigns each line to a variable (e.g. $Line_35... $Line_100). I then take that line, run a test on it to look for a particular value using a StringMid, and if the value is in my Case tests, it'll either pass or fail. Trying to create a For loop so I can reduce the lines of code, I created a variable ($linenum) and set a counter at the line number ($num) I want to start at, then increase the count number for the $num so that I can make my way through the line numbers. this procedure creates a name for the Line_Number variables I set originally ( $linenum = "$Line_" & $num) actually prints out as "$Line_35") But when I try to read in the value of that Line_Number in my test $Test = StringMid( $linenum, 28, 4) I get nada. So, when using the $linenum in the test, I'm really trying to get a peek at the value for the $Line_35 variable, but it's not working. variable of a variable? is this possible? Any suggestions? thanks, max