Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/17/2016 in all areas

  1. This is a printing UDF which allows you to print text in any font, size and colour at any position on the page, draw lines, curves, elipses, pies in any colour, and print images. Useful for labels, reports, graphs and standard forms. Can also print barcodes. It uses my printmg.dll. It is not intended to do the sorts of thing you can do with the Word UDF by big_daddy. Note the dll is 32 bit and so only works with 32 bit applications. printout from the code in the example in the download. Functions available are - Start using/Finish using the UDF _PrintDllStart _PrintDllClose _PrintVersion - Returns version of UDF or dll _PrintSetTitle Printer control _PrintStartPrint _PrintAbort _PrintEndPrint _PrintNewPage Printer selection, getting & setting parameters _PrintListPrinters - lists all installed printers _PrintSetPrinter - manual printer selection dialogue _PrintSelectPrinter - programmatically set the printer. _PrintGetPageWidth _PrintGetPaperWidth _PrintGetPageHeight _PrintGetPaperHeight _PrintGetHorRes _PrintGetVertRes _PrintGetXOffset _PrintGetYOffset _PrintPageOrientation - set portrait or landsacpe Text printing _PrintSetFont - Font, size, attributes and colour _PrintText - At x,y and angle. _PrintGetextWidth _PrintGetTextHeight Graphics _PrintSetLineCol _PrintSetLIneWid _PrintSetBrushCol - sets the colour used for filling _PrintLine _PrintEllipse - Filled ellipse or circle _PrintPie - for filled pie slice _PrintArc - Elliptical or circular arcs _PrintRectangle - filled rectangle _PrintRoundedRectangle _PrintImage - prints jpg, bmp and ico files (Has problems with some icons bigger than 64 x 64) _PrintImageFromDC Latest change = 25th February 2011 Added example to the download which was missing. Get the UDF, dll and example from here. ================================================================= See also these udf's for printing from AutoIt using the Windows API and not using a dll. by GRS - http://www.autoitscript.com/forum/topic/...m-autoit/page__view__findpost_ by Prog@ndy -http://www.autoitscript.com/forum/topic/...gdi-udfs/page__view__findpost_ and this one which embeds a dll in the script for creating pdf files. printing to a pdf by taietel see
    1 point
  2. I just made new UDF. This is an UDF wrapper for windows subst command (Associates a path with a drive letter). Here are examples: #include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include "SubstWrapper.au3" _Subst_Example1() ;~ _Subst_Example2() Func _Subst_Example1() _Subst_SetCallback(ConsoleWrite) ; Generate LONG FILE NAME Local $sFileName = '' For $i = 1 To 25 $sFileName &= '1234567890' Next $sFileName = $sFileName & '.au3' Local $sDestDir = StringLeft(@WindowsDir, 1) & ':\Subst_testing' ; usually C:\Subst_testing Local $sDest = $sDestDir & '\' & $sFileName MsgBox($MB_OK, _ StringLen($sFileName) & ' ' & StringLen($sDest), _ FileCopy(@ScriptFullPath, $sDest, $FC_CREATEPATH + $FC_OVERWRITE) _ ) ; Of course according to: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx ; To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path". ; ; I could use ; FileCopy(@ScriptFullPath, "\\?\" & $sDest, $FC_CREATEPATH + $FC_OVERWRITE) ; ; but for showing how SubstWrapper.au3 works I will not add "\\?\" prefix Local $sDrive = 'r' $sDest = $sDrive & ':\' & $sFileName DirCreate($sDestDir) ; Associates a path with a drive letter. _Subst_Add($sDrive, $sDestDir) If @error Then MsgBox($MB_ICONERROR, '_Subst_Add', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ShellExecute($sDrive & ':') MsgBox($MB_OK, _ StringLen($sFileName) & ' ' & StringLen($sDest), _ FileCopy(@ScriptFullPath, $sDest, $FC_OVERWRITE) _ ) MsgBox($MB_OK, 'Waiting', _ 'Check the content of ' & $sDrive & ':' & @CRLF & _ 'When you Click "OK" button the ' & $sDrive & ': will be Deleted ' & @CRLF & _ 'REMARK: Content should be save - not deleted' _ ) ; Deletes a substituted (virtual) drive. _Subst_Del($sDrive) If @error Then MsgBox($MB_ICONERROR, '_Subst_Del', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndFunc ;==>_Subst_Example1 Func _Subst_Example2() _Subst_SetCallback(ConsoleWrite) ; set drive letter with out colon and backspace Local $sDrive = 's' ; Associates a path with a drive letter. _Subst_Add($sDrive, @WorkingDir) If @error Then MsgBox($MB_ICONERROR, '_Subst_Add', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; list of current virtual drives Local $aResult_outer = _Subst_ListToArray() If @error Then MsgBox($MB_ICONERROR, '_Subst_List', '@error = ' & @error & @CRLF & '@extended = ' & @extended) Local $aResult_inner For $iOuter_idx = 0 To UBound($aResult_outer) - 1 $aResult_inner = $aResult_outer[$iOuter_idx] _ArrayDisplay($aResult_inner, '$aResult_inner[' & $iOuter_idx & ']') Next ShellExecute($sDrive & ':') MsgBox($MB_OK, 'Waiting', _ 'Check the content of ' & $sDrive & ':' & @CRLF & _ 'When you Click "OK" button the ' & $sDrive & ': will be Deleted ' & @CRLF & _ 'REMARK: Content should be save - not deleted' _ ) ; Deletes a substituted (virtual) drive. _Subst_Del($sDrive) If @error Then MsgBox($MB_ICONERROR, '_Subst_Del', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; list of current virtual drives _Subst_List() If @error Then MsgBox($MB_ICONERROR, '_Subst_List', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndFunc ;==>_Subst_Example2 The second example also works (just uncomment them). You can download it here: Have fun. mLipok
    1 point
  3. This is basically two functions (plus supporting infrastructure): _Xbase_ReadToArray($filename, Byref $array, [...]) _Xbase_WriteFromArray($filename, Byref $array, [...]) that transfer all data from one container to the other. Various optional formatting parameters are detailed in the Remarks section of the script; a small test script plus dbf test file (the latter from the (free) Harbour distribution, see here) are provided for your entertainment. Note that the $array variable has to exist already, as it's parsed ByRef, but it does not have to have the correct dimensions. This is pure AutoIt (no SQL, no ADO, no dlls, no external dependencies). The Xbase specification was gleaned from here. There is no support (either currently or planned) for a GUI, or additional functionality; it's just a simple data interface I needed for my MatrixFileConverter for Eigen4Autoit (link in signature), that might be of use to others (see MatrixFileConverter.au3 for an implementation example). One thing to keep in mind is AutoIt's array size limitation (16 MB elements); Xbase files can be considerably larger. On the other hand, AutoIt arrays are less restricted in their number of columns than (certain versions of) Xbase (see script for details). Appropriate error messages will inform you when you've hit these buffers. Xbase.v0.8.7z third beta release
    1 point
  4. mLipok

    SubstWrapper - UDF

    Version 1.0.0

    270 downloads

    I encourted a problem with FilePath Length ( > 260 chars) https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx As a solution I try to use Windows "subst" command: And I make a wrraper UDF for this. Here is example how to use: #include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include "SubstWrapper.au3" _Subst_Example1() ;~ _Subst_Example2() Func _Subst_Example1() _Subst_SetCallback(ConsoleWrite) ; Generate LONG FILE NAME Local $sFileName = '' For $i = 1 To 25 $sFileName &= '1234567890' Next $sFileName = $sFileName & '.au3' Local $sDestDir = StringLeft(@WindowsDir, 1) & ':\Subst_testing' ; usually C:\Subst_testing Local $sDest = $sDestDir & '\' & $sFileName MsgBox($MB_OK, _ StringLen($sFileName) & ' ' & StringLen($sDest), _ FileCopy(@ScriptFullPath, $sDest, $FC_CREATEPATH + $FC_OVERWRITE) _ ) ; Of course according to: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx ; To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path". ; ; I could use ; FileCopy(@ScriptFullPath, "\\?\" & $sDest, $FC_CREATEPATH + $FC_OVERWRITE) ; ; but for showing how SubstWrapper.au3 works I will not add "\\?\" prefix Local $sDrive = 'r' $sDest = $sDrive & ':\' & $sFileName DirCreate($sDestDir) ; Associates a path with a drive letter. _Subst_Add($sDrive, $sDestDir) If @error Then MsgBox($MB_ICONERROR, '_Subst_Add', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ShellExecute($sDrive & ':') MsgBox($MB_OK, _ StringLen($sFileName) & ' ' & StringLen($sDest), _ FileCopy(@ScriptFullPath, $sDest, $FC_OVERWRITE) _ ) MsgBox($MB_OK, 'Waiting', _ 'Check the content of ' & $sDrive & ':' & @CRLF & _ 'When you Click "OK" button the ' & $sDrive & ': will be Deleted ' & @CRLF & _ 'REMARK: Content should be save - not deleted' _ ) ; Deletes a substituted (virtual) drive. _Subst_Del($sDrive) If @error Then MsgBox($MB_ICONERROR, '_Subst_Del', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndFunc ;==>_Subst_Example1 Func _Subst_Example2() _Subst_SetCallback(ConsoleWrite) ; set drive letter with out colon and backspace Local $sDrive = 's' ; Associates a path with a drive letter. _Subst_Add($sDrive, @WorkingDir) If @error Then MsgBox($MB_ICONERROR, '_Subst_Add', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; list of current virtual drives Local $aResult_outer = _Subst_ListToArray() If @error Then MsgBox($MB_ICONERROR, '_Subst_List', '@error = ' & @error & @CRLF & '@extended = ' & @extended) Local $aResult_inner For $iOuter_idx = 0 To UBound($aResult_outer) - 1 $aResult_inner = $aResult_outer[$iOuter_idx] _ArrayDisplay($aResult_inner, '$aResult_inner[' & $iOuter_idx & ']') Next ShellExecute($sDrive & ':') MsgBox($MB_OK, 'Waiting', _ 'Check the content of ' & $sDrive & ':' & @CRLF & _ 'When you Click "OK" button the ' & $sDrive & ': will be Deleted ' & @CRLF & _ 'REMARK: Content should be save - not deleted' _ ) ; Deletes a substituted (virtual) drive. _Subst_Del($sDrive) If @error Then MsgBox($MB_ICONERROR, '_Subst_Del', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; list of current virtual drives _Subst_List() If @error Then MsgBox($MB_ICONERROR, '_Subst_List', '@error = ' & @error & @CRLF & '@extended = ' & @extended) EndFunc ;==>_Subst_Example2 SUPPORT TOPIC IS HERE.
    1 point
  5. Not really ... an event only fires one time and can only fire the next time when it returned from the initial Call. Your original script has this call sequence: GUI() -> Start() -> TrayEvent:Stop() -> GUI() -> Start() So as you can see: the TrayEvent never returns so thinks it is still active. This would be my preferred solution simply Hiding and restoring the same GUI each time: #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> Global $oMyError1 = ObjEvent("AutoIt.Error", "WinhttpError", "IWinHttpRequestEvents") Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") Global $bStop = False Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 1 + 2) Opt("TrayOnEventMode", 1) Global $oStopTray = TrayCreateItem("Stop") TrayItemSetOnEvent(-1, "_stop") $hGUI = GUICreate("Tray Event", 100, 50) $hButton = GUICtrlCreateButton("START", 10, 10, 75, 25) Global $Start_State = 0 GUI() Func GUI() Opt("TrayIconHide", 1) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $hGUI) GUIDelete($hGUI) Exit Case $hButton Start() EndSwitch WEnd EndFunc ;==>GUI Func Start() Opt("TrayIconHide", 0) GUISetState(@SW_HIDE, $hGUI) $Start_State = 1 While $Start_State ;~ $oHTTP.Open("GET", "http://www.google.com") ;~ $oHTTP.Send() ;~ ConsoleWrite($oHTTP.ResponseBody) ConsoleWrite(" Running..") Sleep(5000) WEnd GUISetState(@SW_SHOW, $hGUI) EndFunc ;==>Start Func _stop() $iReply = MsgBox($MB_YESNO + $MB_ICONINFORMATION + $MB_TOPMOST, "STOP???", "Analysis in progress. Do you want to stop the operation?") If $iReply == $IDYES Then $Start_State=0 ConsoleWrite(" Stop selected...") Else Return EndIf EndFunc ;==>_stop Func WinhttpError() ConsoleWrite(@ScriptName & " (" & $oMyError1.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oMyError1.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oMyError1.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oMyError1.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oMyError1.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oMyError1.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oMyError1.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oMyError1.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oMyError1.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oMyError1.retcode) & @CRLF & @CRLF) EndFunc ;==>WinhttpError Jos
    1 point
  6. Not sure if this is what you are looking for??? #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> Global $oMyError1 = ObjEvent("AutoIt.Error", "WinhttpError", "IWinHttpRequestEvents") Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") Global $bStop = False Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 1 + 2) Opt("TrayOnEventMode", 1) Global $oStopTray = TrayCreateItem("Stop") TrayItemSetOnEvent(-1, "_stop") $hGUI = GUICreate("Tray Event", 100, 50) $hButton = GUICtrlCreateButton("START", 10, 10, 75, 25) GUI() Func GUI() Local $bButtonPressed = False Opt("TrayIconHide", 1) GUISetState(@SW_SHOW, $hGUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $hGUI) GUIDelete($hGUI) Exit Case $hButton $bButtonPressed = True GUISetState(@SW_HIDE, $hGUI) ;Start() ExitLoop EndSwitch WEnd If $bButtonPressed Then Start() EndFunc ;==>GUI Func Start() Opt("TrayIconHide", 0) While 1 $oHTTP.Open("GET", "http://www.google.com") $oHTTP.Send() ConsoleWrite($oHTTP.ResponseBody) Sleep(5000) If $bStop Then ExitLoop WEnd EndFunc ;==>Start Func _stop() $bStop = True $iReply = MsgBox($MB_YESNO + $MB_ICONINFORMATION + $MB_TOPMOST, "STOP???", "Analysis in progress. Do you want to stop the operation?") If $iReply == $IDYES Then GUI() Else Return EndIf EndFunc ;==>_stop Func WinhttpError() ConsoleWrite(@ScriptName & " (" & $oMyError1.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oMyError1.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oMyError1.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oMyError1.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oMyError1.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oMyError1.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oMyError1.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oMyError1.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oMyError1.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oMyError1.retcode) & @CRLF & @CRLF) EndFunc ;==>WinhttpError EDIT: the delay in showing the GUI is because of the sleep
    1 point
  7. Maybe like this: #include "WinHttp.au3" $sHost = "http://icecast-qmusic.cdp.triple-it.nl" $sTarget = "Qmusic_nl_fouteuur_96.mp3" $hHttpOpen = _WinHttpOpen() $hHttpConnect = _WinHttpConnect($hHttpOpen, $sHost) $hHttpRequest = _WinHttpOpenRequest($hHttpConnect, Default, $sTarget) _WinHttpSendRequest($hHttpRequest, "Icy-MetaData: 1") _WinHttpReceiveResponse($hHttpRequest) $sYourData = "???" If _WinHttpQueryDataAvailable($hHttpRequest) Then $sYourData = StringRegExpReplace(BinaryToString(_WinHttpReadData($hHttpRequest, 2, 16300)), "(?Us).*?StreamTitle='(.*?)';.*?", "$1") EndIf _WinHttpCloseHandle($hHttpRequest) _WinHttpCloseHandle($hHttpConnect) _WinHttpCloseHandle($hHttpOpen) ConsoleWrite($sYourData & @CRLF) MsgBox(4096, "Your Data...", $sYourData)
    1 point
  8. You were talking to @sadrazc, right?
    1 point
  9. You want to use the $WS_POPUP style and set the width and height to the desktop dimensions #include <GUIConstants.au3> Global $hMain = GUICreate("Example", 600, 400, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX)) Global $btnFullScreen = GUICtrlCreateButton("Fullscreen", 10, 10, 100, 20) Global $aGuiStyle = GUIGetStyle($hMain) ; Save the default styles GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit 0 Case $btnFullScreen Fullscreen() EndSwitch WEnd Func Fullscreen() Local Static $bFullScreen = False $bFullScreen = Not $bFullScreen Switch ($bFullScreen) Case True GUISetStyle($WS_POPUP, -1, $hMain) WinMove($hMain, "", 0, 0, @DesktopWidth, @DesktopHeight) Case False GUISetStyle($aGuiStyle[0], -1, $hMain) WinMove($hMain, "", 0, 0, 600, 400) EndSwitch EndFunc
    1 point
  10. seems a problem with _ArrayUnique try to replace this part of your script: $RetV1 = _ArrayUnique($RetV, 0, 0, 0, 0) $RetV2 = _ArrayUnique($RetV, 1, 0, 0, 0) $RetV3 = _ArrayUnique($RetV, 2, 0, 0, 0) $RetV1 = _ArrayToString($RetV1, "|") $RetV2 = _ArrayToString($RetV2, "|") $RetV3 = _ArrayToString($RetV3, "|") with this: $RetV1 = _ArrayToString($RetV, "|", -1, -1, @CRLF, 0, 0) $RetV2 = _ArrayToString($RetV, "|", -1, -1, @CRLF, 1, 1) $RetV3 = _ArrayToString($RetV, "|", -1, -1, @CRLF, 2, 2) p.s. (just for curiosity) in the following post there was a similar script to achieve the same result...
    1 point
  11. Old thread, but i found it and it was useful in getting me pointed in the right direction, and have a solution to add. This solution takes a two dimensional array of arbitrary size, Sorts it by the first sub-element (eg $array[$i][0]), and then goes through each row and checks each column against every column of the already found array of unique rows. As long as you don't care about the order of the items in the array, this is much faster than the items above ; $a is the array to remove duplicates from ; $ignore is coloms to ignore, "2" will ignore wether $a[$i][2] is unique or not. "1|2" will ignore colom 1 AND 2, etc ; $debug will enable debug messages if set to 1 Func _ArrayUnique2D(ByRef $a, $ignore = "|", $debug = 0) local $colMax = UBound($a, 2)-1, $s, $iUniqueFound = 0 ;This should make things faster and more reliable, so we will know if the current row is the same as a previous row faster _ArraySort($a) ;Start with the larest size return array we might need Dim $aRet[UBound($a)][UBound($a,2)] ;add the first item If $debug Then ConsoleWrite("+ Unique (first row!)"&@CRLF) $iUniqueFound += 1 For $i = 0 to $colMax $aRet[1][$i] = $a[0][$i] Next ;we go down each row of the array For $row = 1 to UBound($a)-1 ;~ ConsoleWrite("> Row "&$Row&@CRLF) ;for every row of unsorted items, go back up the return list of known unique items and ;check each one, row by row, until we find values that don't match (meaning this row is unique) ;or we find a row that is identicle (or run out of rows) (meaning this row is a duplicate and can be skipped) For $rowUnique = $iUniqueFound to 0 step -1 ;sanity checking. if this ever actually happens, something is wrong If $rowUnique > $row Then ContinueLoop If $debug Then ConsoleWrite(" Checking "&$row&" against "&$rowUnique&" ") For $i = 0 to $colMax If $debug Then ConsoleWrite($a[$row][$i]&" = "&$aRet[$rowUnique][$i]&" ") Next If $debug Then ConsoleWrite(@CRLF) ;check all coloms for the two rows for values that are different For $col = 0 to $colMax ;if any of the coloms of the two rows are different, this means the current row is unique If $a[$row][$col] <> $aRet[$rowUnique][$col] Then ;IF it's part of the ignore list then skip it and check the next colom If StringInStr($ignore, "|"&$col&"|") Then ContinueLoop ;If the second, third, etc colom of the row we are checking is different from the unique row we are checking, ;then we know they are not the same and can skip checking the remaining coloms ;Note: Because we sorted them, we know the second the first colom (index 0) is different, we will never run into a duplicate ;so we know we do not need to check any other unique rows for matches. If $col > 0 And $rowUnique > 1 Then ExitLoop ;if we havn't exited the loop to check the next row, or continued the loop because this colom is ignored, this is unique ;Add it to the return array and move on to the next row to start everything again If $debug Then ConsoleWrite("+ Unique! Col: "&$col&@CRLF) $iUniqueFound += 1 For $i = 0 to $colMax $aRet[$iUniqueFound][$i] = $a[$row][$i] Next ExitLoop 2 EndIf ;if it goes through all coloms and it doesn't find any differences then it is a uplicate If $col = $colMax Then If $debug Then ConsoleWrite("- Not unique ("&$rowUnique&") ") For $i = 0 to $colMax ConsoleWrite($a[$row][$i]&" = "&$aRet[$rowUnique][$i]&" ") Next ConsoleWrite(@CRLF) EndIf ExitLoop 2 EndIf Next Next Next _ArrayDelete($aRet, $iUniqueFound+1&"-"&UBound($a)-1) ;~ ConsoleWrite(@error&" "&$iUniqueFound&@CRLF) ;~ exit Return SetExtended($iUniqueFound, $aRet) EndFunc Also supports ignoring rows when checking for differences. If for instance you want an array to have one person from each address $array[$i][0=name, 1=address, 2=city], you set the second parameter to "0" and it will ignore name when considering uniqueness. If two people have different names, but the same address and city, it will consider it duplicate. If anyone can think of ways to optimize this further, let me know
    1 point
  12. wakillon

    StringFinder

    Version 1.2.3

    1,345 downloads

    StringFinder - Find String in Files.
    1 point
  13. no claim of improvement, just another one this returns results in a 2D array col1 contains values contained only in first array, col2 those contained only in the second one, and col3 in both #include <Array.au3> Local $a[11] = [1, 1, 3, 5, 6, 7, 8, 9, 10, 11, 12] Local $b[12] = [1, 2, 2, 3, 4, 5, 6, 8, 10, 12, 13, 14] _ArrayDisplay(_Separate($a, $b)) Func _Separate(ByRef $in0, ByRef $in1) $in0 = _ArrayUnique($in0, 0, Default, Default, 0) $in1 = _ArrayUnique($in1, 0, Default, Default, 0) Local $z[2] = [UBound($in0), UBound($in1)], $low = 1 * ($z[0] > $z[1]), $aTemp[$z[Not $low]][3], $aOut = $aTemp, $aNdx[3] For $i = 0 To $z[Not $low] - 1 If $i < $z[0] Then $aTemp[$i][0] = $in0[$i] If $i < $z[1] Then $aTemp[$i][1] = $in1[$i] Next For $i = 0 To $z[$low] - 1 $x = _ArrayFindAll($aTemp, $aTemp[$i][$low], 0, 0, 1, 0, Not $low) If Not @error Then ; both For $j = 0 To UBound($x) - 1 $aTemp[$x[$j]][2] = 1 Next $aOut[$aNdx[2]][2] = $aTemp[$i][$low] $aNdx[2] += 1 Else ; only in $low $aOut[$aNdx[$low]][$low] = $aTemp[$i][$low] $aNdx[$low] += 1 EndIf Next For $i = 0 To $z[Not $low] - 1 If $aTemp[$i][2] <> 1 Then $aOut[$aNdx[Not $low]][Not $low] = $aTemp[$i][Not $low] $aNdx[Not $low] += 1 EndIf Next ReDim $aOut[_ArrayMax($aNdx)][3] Return $aOut EndFunc ;==>_Separate
    1 point
  14. #include <Array.au3> Global $aCompare1[10] = [1, 3, 5, 6, 7, 8, 9, 10, 11, 12] Global $aCompare2[10] = [1, 2, 3, 4, 5, 6, 8, 10, 12, 13] Global $aBoth[0] For $i = ubound($aCompare1) - 1 to 0 step -1 $iMatch = _ArraySearch($aCompare2 , $aCompare1[$i]) If $iMatch <> -1 then _ArrayAdd($aBoth , $aCompare1[$i]) _ArrayDelete($aCompare1 , $i) _ArrayDelete($aCompare2, $iMatch) EndIf Next For $i = ubound($aCompare2) - 1 to 0 step -1 $iMatch = _ArraySearch($aCompare1 , $aCompare2[$i]) If $iMatch <> -1 then _ArrayAdd($aBoth , $aCompare2[$i]) _ArrayDelete($aCompare2 , $i) _ArrayDelete($aCompare1 , $iMatch) EndIf Next _ArrayDisplay ($aBoth, "In Both") _ArrayDisplay ($aCompare1, "Only in Compare 1") _ArrayDisplay ($aCompare2, "Only in Compare 2")
    1 point
  15. Blip, When you try to read the section with a key of item what do you expect to get? If you can live with a construct like this [Programs] item01=Program item02=Application item03=Exe then it is just a mater of reading the section, finding the highest numbered entry (ubound of the returned array) and creating a new item with the key being "item" concatenated with the ubound of the returned array + 1. kylomas edit: add example This is rough and no error checking but demonstrates the principle #include <GUIConstantsEx.au3> #AutoIt3Wrapper_Add_Constants=n ;---------------------------------------------------------------------------------------- ; Create a test INI file ;---------------------------------------------------------------------------------------- local $inifile = @scriptdir & '\test.ini', $str if not fileexists($inifile) then for $1 = 1 to 10 for $2 = 1 to 5 $str &= chr(random(65,90,1)) Next iniwrite($inifile,"Programs","Item" & stringformat('%02s',$1),$str) $str = '' Next endif ;---------------------------------------------------------------------------------------- ; ADD INI Entry ;---------------------------------------------------------------------------------------- local $gui010 = guicreate('Add an Entry to the Programs Section of my INI File') local $inp010 = guictrlcreateinput('Type Program Name Here',50,50,200,20) local $btn010 = guictrlcreatebutton('Display INI File',50,150,200,20) guisetstate() while 1 switch guigetmsg() case $gui_event_close Exit Case $inp010 _add(guictrlread($inp010)) Case $btn010 shellexecute($inifile) EndSwitch WEnd func _add($pgm) if stringlen(stringstripws($pgm,3)) = 0 then return local $aPrograms = IniReadSection($inifile,"Programs") local $EntryKey = "Item" & stringformat('%02s',$aPrograms[0][0] + 1) iniwrite($inifile,"Programs",$EntryKey,$pgm) endfunc edit2: Note - this only works if all entries are present (not deleted). If an entry is deleted manually then that slot may be overwritten.
    1 point
×
×
  • Create New...