youtuber

if elseif string issues

7 posts in this topic

#1 ·  Posted (edited)

if needs single error message
Multiple line breaks give error the messages!

ElseIf Not StringInStr($sitelisturl[$i] <> $aUrlArrayFind2[0],1) Then
    ConsoleWrite($aUrlArrayFind2[0] & " This site " & "not in rankings")

#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 338, 438)
$aRankingEdit = GUICtrlCreateEdit("", 32, 32, 225, 193)
GUICtrlSetData(-1, "https://www.autoitscript.com/testurlsimilar" & @CRLF & _
"https://www.autoitscript.org/autoitscript2.com/autoitscriptasdf.com" & @CRLF & _
"https://www.autoitscript3.com/autoitscript.com" & @CRLF & _
"https://www.autoitscript2.com/autoitscript5.com/autoitscript.com")
$Button1 = GUICtrlCreateButton("Button1", 96, 264, 75, 25)

GUISetState(@SW_SHOW)
$Count = 1
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
$aFindofrowsReadUrl = "https://www.autoitscript.com/test213213"

$aUrlArrayFind2 = StringRegExp($aFindofrowsReadUrl, 'https?://[^/]+',1)

$sitelisturl = StringSplit(StringStripCR(GUICtrlRead($aRankingEdit)), @LF)

        For $i = 1 To UBound($sitelisturl) - 1
           $sitenamestr = StringRegExp($sitelisturl[$i], 'https?://[^/]+', 1)

If StringInStr($sitelisturl[$i], $aUrlArrayFind2[0]) Then

 ConsoleWrite($sitenamestr[0] & " This site " & $i & "." & "ranking" & @CRLF)
ElseIf Not StringInStr($sitelisturl[$i] <> $aUrlArrayFind2[0],1) Then
    ConsoleWrite($aUrlArrayFind2[0] & " This site " & "not in rankings")
EndIf
        Next

    EndSwitch
WEnd

 

Edited by youtuber

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This makes no sense to me.
ElseIf Not StringInStr($sitelisturl[$i] <> $aUrlArrayFind2[0],1)

The following is a case sensitive string search.
ElseIf Not StringInStr($sitelisturl[$i], $aUrlArrayFind2[0],1) Then

Edited by czardas

Share this post


Link to post
Share on other sites

ElseIf Not StringInStr($sitelisturl[$i], $aUrlArrayFind2[0],1) Then

There is no error for this

GUICtrlSetData(-1, "https://www.autoitscriptasdf.com/testurlsimilar" & @CRLF & _
"https://www.autoitscript.org/autoitscript2.com/autoitscriptasdf.com" & @CRLF & _
"https://www.autoitscript3.com/autoitscript.com" & @CRLF & _
"https://www.autoitscript2.com/autoitscript5.com/autoitscript.com")

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Please explain what you are trying to do, because the code is not making much sense to me. The statement ==>
Not StringInStr($sitelisturl[$i] <> $aUrlArrayFind2[0],1) will always be true, even though it's coding nonesense.

Edited by czardas

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

 

#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 338, 438)
$aRankingEdit = GUICtrlCreateEdit("", 32, 32, 225, 193)
GUICtrlSetData(-1, "https://www.autoitscriptasdf.com/testurlsimilar" & @CRLF & _
"https://www.autoitscript.org/autoitscript2.com/autoitscriptasdf.com" & @CRLF & _
"https://www.autoitscript3.com/autoitscript.com" & @CRLF & _
"https://www.autoitscript2.com/autoitscript5.com/autoitscript.com")
$Button1 = GUICtrlCreateButton("Button1", 96, 264, 75, 25)

GUISetState(@SW_SHOW)
$Count = 1
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
$aFindofrowsReadUrl = "https://www.autoitscript.com/test213213"
$aUrlArrayFind2 = StringRegExp($aFindofrowsReadUrl, 'https?://[^/]+',1)
$aUrlArrayFind3 = StringRegExp($aFindofrowsReadUrl, '(?:http[s]?://[^/]+)',1)

$sitelisturl = StringSplit(StringStripCR(GUICtrlRead($aRankingEdit)), @LF)
        For $i = 1 To UBound($sitelisturl) - 1
           $sitenamestr = StringRegExp($sitelisturl[$i], 'https?://[^/]+', 1)
           $sitenamestr2 = StringRegExp($sitelisturl[$i], '(?:http[s]?://[^/]+)',1)
If StringInStr($sitelisturl[$i], $aUrlArrayFind2[0]) Then

 ConsoleWrite($sitenamestr[0] & " This site " & $i & "." & "ranking" & @CRLF)
ElseIf Not StringInStr($sitenamestr2, $aUrlArrayFind3[0]) Then
    ConsoleWrite($aUrlArrayFind2[0] & " This site " & "not in rankings")
EndIf
        Next
    EndSwitch
WEnd

 

Edited by youtuber

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I'm not an expert in regexp. However I think using forward slash as a delimiter is not a good idea for web URLs. Can you change that to use bar | instead? It should make your task a lot easier.

Edited by czardas

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

regex no problem :)

What I mean is that
If StringInStr($sitelisturl[$i], $aUrlArrayFind2[0]) Then

 ConsoleWrite($sitenamestr[0] & " This site " & $i & "." & "ranking" & @CRLF)
Else
    ConsoleWrite($aUrlArrayFind2[0] & " This site " & "not in rankings" & @CRLF);But there is more explanation than one line here
EndIf

I do not want multiple explanations

Edited by youtuber

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