Renderer

AutoIT split 2 or more strings at the same time.

4 posts in this topic

Hello guys. I've got one more question to ask you. How can i split 2 or more strings at the same time, and return the results? Thanks in advance!

Share this post


Link to post
Share on other sites



@JohnOne means AutoIt is not multi-threaded so you can't literally do two things at the same exact time.  Also, there is no clear function to compare arrays, you need to walk each element.  Check out this example which includes a reference to the wiki:

; array compare - must compare each element
; from the wiki:https://www.autoitscript.com/wiki/Arrays#Comparing_Arrays
;You have to instead, compare all elements one after the other.
;It might be a good idea to first compare array sizes if that can vary for both the compared arrays!

#include <Array.au3>
global $array1,$array2, $delimeter

$delimeter=" "
$string1="I am string 1"
$string2="I am string 2"

;split the strings into arrays
$array1=StringSplit($string1,$delimeter)
;_ArrayDisplay($array1) ; debug in case you want to peek inside the array
$array2=StringSplit($string2,$delimeter)
;_ArrayDisplay($array2) ; debug in case you want to peek inside the array

; quick check to see if the arrays are the same size - if not the strings are different
if UBound($array1) <> UBound($array2) Then
    MsgBox(0,'',"arrays are different sizes - so strings are different")
EndIf


for $a=1 to ubound($array1)-1
    if $array1[$a]<>$array2[$a] Then
        MsgBox(0,'',$array1[$a]&" is not the same as: " & $array2[$a])
    EndIf
Next

 


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

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