• Similar Content

• Hi guys!, i have a problem to convert Python code to AutoIt code, in fact i had not coded with Python yet!, this code is about permutation a string's case, i will be happy with your comments :)❤;

Python code:

# Python code to print all permutations # with respect to cases # Function to generate permutations def permute(inp): n = len(inp) # Number of permutations is 2^n mx = 1 << n # Converting string to lower case inp = inp.lower() # Using all subsequences and permuting them for i in range(mx): # If j-th bit is set, we convert it to upper case combination = [k for k in inp] for j in range(n): if (((i >> j) & 1) == 1): combination[j] = inp[j].upper() temp = "" # Printing current combination for i in combination: temp += i print(temp), # Driver code permute("Hello") # This code is contributed by Sachin Bisht
My code in AutoIt:
; https://www.geeksforgeeks.org/permute-string-changing-case/ _PermuteCase("ABC") Func _PermuteCase(\$sText) If StringRegExp(\$sText, "^[A-Za-z]{1,}\$") Then Local \$iLength = StringLen(\$sText) ; Get length of the text. Local \$iMaxPerm = 2 ^ \$iLength ; Number of permutations is 2^n Local \$sLow_Text = StringLower(\$sText) ; Converting string to lower case Local \$asChrs = StringToASCIIArray(\$sLow_Text) ; Split the text into array of chars. For \$i = 1 To \$iMaxPerm Step 1 For \$j = 0 To \$asChrs[0] ;................................................... Next Next Else Return SetError(-1, 0, "Error: Input is incorrect!") EndIf EndFunc ;==>_PermuteCase

====================== SOLUTION by @TheXman ======================

• By Zaoka
Hi guys
Need little help with filtering.
I'm trying to filter specific weeks from power pivot table using this code recorded with Excel VBA :

#include <Excel.au3> Global \$oExcel = _Excel_Open() Global \$oWorkbook = _Excel_BookOpen(\$oExcel, "C:\Users\....\Orders.xlsb") \$oWorkbook.PivotTables("PivotTable1").PivotFields( _ "[Report 2].[Week].[Week]").VisibleItemsList = Array( _ "[Report 2].[Week].&[10]", "[Report 2].[Week].&[11]", _ "[Report 2].[Week].&[12]", "[Report 2].[Week].&[13]", _ "[Report 2].[Week].&[14]", "[Report 2].[Week].&[15]") But get error
error: Array(): undefined function. Not sure how to resolve this.
• By LxP
I'm trying to pass a nested array to a function, such that the function alters the inner array.
I was surprised to find that this minimal reproducible example, despite its use of ByRef, seems to pass a copy of the inner array to the function:
#include <Array.au3> ; a boring old array Local \$aInnerArray[5] = [1, 2, 3, 4, 5] ; a one-element array containing a reference to the other array Local \$aOuterArray[1] = [\$aInnerArray] ; intention: take a nested array and alter its inner array ; reality: the inner array seems to be getting copied Func ChangeIt(ByRef \$aOuter) Local \$aInner = \$aOuter[0] \$aInner[2] = 0 EndFunc ; Expected: [1, 2, 3, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✔ _ArrayDisplay(\$aInnerArray, 'Before') ; \$aOuterArray passed by-ref, should receive reference to \$aInnerArray ; Therefore should change \$aInnerArray to [1, 2, 0, 4, 5] ChangeIt(\$aOuterArray) ; Expected: [1, 2, 0, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✘ _ArrayDisplay(\$aInnerArray, 'After') I suspect that either:
the copy is taking place in the first line of the function (I couldn't find a way to access the inner array without first assigning it to a variable though); or ByRef doesn't propagate into inner levels of the data structure being passed, which seems less likely to me. Could someone please point me in the right direction to get this working as intended?
; WRONG: ; a one-element array containing a reference to the other array Local \$aOuterArray[1] = [\$aInnerArray] The assumption I made about this code is wrong—it actually copies \$aInnerArray into \$aOuterArray, so there are now two unrelated \$aInnerArray instances.  It is not possible to store arrays in other arrays by reference.
If it is necessary to refer to a mutable array in multiple places, consider holding it in a global variable.  Where a collection of mutable arrays needs to be accessed in multiple places (as in my case), consider storing them in a global array and referring to each sub-array by index (also known as the Registry pattern).
• By VinMe
HELLO All,
is there any function in Auto it to Remove the repeating  strings separated by ","  which is present in the array.
ex.
Available state
a[0]= D97,D96,,D85,D86,D85,D86,D85,D86,D85,,D86,D85,D86,D85,D86
a[1]=D85,D24,,,,,D85
Required state
a[0]= D97,D96,D85,D86,
a[1]=D85,D24
vin!

• Hi all, I wasnt active in this Forum forum for Years. 😅
Since I need something with Json in AutoIt i write a little UDF to save a variable to file to read it with another language - and back. After a while until my other script grows i thought - lets integrate all variables wich is possible, because i want have arrays to.
This is my first public UDF in Autoit - normaly my AutoIt scripts are quick an dirty.... - like the examples for this udf. - someone want to write nice examples?
I tried to write this UDF properly, cared for processing speed, low mem consumption as possible, a short code, and a high usability without beeing very familiar with arrays.
What is it for? - convert nearly all types of variables to a json string for saving it in a file or to an ini. Read it back in to a same formated variable and preserv variable types. All array types are supported with nested arrays, the only restriction is ram and array/stringsize - and time if the array is very big. You can use Filters for variable types and some other options.
If anyone found a bug or any suggestions, please post it.

get Json.au3 from here Json.au3

JsonVar 2019.01.25.1.zip
×
×
• Create New...