Jump to content

xcaliber13

Active Members
  • Posts

    205
  • Joined

  • Last visited

Recent Profile Visitors

283 profile views

xcaliber13's Achievements

  1. Have you tried the set default printer function? _PrintMgr_SetDefaultPrinter("Name of your Printer") Func _PrintMgr_SetDefaultPrinter($sPrinterName) Local $iRet = 1 Local $oWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") If NOT IsObj($oWMIService) Then Return SetError(1, 0, 0) Local $oPrinters = $oWMIService.ExecQuery ("Select * from Win32_Printer where DeviceID = '" & $sPrinterName & "'") If NOT IsObj($oPrinters) Then Return SetError(1, 0, 0) For $oPrinter in $oPrinters $iRet = $oPrinter.SetDefaultPrinter() Next Return ($iRet = 0 ? 1 : SetError($iRet, 0, 0)) EndFunc ; ==> _PrintMgr_SetDefaultPrinter
  2. Thank you everyone, TheXman thank you for the explanation. Read the help file many times but just could not see that. Again Thank you
  3. FrancescoDiMuro just a quick simple text file. The script finds the correct line for $sSearch but does not find the correct line for $bSearch test2.txt
  4. I just seem to be missing something with _ArraySearch. I modified the help file just to test what I am trying to do. I am searching an array for "End of Record". From that I want to search backwards and find the first " Begining of Record". But my second search keeps starting at the end of the file. Local $avArray _FileReadToArray("X:\Temp\test2.txt", $avArray, $FRTA_NOCOUNT) ;_ArrayDisplay($avArray, "$avArray") Local $sSearch = "End of Record" Local $bSearch = "Begining of Record" Local $iIndex = _ArraySearch($avArray, $sSearch, 0, 0, 0, 1, 1) MsgBox($MB_SYSTEMMODAL, "iIndex", $iIndex) Local $jIndex = _ArraySearch($avArray, $bSearch, $iIndex, 0, 0, 0, 0) If @error Then MsgBox($MB_SYSTEMMODAL, "Not Found", '"' & $sSearch & '" was not found' & '.') Else MsgBox($MB_SYSTEMMODAL, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & '.'&@CRLF& "encouter was found at "& $jIndex) EndIf What am I doing wrong? Shouldn't $jIndex start the search where $iIndex was found? Thank you any help you can give me.
  5. OK! Now that makes perfect since. Thank you I will continue to work on this script.
  6. TheXMan thank you for taking the time to help. But if that were the case would I not be able to do a _ArrayDisplay right after _FileReadtoArray? The _ArrayDisplay is showing 238303 row 13 columns. I checked each line or at least to the limit that _ArrayDisplay is showing (65524 lines) and each line is 13 cells. Col1 - Col12 Hope I am making some since. Just trying to understand this. Again thank you
  7. Thanks for pointing that out but if I do not have a sleep I am getting this error: "C:\Users\user82\Desktop\WorkingScripts\AdvocateReg.au3" (45) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: No error if there is a sleep. So any other way around this? Am I just missing something else? Thank you And yeah I did not see how long the sleep would add up.
  8. Hello, I have a very large file (over 200,000) lines. I read it to an array and once in the array If 3 cells match the same three cells in the next line down then copy another cell to the first line. And do this for every line that matches. Here is the code I am using. It seems to be working but it has been running for over 12 hours and has not completed. Is there a better way for me to do this? Thank you Local $aArray _FileReadToArray('C:\RegTemp\temp1.txt', $aArray, $FRTA_NOCOUNT, @TAB) Sleep(3000) for $i = 1 to UBound($aArray)-1 step 1 $origRow = $aArray[$i][3] & $aArray[$i][7] & $aArray[$i][12] $1Row = $aArray[$i+1][3] & $aArray[$i+1][7] & $aArray[$i+1][12] $2Row = $aArray[$i+2][3] & $aArray[$i+2][7] & $aArray[$i+2][12] $3Row = $aArray[$i+3][3] & $aArray[$i+3][7] & $aArray[$i+3][12] $4Row = $aArray[$i+4][3] & $aArray[$i+4][7] & $aArray[$i+4][12] $5Row = $aArray[$i+5][3] & $aArray[$i+5][7] & $aArray[$i+5][12] Sleep(5000) If $origRow = $1Row Then $aArray[$i][10] = $aArray[$i][10] &" "& $aArray[$i+1][10] $aArray[$i+1][10] = "" If $origRow = $2Row Then $aArray[$i][10] = $aArray[$i][10] &" "& $aArray[$i+2][10] $aArray[$i+2][10] = "" If $origRow = $3Row Then $aArray[$i][10] = $aArray[$i][10] &" "& $aArray[$i+3][10] $aArray[$i+3][10] = "" If $origRow = $4Row Then $aArray[$i][10] = $aArray[$i][10] &" "& $aArray[$i+4][10] $aArray[$i+4][10] = "" If $origRow = $5Row Then $aArray[$i][10] = $aArray[$i][10] &" "& $aArray[$i+5][10] $aArray[$i+5][10] = "" EndIf EndIf EndIf EndIf EndIf Next _FileWriteFromArray('C:\RegTemp\temp1.txt\temp2.txt', $aArray, Default, Default) _ArrayDisplay($aArray)
  9. jchd thank you does exactly what I needed.
  10. hey guys I just cannot seem to figure out how to get this done. I have a text file within that text file I have records. Each record starts with 01|A. Example: 01|A|Data|Data 02|A|Data|Data 01|A|Data|Data <-- Start of new record 02|A|Data|Data 01|A|Data|Data <-- Start of new record 02|A|Data|Data 02|A|Data|Data 02|A|Data|Data 01|A|Data|Data <-- Start of new record 02|A|Data|Data So what I am trying to do is to get the file to look like this: 01|A|Data|Data 02|A|Data|Data 01|A|Data|Data 02|A|Data|Data 01|A|Data|Data 02|A|Data|Data 02|A|Data|Data 02|A|Data|Data 01|A|Data|Data 02|A|Data|Data Were I am having the issue is when there is more the one(1) line that begins with 02|A|Data|Data. I can only get the first 02|A|Data|Data to move to the same line with the 01|A|Data|Data So I am just trying to get each record on a single line. Here is what I have tried _FileReadToArray("C:\Temp\temp.txt", $aResults, $FRTA_NOCOUNT) Local $aFinalResults[UBound($aResults)] For $i = 0 to UBound($aResults) -1 If StringLeft($aResults[$i], 4) = "01|A" Then $aFinalResults[$i] = $aResults[$i] & " " & $aResults[$i+1] EndIf Next _ArrayDisplay($aFinalResults) _FileWriteFromArray("C:\Temp\temp1.txt", $aFinalResults) I have also tried with a While Wend loop but I am getting the same results. Just the first 02|A|Data|Data line gets moved to the 01|A|Data|Data line. Can someone point me in the right direction to get this working correctly?
  11. Hello everyone I am having a hard time to figure out the correct syntax for an excel formula. I use Global $iLastRow = $oWorkBook.ActiveSheet.UsedRange.Rows.Count Global $iNextRow = $oWorkBook.ActiveSheet.UsedRange.Rows.Count + 2 as my variables. This works _Excel_RangeWrite($oWorkbook, Default, "=SUM(D2:D136)", "D" & $iNextRow) But I want to use $iLastRow in the formula _Excel_RangeWrite($oWorkbook, Default, "=SUM(D2:D"& $iLastRow)"", "D" & $iNextRow) This is just one example of the many different ways I have tried to get this to work without getting a syntax error. What am I doing wrong? Thank you
  12. Radiohead22 at one time I did use excel to do my compares. Very slow. Read your file to an array and do your compare within the array. A lot faster.
  13. detrophy, Not sure if your problem to create a 2D array comes from unequal columns per line. If that is the issue then use this: Global $aArray _FileReadToArray('PathtoyourFile\yourfilename.csv', $aArray, $FRTA_INTARRAYS , ",") $col = 0 For $i = 0 to ubound($aArray) - 1 $col = ubound($aArray[$i]) > $col ? ubound($aArray[$i]) : $col next local $aFinal[0][$col] For $j = 0 to ubound($aArray) - 1 _ArrayAdd($aFinal , _ArrayToString($aArray[$j] , @CRLF) , 0 , @CRLF , ",") Next _ArrayDisplay($aFinal) This will create a 2D array from your csv even if each line is of different lengths.
  14. Thank you Water and Melba23 you got me on the right track to be able to finish the script.
×
×
  • Create New...