Leaderboard
Popular Content
Showing content with the highest reputation on 03/11/2022 in all areas
-
Multiple Arrays one Loop?
SkysLastChance reacted to seadoggie01 for a topic
I like to avoid using eval, because it looks messy to me and makes future changes much harder. Personally, I like option 1 better, but if you want to store an array in another array, you can do that... ; declare your 4 files lists above Local $aListList[4] = [$aFileList1, $aFileList2, $aFileList3, $aFileList4] ; Option 1: ; For each list For $iList=0 To UBound($aListList) - 1 $aFileList = $aListList[$iList] ; For each file in the list For $iFile = 0 To UBound($aFileList) - 1 $sFile = $aFileList[$iFile] Next Next ; Option 2: ; For each List For $iList = 0 To UBound($aListList) - 1 ; For each file in the list For $iFile = 0 To UBound($aListList[$iList]) - 1 $sFile = ($aListList[$iList])[$i] Next Next Obviously, if what you have works for you, that's great and keep going1 point -
I'll do #1 for your : #include <Array.au3> Local $sText = FileRead("lineup-original.json") Local $aArray = StringRegExp($sText, '(?s)"(?|GuideNumber|GuideName|URL)":"([^"]*)', 3) Local $aList = _Array_Resize($aArray, 3) _ArrayDisplay($aList) Func _Array_Resize(ByRef $aArray1d, $iColumns, $iStart = Default) If $iStart = Default Then $iStart = 0 Local $iElements = UBound($aArray1d) - $iStart If Mod($iElements, $iColumns) <> 0 Then Return SetError(1, 0, False) Local $aArray2d[$iElements / $iColumns][$iColumns] Local $iRow = 0 For $i = $iStart To UBound($aArray1d) - 1 $aArray2d[$iRow][Mod($i, $iColumns)] = $aArray1d[$i] ; If this is the end of a column, increase the row counter If Mod($i, $iColumns) = $iColumns - 1 Then $iRow += 1 Next Return $aArray2d EndFunc ;==>_Array_Resize Now try to do #2 to #51 point
-
Kloud, If you want scrollbars in a resizable GUI using my UDF then I am afraid that there will always be a slight flicker as the scrollbars are redrawn after either a resize or a move. This is because I remove the scrollbars as the resize/move event starts and then redraw them as it finishes. This is only strictly necessary for a resize, but as I mentioned earlier, MS has combined the 2 events into the one message and as yet I have not found a way to distinguish between them. But we have a very wet few days forecast (yes, even in the south of Spain!) and I will plug away at the problem to see if I can come up with something. M231 point
-
1 point
-
Multiple Arrays one Loop?
SkysLastChance reacted to Nine for a topic
What I meant was to create a function instead of repeating just about the same code 4 times : MyFunc($aFileList1) MyFunc($aFileList2) MyFunc($aFileList3) MyFunc($aFileList4) Func MyFunc (ByRef $aArray) For $i = 0 To UBound($aArray) -1 ConsoleWrite($aArray[$i]) Next EndFunc But to answer your question, you need to use Eval function : For $i = 1 to 4 ConsoleWrite(UBound(Eval("aFileList" & $i)) & @CRLF) Next1 point -
Your wishOrder.txt is incomplete, only 10 elements are listed. What have you tried so far that is not working ? To get you started, here the SRE to extract the desired elements into a 1d array : Local $aArray = StringRegExp($sText, '(?s)"(?|GuideNumber|GuideName|URL)": "([^"]*)', 3) What I suggest you do next : 1- convert the 1d into a 2d array 2- Read the wish list into a 1d array 3- Add a 4th column in the 2d array 4- Loop thru the wish list and search the 2d array for the same entry (_ArraySearch), adding a 1 in the 4th column to indicate you found it. Print result. 5- _ArrayFindAll on the 4th column to find the missing entries VoilĂ !1 point
-
Question regarding operator precedence
Musashi reacted to AspirinJunkie for a topic
Good hint: I would sum up in my own words: The minus has two functions - once as a binary minus operator and once as a unary sign operator. The tricky thing about this is that the binary operator has a lower priority than the power operator. The sign operator, on the other hand, has a higher priority (as in mathematics) than the power operator. This leads to the implicit execution (-2)^4 The basic problem here, however, is that even if the minus here is only interpreted as a sign operator, we still lack a binary operator that links the right side with the 11. The parser simply assumes a plus operator for this. This would explain the behaviour - but not whether it is a bug or not. Basically, I still think it is a bug, because the form of the equation specifies the minus as a binary operator (especially from a mathematical view). Furthermore, there is no indication in the AutoIt documentation that the sign operator has an operator priority that differs from the binary variant - so it is a behaviour that differs from the language definition.1 point -
Works for me, clearly. Copy/paste the exact content I posted in a new .au3 and run it verbatim.1 point
-
Musashi, It looks as if AutoIt is treating the expected - operator as a unary minus. This recent thread went into the matter in some detail - and my advice remains the same: never rely on operator precedence and always uses parentheses. M231 point
-
;~ Check if $result3 is an array ;~ True = if ubound array greater greater than 1 $result3[1] otherwise $result3[0] ;~ False = -1 Global $result4 = IsArray($result3) ? (UBound($result3) > 1 ? $result3[1] : $result3[0]) : -11 point
-
@boludoz and @Nine can check if is correct..... #include <Array.au3> #include <Math.au3> #include <MsgBoxConstants.au3> Global $g_aiOrden = [0, 2, 200, 1, -1, 1, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Global $eCount = 38 Order3($g_aiOrden) _ArrayDisplay($g_aiOrden) Func Order3(ByRef $aArray) Local $oTemp = '' Local $oRow = '' Local $oNumber = '' Local Const $iMax = UBound($aArray) - 1 Local $iNum = -1 For $i = 0 To $iMax $oNumber &= $i & ';' If $aArray[$i] > $iMax Or $aArray[$i] < 0 Or Not StringIsDigit($aArray[$i]) Then $oRow &= $i & '|' Else If Not StringRegExp($oTemp, '\b'& $aArray[$i] &'\b') Then $oTemp &= $aArray[$i] & '|' Else $oRow &= $i & '|' Endif Endif Next $oTemp = StringTrimRight($oTemp, 1) $oNumber = StringRegExpReplace($oNumber, '\b('& $oTemp &');\b', '') Local $oRowSplit = StringSplit(StringTrimRight($oRow, 1), '|', 2) Local $oNumberSplit = StringSplit(StringTrimRight($oNumber, 1), ';', 2) For $i = 0 To UBound($oRowSplit) - 1 $aArray[$oRowSplit[$i]] = $oNumberSplit[$i] Next EndFunc1 point
-
One of possible ways #include <AutoItConstants.au3> #include <StringConstants.au3> Local $sUsername = "administrator" ; target username Local $sOutput = "" ; build your wmic query Local $sWMICquery = 'wmic useraccount where name="' & $sUsername & '" get passwordexpires /format:VALUE' ; run your query hidden and with redirected I/O streams Local $hPid = Run($sWMICquery, '', @SW_HIDE, $STDERR_MERGED) Do Sleep(100) $sOutput &= StdoutRead($hPid) ; get wmic output from redirected stream Until @error ; error occurs when command has finished $sOutput = StringStripWS($sOutput, $STR_STRIPALL) ; remove all @cr and spaces from output MsgBox(0, 'Debug', $sOutput) ; show result1 point
-
Minesweeper (source released)
AJLBarroso reacted to AlmarM for a topic
Hey! Prepare to be amazed! Instead of writing a bot for Minesweeper, I created the game itself! Source status Released! Check downloads! Screenshots Any tips, feedback, comments, features would be great! EDIT (22-11-2010): Increased timer input widthFixed "Win/Lose" label textFixed the 'first-click-game-over' bug.EDIT (23-11-2010): Added IconFixed a few problemsEDIT (26-11-2010): Added flag system (needs testing, feedback appreciated)Fixed some bugsDecided to release source in a few updates.Note: I tried creating a mouseOverHover effect, but it results in a massive lag (wich gets worse everytime you start a new game). EDIT (29-11-2010): Fixed some bugsAdded second SkinPackIncluded source, check 'Downloads'EDIT (11-12-2013): Updated the download links Downloads The source code can now be found in the attached files. Minesweeper Source Code.zip1 point -
Minesweeper (source released)
AJLBarroso reacted to AlmarM for a topic
Seems the links are a bit outdated, haha. As soon as I get home, I will re-post the source codes EDIT: Added the source code!1 point