Sign in to follow this  
Followers 0
LukeJrs

$match if not match then execute command

5 posts in this topic

I need some help matching many of my post keep falling less people helping me out to understand this Autoit language. The thing is English aint my native language so is hard to understand me.

The script in bottom work really great another word More cleaner and Great undertstanding. I'm love with it thanks to ssubirias3 But One part i'm lost with this project.Let say if i wanted like to find a value in the website but cannot be found on Dim $avCodes array in script to match the case god is so hard to explain.

If value can't be found in $avCodes on the website to locate any of the value then exit loop and then if no result was found in $avCodes then execute msg pop saying couldnt find.

CODE
#include <IE.au3>

#include <String.au3>

#include <array.au3>

; $avCodes contains the strings you want to search for

; NOTE: last two values in the array are in the html code.

Dim $avCodes[6] = ["68819", "73501", "73417", "72146", "68994", "48526"]

; Create an invisible browser

$soIE1 = _IECreate("http://www.freewebs.com/lukejrs/testvar.html", 0, 0, 1)

$sText1 = _IEDocReadHTML($soIE1) ;READ FROM HTML CODE ON WEBSITE

$avFeature = _StringBetween($sText1, 'teleFeature.code = "', '";') ; FEATURE

For $i = 0 To UBound($avCodes) - 1

$Input = $avFeature[$i]

Switch $Input

Case 68819, 73501, 73417

;.... some unique calculation charging 30% extra.....

MsgBox(0, "account is over by: ", $Input & " and will be charged 30% fee")

Case 72146, 48526

;.... some unique calculation charging 15% extra.....

MsgBox(0, "account is over by: ", $Input & " and will be charged 15% fee")

Case 68994

;.... some unique calculation charging 65% extra.....

MsgBox(0, "account is over by: ", $Input & " and will be charged 65% fee")

EndSwitch

Next

Share this post


Link to post
Share on other sites



It might not be the fastest but it certainly does what you want:

#include <IE.au3>
#include <String.au3>
#include <array.au3>
Dim $match = 0
; $avCodes contains the strings you want to search for
; NOTE: last two values in the array are in the html code.
Dim $avCodes[6] = ["68819", "73501", "73417", "72146", "68994", "48526"]

; Create an invisible browser
$soIE1 = _IECreate("http://www.freewebs.com/lukejrs/testvar.html", 0, 1, 1)
$sText1 = _IEDocReadHTML($soIE1) ;READ FROM HTML CODE ON WEBSITE
$avFeature = _StringBetween($sText1, 'teleFeature.code = "', '";') ; FEATURE

For $i = 0 to UBound($avFeature)-1
    For $k = 0 to 5     ;5 is the dimension of your $avCodes array
        If StringInStr($avFeature[$i], $avCodes[$k]) Then
            $match = 1
            Switch $avFeature[$i]
                Case 68819, 73501, 73417
                ;.... some unique calculation charging 30% extra.....
                MsgBox(0, "account is over by: ", $avCodes[$k] & " and will be charged 30% fee")
                Case 72146
                ;.... some unique calculation charging 15% extra.....
                MsgBox(0, "account is over by: ", $avCodes[$k] & " and will be charged 15% fee")
                Case 68994, 48526
                ;.... some unique calculation charging 65% extra.....
                MsgBox(0, "account is over by: ", $avCodes[$k] & " and will be charged 65% fee")
            EndSwitch
        EndIf
    Next
Next
If $match = 0 Then
    MsgBox(0, "", "nothing found")
EndIf

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

YOUR GENIUS, I can finally continue with the project so much to learn i was on right track but silly me i put AND for like

For $i = 0 to UBound($avFeature)-1 and $a = 0 to UBound($avCodes)-1

LMAO silly mistake.

Also about the command line 5 dimension as 0,1,2,3,4,5 because Dim $avCodes[6] = ["68819", "73501", "73417", "72146", "689914", "48526"] is a six dimision or 5? should $avCodes be like Dim $avCodes[5] = ["68819", "73501", "73417", "72146", "689914", "48526"]

CODE

For $k = 0 to 5 ;5 is the dimension of your $avCodes array

Edited by LukeJrs

Share this post


Link to post
Share on other sites

The dimension is 6 but an array is 0 based so the values are 0, 1, 2, 3, 4, 5 = total =6 values:


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

thank you so much and everyone else who helped me thanks.

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