Sign in to follow this  
Followers 0
RyukShini

[UNSOLVED] Writing [SUCCESS] after each line

29 posts in this topic

#1 ·  Posted (edited)

If $oStatusCode = 404 Then
_FileReadToArray("email.txt", $aInput[$i])
For $i = 1 To $aInput[$i]
    $aInput[$i] &= "[SUCCESS]"
Next

_FileWriteFromArray("checked.txt", $aInput[$i], 1)
EndIf

I am trying to write [SUCECSS] on each line in my email.txt file and store it as "Checked.txt"
I have written this code from my research here on this forum, but I just can't get it to work.
I've tried different ways of using array, also tried using "FileWriteLine" functions, nothing works out for me.

 

I hope someone can point me towards a solution and/or write the code I need with an explanation.
Thanks in advance.

Edited by RyukShini
[SOLVED]

Share this post


Link to post
Share on other sites



4 minutes ago, JohnOne said:
_FileWriteFromArray("checked.txt", $aInput, 1)

 

Now it writes $aInput on each lines of "checked.txt"

 

However it does not write [SUCCESS] after each lines.
And it does it for all of email.txt not just the ones giving response 404.

Thank you though, it made my progress go a bit further.

Share this post


Link to post
Share on other sites
8 minutes ago, JohnOne said:

And

_FileReadToArray("email.txt", $aInput)

And

For $i = 1 To $aInput[0]
    $aInput[$i] &= "[SUCCESS]"
Next

 

Now it writes [SUCCESS] after each line.
however it does it for all of email.txt.
It does not only write [SUCCESS] if the response code is 404.
Thanks a lot, I will try to fix it, but if more responds comes I wont complain!
 

Share this post


Link to post
Share on other sites

You're reading the entire contents of "email.txt" into a single array element (with a possibly undefined index), then trying to use that same array element as the upper bound on a for-loop index, which won't work: $aInput[$i] contains the data from "email.txt", not the line count. Perhaps what you meant is something like this:

If $oStatusCode = 404 Then
    _FileReadToArray("email.txt", $aInput)          ; Line count (max index) is in element 0
    For $i = 1 To $aInput[0]
        $aInput[$i] &= "[SUCCESS]"
    Next
    _FileWriteFromArray("checked.txt", $aInput, 1)  ; Begin writing from index = 1
EndIf

Give _FileReadToArray() an array variable with no index to read each line of "email.txt" into successive elements starting at index = 1; you need to specify a starting index of 1 for _FileWriteFromArray(), otherwise it will start with 0 and include the line count in the output to "checked.txt".

I haven't tested the code; you might need to append @CRLF to each element of the array (after "[SUCCESS]"). You might also want to put a space or tab character before "[SUCCESS]" for readability, otherwise it will immediately follow the last character in the input line (no intervening whitespace).

Share this post


Link to post
Share on other sites
21 minutes ago, tremolux66 said:

You're reading the entire contents of "email.txt" into a single array element (with a possibly undefined index), then trying to use that same array element as the upper bound on a for-loop index, which won't work: $aInput[$i] contains the data from "email.txt", not the line count. Perhaps what you meant is something like this:

If $oStatusCode = 404 Then
    _FileReadToArray("email.txt", $aInput)          ; Line count (max index) is in element 0
    For $i = 1 To $aInput[0]
        $aInput[$i] &= "[SUCCESS]"
    Next
    _FileWriteFromArray("checked.txt", $aInput, 1)  ; Begin writing from index = 1
EndIf

Give _FileReadToArray() an array variable with no index to read each line of "email.txt" into successive elements starting at index = 1; you need to specify a starting index of 1 for _FileWriteFromArray(), otherwise it will start with 0 and include the line count in the output to "checked.txt".

I haven't tested the code; you might need to append @CRLF to each element of the array (after "[SUCCESS]"). You might also want to put a space or tab character before "[SUCCESS]" for readability, otherwise it will immediately follow the last character in the input line (no intervening whitespace).

I have tried back and forth, I am not sure I understand.
Would you mind writing an example?
I process code easier than I process words to be honest.

Share this post


Link to post
Share on other sites

This example is pretty much the same as the code I posted earlier, and is based on the code fragment that was originally posted.

#cs ----------------
    success.au3
#ce ----------------
#include <File.au3>

Local $aInput[1]            ; Declare the array with 1 element just so AutoIt knows it's an array -
                            ;   _FileReadToArray() will grow the array to be big enough to hold all the
                            ;   lines of text from the file

Local $oStatusCode = 404    ; Set this variable to 404 to force the SUCCESS code to execute

If $oStatusCode = 404 Then
    ; Read the contents of "email.txt" into the array starting at index = 1
    ; -- $aInput[0] will hold the line count, and $aInput[1] ... $aInput[N] will hold lines 1-N
    ; -- For example: with 4 lines of text, $aInput = [4, line_1, line_2, line_3, line_4]
    _FileReadToArray("email.txt", $aInput)

    ; For every line in the file ...
    For $i = 1 to $aInput[0]
        ; ... append <space>[SUCCESS] to the line (no @CRLF needed)
        $aInput[$i] &= " [SUCCESS]"
    Next

    ; Write all the text lines in the array to "checked.txt"
    ; -- We set the 3rd argument to 1 so that it starts with index = 1 instead of 0
    _FileWriteFromArray("checked.txt", $aInput, 1)
EndIf

 

email.txt contents:

This is line 1.
Here is line 2!
This could be line 3...

 

checked.txt contents:

This is line 1. [SUCCESS]
Here is line 2! [SUCCESS]
This could be line 3... [SUCCESS]

 

Share this post


Link to post
Share on other sites
3 hours ago, tremolux66 said:

This example is pretty much the same as the code I posted earlier, and is based on the code fragment that was originally posted.

#cs ----------------
    success.au3
#ce ----------------
#include <File.au3>

Local $aInput[1]            ; Declare the array with 1 element just so AutoIt knows it's an array -
                            ;   _FileReadToArray() will grow the array to be big enough to hold all the
                            ;   lines of text from the file

Local $oStatusCode = 404    ; Set this variable to 404 to force the SUCCESS code to execute

If $oStatusCode = 404 Then
    ; Read the contents of "email.txt" into the array starting at index = 1
    ; -- $aInput[0] will hold the line count, and $aInput[1] ... $aInput[N] will hold lines 1-N
    ; -- For example: with 4 lines of text, $aInput = [4, line_1, line_2, line_3, line_4]
    _FileReadToArray("email.txt", $aInput)

    ; For every line in the file ...
    For $i = 1 to $aInput[0]
        ; ... append <space>[SUCCESS] to the line (no @CRLF needed)
        $aInput[$i] &= " [SUCCESS]"
    Next

    ; Write all the text lines in the array to "checked.txt"
    ; -- We set the 3rd argument to 1 so that it starts with index = 1 instead of 0
    _FileWriteFromArray("checked.txt", $aInput, 1)
EndIf

 

email.txt contents:

This is line 1.
Here is line 2!
This could be line 3...

 

checked.txt contents:

This is line 1. [SUCCESS]
Here is line 2! [SUCCESS]
This could be line 3... [SUCCESS]

 

Thanks, so far that is working fine, sorry for not being able to express myself proper.
It is already working as your example shows.
However it should only write [SUCCESS] on the ones giving status code 404.

So 

This is an example:

 

This is a line - It gave Response code 200
this is a line - same as above
this is a line - ^
this is a line [SUCCESS] - Response code was 404
this is a line - response code 200

Right now it takes all of the file and writes [SUCCESS] each line even thought I gave it if $statuscode = etc.
I am not sure what I am doing wrong.

Share this post


Link to post
Share on other sites

Is "email.txt" a list of addresses , for which you check status code and then write the result in "checked.txt" ?

Share this post


Link to post
Share on other sites

Are you sending a EMail to all adresses in EMail.txt in a loop? I think it's better to show your whole script,because title and script snippet are saying you want to write success after each line.

 

Share this post


Link to post
Share on other sites
#cs ----------------
    success.au3
#ce ----------------
#include <File.au3>

Local $aInput[1]            ; Declare the array with 1 element just so AutoIt knows it's an array -
                            ;   _FileReadToArray() will grow the array to be big enough to hold all the
                            ;   lines of text from the file

Local $oStatusCode = 404    ; Set this variable to 404 to force the SUCCESS code to execute

If $oStatusCode = 404 Then
    ; Read the contents of "email.txt" into the array starting at index = 1
    ; -- $aInput[0] will hold the line count, and $aInput[1] ... $aInput[N] will hold lines 1-N
    ; -- For example: with 4 lines of text, $aInput = [4, line_1, line_2, line_3, line_4]
    _FileReadToArray("email.txt", $aInput)

    ; For every line in the file ...
    For $i = 1 to $aInput[0]
        $oStatusCode = Random(404, 408, 1)
        If Not $oStatusCode = 404 Then
            ; ... append <space>[SUCCESS] to the line (no @CRLF needed)
            $aInput[$i] &= " [SUCCESS]"
        EndIf
    Next

    ; Write all the text lines in the array to "checked.txt"
    ; -- We set the 3rd argument to 1 so that it starts with index = 1 instead of 0
    _FileWriteFromArray("checked.txt", $aInput, 1)
EndIf

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

JO, your code assumes that the answer to the question in post #10 is "yes" ... no ?  :)

Share this post


Link to post
Share on other sites
15 hours ago, mikell said:

Is "email.txt" a list of addresses , for which you check status code and then write the result in "checked.txt" ?

It is a list of usernames actually, just never got to change the filename.
but it takes the username/email.txt and inserts it after .com/username
Then if the specific website gives me back a 404 response code(Page not found)
Then it should write [SUCCESS] after that username in the email.txt and/or save the [SUCCESS] in checked.txt

Share this post


Link to post
Share on other sites
5 hours ago, JohnOne said:

Well, we are being forced to guess. :blink:

Thank you for all the support!

Share this post


Link to post
Share on other sites

Then the approach should be like this

Local $aInput
_FileReadToArray("email.txt", $aInput)  ; read the list of names to array

For $i = 1 To $aInput[0]   ; for each name
    ; here some code to send mail and check status code 
    ; ...
    If $oStatusCode = 404 Then $aInput[$i] &= " [SUCCESS]"  ; append to the address
Next
_FileWriteFromArray("checked.txt", $aInput, 1)  ; rewrite the array to file

 

Share this post


Link to post
Share on other sites

 

3 hours ago, mikell said:

Then the approach should be like this

Local $aInput
_FileReadToArray("email.txt", $aInput)  ; read the list of names to array

For $i = 1 To $aInput[0]   ; for each name
    ; here some code to send mail and check status code 
    ; ...
    If $oStatusCode = 404 Then $aInput[$i] &= " [SUCCESS]"  ; append to the address
Next
_FileWriteFromArray("checked.txt", $aInput, 1)  ; rewrite the array to file

 

I am not sure what I am doing wrong:

 

#include <String.au3>
#include <Array.au3>
#Include <File.au3>
Local $aInput
_FileReadToArray("email.txt", $aInput)  ; read the list of names to arra

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
For $i = 1 to UBound($aInput) -1
$oHTTP.Open("GET", "https:///" & $aInput[$i], False) ; Post url
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") ; Header data >
$oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
$oHTTP.SetRequestHeader("User-Agent", "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.52 YaBrowser/15.12.2490.3614 (beta) Yowser/2.5 Safari/537.36")
$oHTTP.SetRequestHeader("X-CSRFToken", "")
$oHTTP.SetRequestHeader("Referer", "https:///")
$oHTTP.SetRequestHeader("X-Requested-With", "XMLHttpRequest")
; Header data <

; Performing the Request
$oHTTP.Send
;Sends the post data with the given details

;Download the body response if any, and get the server status response code.
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
Next
For $i = 1 To $aInput[0]   ; for each name
    If $oStatusCode = 404 Then
        $aInput[$i] &= " [SUCCESS]"  ; append to the address

_FileWriteFromArray("checked.txt", $aInput, 1)  ; rewrite the array to file
EndIf
Next
Sleep(3000)

 

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

My (personal) feeling about your logic is that you should try something like this

#include <String.au3>
#include <Array.au3>
#Include <File.au3>

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
Local $aInput
_FileReadToArray("email.txt", $aInput)  ; read the list of names to array

For $i = 1 To $aInput[0]   ; for each name
    $oHTTP.Open("GET", "https:///" & $aInput[$i], False) ; Post url
    $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") ; Header data >
    $oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
    $oHTTP.SetRequestHeader("User-Agent", "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.52 YaBrowser/15.12.2490.3614 (beta) Yowser/2.5 Safari/537.36")
    $oHTTP.SetRequestHeader("X-CSRFToken", "")
    $oHTTP.SetRequestHeader("Referer", "https:///")
    $oHTTP.SetRequestHeader("X-Requested-With", "XMLHttpRequest")
    $oHTTP.Send
    $oReceived = $oHTTP.ResponseText
    $oStatusCode = $oHTTP.Status
    If $oStatusCode = 404 Then $aInput[$i] &= " [SUCCESS]"  ; append to the address
Next

$oHTTP = 0
_FileWriteFromArray("checked.txt", $aInput, 1)  ; rewrite the array to file

 

Edited by mikell
huge typo

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • Jibberish
      By Jibberish
      I am trying to add data to an array and I keep getting the error "Subscript used on non-accessible variable ".
      #include <array.au3> ; Includes, etc ~ ~ ~ Local $aOptionsArray[3] $aOptionsArray = CheckboxesAndRadioButtons() _ArrayDisplay($aOptionsArray) Func CheckboxesAndRadioButtons() ; Create Checkboxes and Radio Buttons and read the results ~ ~ ~ ; Radio Buttons to Array ; $aOptions[0] = $bTestSelectForever ; $aOptions[1] = $bTestSelect3Times ; $aOptions[2] = $bTestSelectOnce If $bSelect1 = 1 Then $aOptions[0] = "True" Else $aOptions[0] = "False" <<< This is where the error occurs. EndIf If $bSelect2 = 1 Then $aOptions[1] = "True" Else $aOptions[1] = "False" EndIf If $bSelect3 = 1 Then $aOptions[2] = "True" Else $aOptions[2] = "False" EndIf Return $aOptions EndFunc Is putting data into an array while in a If - Then - Else illegal?
    • anoig
      By anoig
      Hi all, 

      First, I want to give a huge shout-out to the community. I'm completely self-taught, and have never had to actually ask a question before because the forum is that good at answering questions and explaining things. However, I'm kind of stumped here, and I've been stuck on this problem for almost a full day.

      I'm working on a script to populate drafts of deeds at work. I have the main GUI and  a function (ctrl($n) and read()) for adding fields to find and data to replace it with to an array for later use with _word_docfindreplace. All of that works. However, due to the way I have the forms set up, I need to create additional fields and info based on the data that's there. Specifically, if there's only one buyer, I need to add the field [Buyer1&2] and the data in $aArray_Base for [Buyer 1]. I also need to add a field [Buyer 2] and have a blank data set in the next column over in the array, and I need to do the same for the Seller. To this end, the function parties() sets boolean variables $2buyers and $2sellers accordingly. Then, I have buyers() and sellers() to populate the data. 

      The problem that I'm running into is that each function works... when ONLY the buyer 1 name field is filled, and when ONLY the seller 1 field is filled.

      So if I fill Buyer 1 Name and save it, the data is populated correctly. But when I fill Buyer 1 and Seller 1 name, only the buyer 1 data populates correctly. Worse, when I fill several fields, neither populate correctly. I have no idea why this happens. I've added messageboxes to debug throughout the entire process and can't pinpoint what's causing the issue. The entire script is below. The function(s) in question are buyers() and sellers(). Only Sellers() has messageboxes throughout.

      Can someone help walk me through what might be causing this and help me find a solution? Thanks a ton in advance, and sorry for the wall of text.
      -Anoig
       
    • InunoTaishou
      By InunoTaishou
      Cleaning up some old folders and found this little snippit. Think I was using this back when I was trying to create 2d maps for a game I was making in GDI+ (that never got finished). Pretty straight forward, searches an array for an array.
      #include <Array.Au3> Search() Func Search() Local $aArrayToFind[][] = [["V", "V", "V", "V", "V"], ["V", "V", "V", "V", "V"], ["V", "V", "V", "V", "B"], ["V", "V", "V", "V", "B"], ["V", "V", "V", "V", "B"]] Local $aArrayToSearch[][] = [["R", "R", "R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "V", "V", "V", "V", "V", "T", "T", "T", "T", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "X", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "B", "B", "B", "B", "B", "B", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "B", "B", "B", "B", "B", "B", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "X", "V", "V", "V", "X", "B", "B", "B", "B", "B", "V", "V", "V", "V", "B", "B", "B", "B", "B", "B", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "V", "B", "B", "B", "B", "B", "V", "V", "V", "X", "V", "V", "B", "D", "B", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "X", "V", "V", "V", "X", "B", "D", "B", "B", "B", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "V", "V", "V", "V", "X", "X", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "X", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "R", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "V", "V", "V", "X", "T", "T", "T", "T", "T", "T", "T", "T", "X", "X", "V", "V", "V", "V", "V", "V", "V", "V", "V", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "T", "T", "T", "T", "T", "T"], _ ["V", "V", "V", "V", "V", "V", "V", "V", "V", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "V", "X", "V", "V", "X", "B", "B", "B", "B", "B", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "B", "B", "B", "B", "B", "V", "V", "V", "V", "V", "M", "M", "M", "M", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "X", "B", "D", "B", "B", "B", "V", "V", "V", "V", "V", "M", "M", "M", "M", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "M", "M", "D", "M", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "C", "C", "C", "C", "C", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "V", "T", "T", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "C", "C", "C", "C", "C", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "V", "T", "T", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "C", "C", "C", "C", "C", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "W", "W", "W", "W", "W", "W", "V", "V", "V", "V", "V", "V", "V", "C", "C", "D", "C", "C", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "W", "W", "W", "W", "W", "W", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "W", "W", "W", "W", "W", "W", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "W", "W", "W", "W", "W", "W", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "L", "L", "L", "L", "W", "W", "W", "W", "W", "W", "L", "L", "L", "V", "V", "V", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "X", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "R", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T"], _ ["R", "R", "R", "R", "R", "R", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "V", "V", "V", "V", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T", "T"]] Local $aArrayInArray = ArrayInArray($aArrayToSearch, $aArrayToFind) If (@Error) Then MsgBox("", "Error", "Error doing search: " & @Error) Else If ($aArrayInArray[0] = 1) Then ToolTip("Start Coords = " & $aArrayInArray[1] & ", " & $aArrayInArray[2] & @LF & _ "End Coords = " & $aArrayInArray[1] + UBound($aArrayToFind, $UBOUND_ROWS) - 1 & ", " & $aArrayInArray[2] + UBound($aArrayToFind, $UBOUND_COLUMNS) - 1 & @LF & _ "(Approx) Center coords = " & $aArrayInArray[1] + Int(UBound($aArrayToFind, $UBOUND_ROWS) / 2) & ", " & $aArrayInArray[2] + Int(UBound($aArrayToFind, $UBOUND_COLUMNS) / 2), 0, 0) $aArrayToSearch[$aArrayInArray[1]][$aArrayInArray[2]] = "Start" $aArrayToSearch[$aArrayInArray[1] + UBound($aArrayToFind, $UBOUND_ROWS) - 1][$aArrayInArray[2] + UBound($aArrayToFind, $UBOUND_COLUMNS) - 1] = "End" $aArrayToSearch[$aArrayInArray[1] + Int(UBound($aArrayToFind, $UBOUND_ROWS) / 2)][$aArrayInArray[2] + Int(UBound($aArrayToFind, $UBOUND_COLUMNS) / 2)] = "(Approx) Center" _ArrayDisplay($aArrayToSearch, "ArrayInArray") ElseIf ($aArrayInArray[0] > 1) Then MsgBox("", "Multiple Matches", "Multiple Matches Found For Search") Else MsgBox("", "No Matches", "No Matches Found For Search") EndIf EndIf EndFunc ;==>Start Func ArrayInArray($aArrayToSearch, $aArrayToFind) Local $aReturn[3] = [0, -1, -1] If (Not IsArray($aArrayToSearch)) Then Return SetError(1, 0, $aReturn) If (Not IsArray($aArrayToFind)) Then Return SetError(2, 0, $aReturn) Local $iRowsToSearch = UBound($aArrayToSearch, $UBOUND_ROWS) Local $iColumnsToSearch = UBound($aArrayToSearch, $UBOUND_COLUMNS) Local $iRowsToFind = UBound($aArrayToFind, $UBOUND_ROWS) Local $iColumnsToFind = UBound($aArrayToFind, $UBOUND_COLUMNS) If ($iRowsToFind > $iRowsToSearch) Then Return SetError(3, 0, $aReturn) If ($iColumnsToFind > $iColumnsToSearch) Then Return SetError(4, 0, $aReturn) For $iRow = 0 To $iRowsToSearch - $iRowsToFind For $iColumn = 0 To $iColumnsToSearch - $iColumnsToFind Local $bValid = False For $i = 0 To $iRowsToFind - 1 For $p = 0 To $iColumnsToFind - 1 If ($aArrayToFind[$i][$p] = "" Or $aArrayToFind[$i][$p] = $aArrayToSearch[$iRow + $i][$iColumn + $p]) Then $bValid = True Else $bValid = False ExitLoop 2 EndIf Next Next If ($bValid) Then ; Number of valid results found $aReturn[0] += 1 ; row of the last valid result found $aReturn[1] = $iRow ; column of the last valid result found $aReturn[2] = $iColumn EndIf Next Next Return $aReturn EndFunc ;==>ArrayInArray ArrayInArray Returns an array: [0] = number of results found, [1] = row of the last valid result found, [2] = column of the last valid result found
    • distancesprinter
      By distancesprinter
      _ArrayDisplay($aArray, "Window Title", "1:", 0, Default, "Column") ; Expected results are rows 1 to the end of the array, all columns. The result is rows 0-1, all columns. The API reference is here:
      https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDisplay.htm
       
      Am I doing something wrong?
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have a question related to strings items in an Array and sorting. Maybe someone can advice me how to solve the issue.
      I have an Array of strings, every item of the Array is as following:
      INFO [13.06.2017 11:48:01] [Thread-13] [ConGenImpUsb -> waitForConnection]  INFO [07.06.2017 08:55:44] [main] MDU5 - Ver 5.1x I want to sort the item in the array by date and time, is there any function which allows me to sort by date/time?
      Thanks in advance