Alitai Posted October 7, 2019 Share Posted October 7, 2019 (edited) Hope this does not already exist? If not have fun with it. expandcollapse popup#include "ArrayDisplayInternals.au3" #include "AutoItConstants.au3" #include "MsgBoxConstants.au3" #include "StringConstants.au3" Local $aArray[4] = [11, 22, 33, 44] Local $iSize2 = 3 Local $aArrayCombo = _ArrayPermute($aArray, ",") _ArrayDisplay($aArrayCombo, "Text") Func _ArrayPermute(ByRef $aArray, $sDelimiter = "") If $sDelimiter = Default Then $sDelimiter = "" If Not IsArray($aArray) Then Return SetError(1, 0, 0) If UBound($aArray, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(2, 0, 0) Local $iSize = UBound($aArray), $iFactorial = 1, $aIdx[$iSize], $aResult[1], $iCount = 1 If UBound($aArray) Then For $i = 0 To $iSize - 1 $aIdx[$i] = $i Next For $i = $iSize To 1 Step -1 $iFactorial *= $i Next ReDim $aResult[$iFactorial + 1] $aResult[0] = $iFactorial __Array_ExeterInternal($aArray, 0, $iSize, $sDelimiter, $aIdx, $aResult, $iCount) Else $aResult[0] = 0 EndIf Return $aResult EndFunc ;==>_ArrayPermute Func __Array_ExeterInternal(ByRef $aArray, $iStart, $iSize, $sDelimiter, ByRef $aIdx, ByRef $aResult, ByRef $iCount) If $iStart == $iSize - 1 Then For $i = 0 To $iSize2 - 1 $aResult[$iCount] &= $aArray[$aIdx[$i]] & $sDelimiter Next If $sDelimiter <> "" Then $aResult[$iCount] = StringTrimRight($aResult[$iCount], StringLen($sDelimiter)) $iCount += 1 Else Local $iTemp For $i = $iStart To $iSize - 1 $iTemp = $aIdx[$i] $aIdx[$i] = $aIdx[$iStart] $aIdx[$iStart] = $iTemp __Array_ExeterInternal($aArray, $iStart + 1, $iSize, $sDelimiter, $aIdx, $aResult, $iCount) $aIdx[$iStart] = $aIdx[$i] $aIdx[$i] = $iTemp Next EndIf EndFunc ;==>__Array_ExeterInternal Func _ArrayDisplay(Const ByRef $aArray, $sTitle = Default, $sArrayRange = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default) #forceref $vUser_Separator Local $iRet = __ArrayDisplay_Share($aArray, $sTitle, $sArrayRange, $iFlags, Default, $sHeader, $iMax_ColWidth, 0, False) Return SetError(@error, @extended, $iRet) EndFunc ;==>_ArrayDisplay Output: (44, 11, 22) (44, 33, 11) (33, 22, 11) (44, 11, 33) (33, 11, 44) (22, 11, 33) (22, 33, 11) (22, 33, 44) (11, 22, 44) (11, 44, 22) (22, 44, 33) (33, 11, 22) (44, 33, 22) (44, 22, 33) (11, 33, 44) (22, 44, 11) (22, 11, 44) (33, 44, 11) (11, 33, 22) (11, 22, 33) (44, 22, 11) (33, 22, 44) (33, 44, 22) (11, 44, 33) Regards Alitai Edited October 7, 2019 by Alitai Link to comment Share on other sites More sharing options...
jchd Posted October 7, 2019 Share Posted October 7, 2019 You're making it way too complex and the output is incomplete. Keep it simple instead: Local $aArray = [11, 22, 33, 44] Local $aP = _ArrayPermute($aArray, ",") _ArrayDelete($aP, 0) For $i = 0 To UBound($aP) - 1 $aP[$i] = "(" & StringRegExpReplace($aP[$i], "(,[^,]+$)", ")") Next _ArrayDisplay($aP) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Alitai Posted October 7, 2019 Author Share Posted October 7, 2019 (edited) 1 hour ago, jchd said: You're making it way too complex and the output is incomplete. Keep it simple instead: Local $aArray = [11, 22, 33, 44] Local $aP = _ArrayPermute($aArray, ",") _ArrayDelete($aP, 0) For $i = 0 To UBound($aP) - 1 $aP[$i] = "(" & StringRegExpReplace($aP[$i], "(,[^,]+$)", ")") Next _ArrayDisplay($aP) Sorry but my output is not incomplete. Edit: It was a issue while i did copy paste it's fixed now. 😅 It's 100% correct. It's wrong when you do follow: Local $aArray[7] = [11, 22, 33, 44, 55, 66, 77] Local $iSize2 = 5 And arraypermute is brocken too. Here is the Fix: For $i = $iSize To 1 Step -1 $iFactorial *= $i Next $iSize3 = UBound($aArray) ;---Fix $iSize4 = $iSize3 - $iSize2 ;---Fix $iFactorial = $iFactorial / $iSize4 ;---Fix But this breaks then "__Array_ExeterInternal". I already reported this to the Autoit Team. Regards Alitai Edited October 7, 2019 by Alitai Link to comment Share on other sites More sharing options...
jchd Posted October 7, 2019 Share Posted October 7, 2019 2 minutes ago, Alitai said: Sorry but my output is not incomplete. Are you sure? Here are missing lines: (33, 44, 22) (44, 11, 22) (44, 11, 33) (44, 22, 11) (44, 22, 33) (44, 33, 11) (44, 33, 22) And why is my code wrong? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Alitai Posted October 7, 2019 Author Share Posted October 7, 2019 2 minutes ago, jchd said: Are you sure? Here are missing lines: (33, 44, 22) (44, 11, 22) (44, 11, 33) (44, 22, 11) (44, 22, 33) (44, 33, 11) (44, 33, 22) And why is my code wrong? Your Code isn't wrong. You give 4 in and get 4 back. I give 4 in and get 3 back. I corrected it above. The missing lines are now there. Copy Paste issue. Link to comment Share on other sites More sharing options...
jchd Posted October 7, 2019 Share Posted October 7, 2019 3 minutes ago, Alitai said: You give 4 in and get 4 back. I give 4 in and get 3 back. Did you run it? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Alitai Posted October 7, 2019 Author Share Posted October 7, 2019 1 minute ago, jchd said: Did you run it? Yes both. Yours: 4 in and result: (11,22,33,44) -> 4 out My: 4 in and result: (44, 11, 22) -> 3 out I hope you can see what i mean now? Link to comment Share on other sites More sharing options...
jchd Posted October 7, 2019 Share Posted October 7, 2019 (edited) I don't get it! Added whitespace in output format and display title. Local $aArray = [11, 22, 33, 44] Local $aP = _ArrayPermute($aArray, ", ") _ArrayDelete($aP, 0) For $i = 0 To UBound($aP) - 1 $aP[$i] = "(" & StringRegExpReplace($aP[$i], "(, [^,]+$)", ")") Next _ArrayDisplay($aP, "My result") Here's my output: Edited October 7, 2019 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Alitai Posted October 7, 2019 Author Share Posted October 7, 2019 (edited) 9 minutes ago, jchd said: I don't get it! Here's my output: ahhh i see. but what do you change if you want Local $aArray = [11, 22, 33, 44, 55, 66, 77] and 5 out? Edited October 7, 2019 by Alitai Link to comment Share on other sites More sharing options...
jchd Posted October 7, 2019 Share Posted October 7, 2019 Trivial: Local $aArray = [11, 22, 33, 44, 55, 66, 77] Local $aP = _ArrayPermute($aArray, ", ") _ArrayDelete($aP, 0) For $i = 0 To UBound($aP) - 1 $aP[$i] = "(" & StringRegExpReplace($aP[$i], "(, [^,]+, [^,]+$)", ")") Next _ArrayDisplay($aP, "My result") This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Alitai Posted October 7, 2019 Author Share Posted October 7, 2019 2 minutes ago, jchd said: Trivial: Local $aArray = [11, 22, 33, 44, 55, 66, 77] Local $aP = _ArrayPermute($aArray, ", ") _ArrayDelete($aP, 0) For $i = 0 To UBound($aP) - 1 $aP[$i] = "(" & StringRegExpReplace($aP[$i], "(, [^,]+, [^,]+$)", ")") Next _ArrayDisplay($aP, "My result") Cool but now you run in the same Problem as i do. 5040 is wrong. It muste be 2520. The arraypermute code is wrong. Link to comment Share on other sites More sharing options...
jchd Posted October 7, 2019 Share Posted October 7, 2019 OK, when there is more than 1 element left out, we get dups. Then: Local $aArray = [11, 22, 33, 44, 55, 66, 77] Local $aP = _ArrayPermute($aArray, ", ") _ArrayDelete($aP, 0) For $i = 0 To UBound($aP) - 1 $aP[$i] = "(" & StringRegExpReplace($aP[$i], "(, [^,]+, [^,]+$)", ")") Next $aP = _ArrayUnique($aP) _ArrayDelete($aP, 0) _ArrayDisplay($aP, "My result") This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Alitai Posted October 7, 2019 Author Share Posted October 7, 2019 2 minutes ago, jchd said: OK, when there is more than 1 element left out, we get dups. Then: Local $aArray = [11, 22, 33, 44, 55, 66, 77] Local $aP = _ArrayPermute($aArray, ", ") _ArrayDelete($aP, 0) For $i = 0 To UBound($aP) - 1 $aP[$i] = "(" & StringRegExpReplace($aP[$i], "(, [^,]+, [^,]+$)", ")") Next $aP = _ArrayUnique($aP) _ArrayDelete($aP, 0) _ArrayDisplay($aP, "My result") WOW! You are a genius. If you add 88 and 99 ............. it's wrong again. But i think it's fine for now. Thank you so much. 🤗 Link to comment Share on other sites More sharing options...
jchd Posted October 7, 2019 Share Posted October 7, 2019 (edited) You can parametrize the number of elements in output: Local $aArray = [11, 22, 33, 44, 55, 66, 77] Local $aRes _ArrayPermutePartial($aArray, $aRes, 3, ", ") _ArrayDisplay($aRes, "My result") Func _ArrayPermutePartial(ByRef $aIn, ByRef $aOut, $iCount, $sDelim) $aOut = _ArrayPermute($aIn, ", ") _ArrayDelete($aOut, 0) Local $sPattern = "(" & _StringRepeat(", [^,]+", UBound($aIn) - $iCount) & ")$" For $i = 0 To UBound($aOut) - 1 $aOut[$i] = "(" & StringRegExpReplace($aOut[$i], $sPattern, ")") Next $aOut = _ArrayUnique($aOut) _ArrayDelete($aOut, 0) EndFunc It's also possible and more efficient to merge the permutations of combinations, as I once showed in reply to a somehow similar request. See Edited October 7, 2019 by jchd Alitai 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
water Posted October 7, 2019 Share Posted October 7, 2019 BTW: When you reply to a post do not use the "Quote" button - we know what we have written Simply add your reply at the end of this page and then press the "Submit Reply" button. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
jchd Posted October 9, 2019 Share Posted October 9, 2019 (edited) @Alitai, It appears that what you're looking for is called "Arrangements", despite there is no unambiguous english term for that computation. Mathematically the cardinal of this set is written and it's equal to That's is the number of ways to pick k distinct items as an ordered k-tuple from a set of n distinct objects. What the AutoIt function _ArrayCombinations() compute is the set of the combinations, picking k distinct items as an unordered k-tuple from a set of n distinct objects. We have Building a list of arrangements isn't hard and here's a function for doing so: Local $a = [1,2,3,4,5] _ArrayDisplay(_ArrayArrangements($a, 3)) Func _ArrayArrangements(ByRef $aIn, $k, $sDelim = ",") Local $aOut[0] If $k > 0 And $k <= UBound($aIn) Then Local $aComb = _ArrayCombinations($aIn, $k, $sDelim) Local $p _ArrayDelete($aComb, 0) For $a In $aComb $p = _ArrayPermute(StringSplit($a, $sDelim, 3), $sDelim) _ArrayDelete($p, 0) _ArrayAdd($aOut, $p, 0, $sDelim) Next EndIf _ArraySort($aOut) ; optional Return $aOut EndFunc EDIT: beware that if items are strings which may contain default delimiter, then you'll have to select something more robust to avoid unwanted string split, i.e. ChrW(0xFFFD). Edited October 9, 2019 by jchd Warning This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Alitai Posted October 9, 2019 Author Share Posted October 9, 2019 I finally fixed it: expandcollapse popup#include "ArrayDisplayInternals.au3" #include "AutoItConstants.au3" #include "MsgBoxConstants.au3" #include "StringConstants.au3" #include "FileConstants.au3" $sFileName = @ScriptDir &"\24.txt" $hFilehandle = FileOpen($sFileName, $FO_APPEND) Local $aArray[7] = [11, 22, 33, 44, 55, 66, 77] Local $iSize2 = 5 Local $aArrayCombo = _ArrayPermute($aArray, ",") _ArrayDisplay($aArrayCombo, "Text") _FileWriteFromArray($hFilehandle, $aArrayCombo) Func _ArrayPermute(ByRef $aArray, $sDelimiter = "") If $sDelimiter = Default Then $sDelimiter = "" If Not IsArray($aArray) Then Return SetError(1, 0, 0) If UBound($aArray, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(2, 0, 0) Local $iSize = UBound($aArray), $iFactorial = 1, $aIdx[$iSize], $aResult[1], $iCount = 1 If UBound($aArray) Then For $i = 0 To $iSize - 1 $aIdx[$i] = $i Next For $i = $iSize To 1 Step -1 $iFactorial *= $i Next $n = UBound($aArray) ;---Fix $iSize4 = $n - $iSize2 ;---Fix Local $iFactorial2 = 1 For $i = $iSize4 To 1 Step -1 ;---Fix $iFactorial2 *= $i ;---Fix Next $iFactorial = $iFactorial / $iFactorial2 ;---Fix ReDim $aResult[$iFactorial + 1] $aResult[0] = $iFactorial Global $a ;-> Fix Global $b ;-> Fix Local $c = 1 ;-> Fix $a = $isize2 - $isize ;-> Fix $b = $a - $c ;-> Fix __Array_ExeterInternal($aArray, 0, $iSize, $sDelimiter, $aIdx, $aResult, $iCount) Else $aResult[0] = 0 EndIf Return $aResult EndFunc ;==>_ArrayPermute Func __Array_ExeterInternal(ByRef $aArray, $iStart, $iSize, $sDelimiter, ByRef $aIdx, ByRef $aResult, ByRef $iCount) If $iStart == $iSize + $a Then ;-> Fix For $i = 0 To $iSize + $b ;-> Fix $aResult[$iCount] &= $aArray[$aIdx[$i]] & $sDelimiter Next If $sDelimiter <> "" Then $aResult[$iCount] = StringTrimRight($aResult[$iCount], StringLen($sDelimiter)) $iCount += 1 Else Local $iTemp For $i = $iStart To $iSize - 1 $iTemp = $aIdx[$i] $aIdx[$i] = $aIdx[$iStart] $aIdx[$iStart] = $iTemp __Array_ExeterInternal($aArray, $iStart + 1, $iSize, $sDelimiter, $aIdx, $aResult, $iCount) $aIdx[$iStart] = $aIdx[$i] $aIdx[$i] = $iTemp Next EndIf EndFunc ;==>__Array_ExeterInternal Func _ArrayDisplay(Const ByRef $aArray, $sTitle = Default, $sArrayRange = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default) #forceref $vUser_Separator Local $iRet = __ArrayDisplay_Share($aArray, $sTitle, $sArrayRange, $iFlags, Default, $sHeader, $iMax_ColWidth, 0, False) Return SetError(@error, @extended, $iRet) EndFunc ;==>_ArrayDisplay Func _FileWriteFromArray($sFilePath, Const ByRef $aArray, $iBase = Default, $iUBound = Default, $sDelimiter = "|") Local $iReturn = 0 ; Check if we have a valid array as an input. If Not IsArray($aArray) Then Return SetError(2, 0, $iReturn) ; Check the number of dimensions is no greater than a 2d array. Local $iDims = UBound($aArray, $UBOUND_DIMENSIONS) If $iDims > 2 Then Return SetError(4, 0, 0) ; Determine last entry of the array. Local $iLast = UBound($aArray) - 1 If $iUBound = Default Or $iUBound > $iLast Then $iUBound = $iLast If $iBase < 0 Or $iBase = Default Then $iBase = 0 If $iBase > $iUBound Then Return SetError(5, 0, $iReturn) If $sDelimiter = Default Then $sDelimiter = "|" ; Open output file for overwrite by default, or use input file handle if passed. Local $hFileOpen = $sFilePath If IsString($sFilePath) Then $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(1, 0, $iReturn) EndIf ; Write array data to file. Local $iError = 0 $iReturn = 1 ; Set the return value to true. Switch $iDims Case 1 For $i = $iBase To $iUBound If Not FileWrite($hFileOpen, $aArray[$i] & @CRLF) Then $iError = 3 $iReturn = 0 ExitLoop EndIf Next Case 2 Local $sTemp = "" For $i = $iBase To $iUBound $sTemp = $aArray[$i][0] For $j = 1 To UBound($aArray, $UBOUND_COLUMNS) - 1 $sTemp &= $sDelimiter & $aArray[$i][$j] Next If Not FileWrite($hFileOpen, $sTemp & @CRLF) Then $iError = 3 $iReturn = 0 ExitLoop EndIf Next EndSwitch ; Close file only if specified by a string path. If IsString($sFilePath) Then FileClose($hFileOpen) ; Return the results. Return SetError($iError, 0, $iReturn) EndFunc ;==>_FileWriteFromArray Link to comment Share on other sites More sharing options...
Skeletor Posted October 23, 2019 Share Posted October 23, 2019 Interesting posts from @jchd and @Alitai , both had a wealth of knowledge on the topic. Very interesting read. Almost like turf wars.. Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI Link to comment Share on other sites More sharing options...
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