
maxcronjob
Active Members-
Posts
44 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by maxcronjob
-
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
-
Okay, I created a monster script that does a lot of testing and prints out lines to a log file. The log file has a number of PASS and FAIL entries in it. What I need to do is come up with a way to count all the PASS and all the FAIL entries and spit them out at the END of that logfile... I'm wondering if there's a way to do this outside the script rather than going back in and adjusting each PASS and FAIL to increase in count after they've printed out to the log file, then print out the number of counts for each in the end. Any suggestions? thanks, max
-
Can't FileReadLine from a _RegExport file
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Right on! Got it to work! Thanks!!!!! -max -
Can't FileReadLine from a _RegExport file
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
The function wasn't working when I added in the parameter. I went forward and used the "type /c inputfile>outputfile" call before I opened the file to read, so it works now. Thanks for the awesome support! -max -
Can't FileReadLine from a _RegExport file
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Can't seem to find that parameter for the Reg command... This is a Windows 2003 Server OS. -max -
Can't FileReadLine from a _RegExport file
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Hi, As requested, below are 1. the function I'm having a problem with getting the FileReadLine to work right. 2. Below this function is the _RegExport function I'm using 3. Below that is a copy of the gibberish I'm seeing in the Log file where I should be seeing text from the textfile: 1. The main function ************************************************************ Func userSystemConfig() FileWriteLine ( $TestLog, "" & @CRLF) FileWriteLine ( $TestLog, @TAB & "Running user account configuration tests...") FileWriteLine ( $TestLog, "" & @CRLF) FileWriteLine ( $TestLog, "" & @CRLF) ; User RunAsSet along with the _RegExport function to peek at user's HKCU settings RunAsSet ("user", @Computername, "password") ; dumps the HKCU settings into a separate file and reads them from the file _RegExport("HKCU\Control Panel\Desktop", "C:\" & "userTest.txt") RunAsSet() sleep(2000) ; opens the C:\userTest.txt file and reads the info $ListUpdateOutput= FileOpen("C:\userTest.txt", 0) If $ListUpdateOutput = -1 Then FileWriteLine( $TestLog, "ERROR: Unable to open C:\userTest.txt") Exit EndIf ; Here are the lines of information we're extracting from userTest.txt $anything = FileReadLine ( $ListUpdateOutput, 1) $screensaveActive = FileReadLine( $ListUpdateOutput, 27) $wallpaper = FileReadLine( $ListUpdateOutput, 33) ; Test if the ScreenSaver is active $user_screensaveActive_test = StringMid($screensaveActive, 21, 1) FileWriteLine( $TestLog, @TAB & "Checking Screen Saver settings: ") FileWriteLine( $TestLog, "$user_screensaveActive_test: " & $user_screensaveActive_test) FileWriteLine( $TestLog, "$screensaveActive: " & $screensaveActive) FileWriteLine( $TestLog, "$anything: " & $anything) If $user_screensaveActive_test = "0" Then FileWriteLine( $TestLog, "PASS: user's Screen Saver has been deactivated.") FileWriteLine( $TestLog, "" & @CRLF) Else FileWriteLine( $TestLog, "FAIL: user's Screen Saver has NOT been deactivated!") FileWriteLine( $TestLog, "" & @CRLF) EndIf ; Test if wallpaper is installed $user_wallpaper_test = StringMid($wallpaper, 14, 36) FileWriteLine( $TestLog, @TAB & "Checking if Wallpaper is installed: ") FileWriteLine( $TestLog, "$user_wallpaper_test: " & $user_wallpaper_test) FileWriteLine( $TestLog, "$wallpaper: " & $wallpaper) If $user_wallpaper_test = "C:\\WINDOWS\\server_wallpaper.bmp" Then FileWriteLine( $TestLog, "PASS: Server Wallpaper has been installed on user's desktop.") FileWriteLine( $TestLog, "" & @CRLF) ElseIf $user_wallpaper_test = "(None) " Then FileWriteLine( $TestLog, "FAIL: Server Wallpaper has NOT been installed on user's desktop. In fact, user's desktop contains NO wallpaper!") FileWriteLine( $TestLog, "" & @CRLF) Else FileWriteLine( $TestLog, "FAIL: Server Wallpaper has NOT been installed on user's desktop!") FileWriteLine( $TestLog, "" & @CRLF) EndIf ; close the userTest.txt file so we can delete it in Cleanup FileClose($ListUpdateOutput) FileWriteLine( $TestLog, "" & @CRLF) FileWriteLine( $TestLog, "------------------") FileWriteLine ( $TestLog, "" & @CRLF) EndFunc ***************************************************** 2. the _RegExport function ********************************* ; Here's the RegExport function, which is a wrapper for the REG Export function in Windows Func _RegExport($sKey2Export, $sWhere2SaveTo) RunWait(@SystemDir & '\Reg.exe EXPORT "' & $sKey2Export & '" "' & $sWhere2SaveTo & '"', "", @SW_HIDE) If Not FileExists($sWhere2SaveTo) Then SetError(1) Return 0 EndIf SetError(0) Return 1 EndFunc ;==>_RegExport ************************************ 3. The Logfile results: ******************** ------------------ Running user account configuration tests... screensaveActive2: Checking Screen Saver settings: $user_screensaveActive_test: $screensaveActive: $anything: ÿþW FAIL: user's Screen Saver has NOT been deactivated! Checking if Wallpaper is installed: $user_wallpaper_test: $wallpaper: FAIL: Server Wallpaper has NOT been installed on user's desktop! ------------------ Any suggestions? Thanks! max -
Hi, I'm using a _RegExport function that I found on this forum to do a quick check of another user's desktop settings. It basically does a RunAs for that user and dumps some HKCU settings into a textfile. Problem is, when I try to read from the textfile to check some values, I get nada. The file is there and I can open it after the test runs, but during the test if I try a FileRead, I get some gibberish: ypw (but the y has a horizontal : above it and the p has an extended l going through it) ?? any suggestions? Thanks! max
-
Log Off and Log In to another Windows account
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Awesome! thanks! max -
Log Off and Log In to another Windows account
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Okay, I may have a partial solution. Through the forum search I found a nice little function called _RegExport. I set my #include to include that script, setup a function to use "RunAsSet" along with that function and voila - I can see the other user's registry settings without logging off! Anyone have a suggestion on where I might find a Windows file or registry file that lists all the icons a particular user currently has on his desktop? Does such a file or registry file exist? I'm still looking... thanks! max -
Log Off and Log In to another Windows account
maxcronjob replied to maxcronjob's topic in AutoIt General Help and Support
Looks like Windows Server 2003 doesn't have any entries for "DefaultPassword". Would I have to add this to the registry like the AutoAdminLogon? thanks, max