Jump to content

if elseif string issues


youtuber
 Share

Recommended Posts

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
Link to comment
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")

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

#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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...