6 posts in this topic
Array Comparison with Logical expressions
I'm having list of words and put them into an array ($WordsList) and try to compare results with logical function if in such a condition that if letter extracted through _StringBetween doesn't exist in Array ($WordsList) then it'll show message box like "Pattern Not found" and if patter found in array then it'll skip if comparison and show last message "All Done".
But in my condition, the if comparison is not able to process commands upto my expectations and just show last message only.
Please help me and guide me further how can i make this possible.
$file = fileopen(@ScriptDir & "\source.txt", 10) $IE = _IECreate( "http://example.com", 0, 0) $source = _IEDocReadHTML($IE) FileWrite($file, $source) Global $File = @scriptdir & "\source.txt" $sText = FileRead($File) $target_source = _StringBetween($sText, "Dateuploaded</strong><span>", "</span></li><li><strong>Seeders") _ArrayDisplay ($target_source) $WordsList = ("2daysago", "1dayago") If $target_source <> $WordsList Then ; Here is the problem for logical comparison MsgBox ( '', '', 'Pattern Not found') EndIf MsgBox ('', '', 'All Done')
Can anyone explain what's going on here:
; Initializing an array Local $a = [ 0 ] ; Lately in code I want to assign new array to $a variable $a = [ 1 ] and got this error at compile time
==> Error in expression.: $a = [ 1 ] $a = ^ ERROR What is it and why?
And I've mentioned that I can't pass "manual" array to function as parameter:
a( [ 0 ] ) Func a( $a ) _ArrayDisplay( $a ) EndFunc still the same error
==> Error in expression.: a( [ 0 ] ) a( ^ ERROR
Writing array into excel cells with line breaks automatically
I'm trying to write data from array into .text file with line break and i did it successfully.
but now I want to write from the same array into already empty excel with with line breaks means each value of array should be written in next cell automatically as it's happening in text file using "Filewrite"
Looking for guidance.
Here is my code;
$file = fileopen(@scriptdir & "\source.txt", 10) $IE = _IECreate("http://www.example.com") $source = _IEDocReadHTML($IE) FileWrite($file, $source) $target_source1 = _StringBetween($source, '<span>', '</span>') If Not @error Then For $i=0 To UBound($target_source1) -1 FileWrite (@scriptdir & "\save.txt", $target_source2[$i] & @crlf) ; I want to write above array onto excel file Next EndIf
AutoItSetOption for arrays
If we give the below line in our script, we can expand the variables in double quotes to its values.
AutoItSetOption ("ExpandVarStrings", 1) Like,
Local $b=4 MsgBox(0,"$b$","See subject") But coming to variables, they are not getting expanded.
Local $a=[1,2,3] Local $b=4 _ArrayDisplay($a) MsgBox(0,"$a$$b$","See subject") Could anyone please help me on this.
So I have this code
#include <Array.au3> Run("C:\Windows\System32\query user>>c:\GTScript\query.txt") $aFileArray = FileReadToArray("c:\GTScript\query.txt") -1 ; NOTE: the first line of the file is in element 0, but that only holds column headers so we start from 1! For $lineIndex = 1 to UBound($aFileArray) ; Let's take every group of non-whitespace characters from the current line and put it in an array: $aSplit = StringRegExp($aFileArray[$lineIndex], "(\S+)", $STR_REGEXPARRAYGLOBALMATCH) _ArrayDisplay($aSplit, "All elements on line") ; We know the format of the file, so we know where the values will be in the array: $userName = $aSplit $userId = $aSplit MsgBox(64, "Info", "Username: " & $userName & @CRLF & "ID: " & $userId) Next Do you have an Idea on how to rewrite it so it allways tells me row 2 of a certain user, no matter in which Column of ArrayDisplay he is?
Post examples please, since I am still a rookie!
With kind regards