Jump to content

Recommended Posts

Posted (edited)

I want to go to a webpage, and report back if a page has a dollar value greater than $10,000.

My thought was to use _IEBodyReadText to make the webpage text into a string, then use StringInStr to detect if a string is greater than $10,000. But I see 2 issues, and I don't know if there is a workaround.

1) The formatting of the numbers is in currency. Can I use currency formatting and ">" (greater than) together?

2) Can StringinStr be used to detect if something is greater or less than something else?

TIA

***Edit***Added Psuedo Code***

$sUrl = "http://adventure-cruises.gordonsguide.com/adventurecenter/trips.cfm"
$oIE = _IECreate ($sUrl, 1)
$BodyReadText = _IEBodyReadText ($oIE)
If StringInStr ($BodyReadText, [Is greater than $10,000]) Then Msg(0,"","There is a Number on this Page that is Greater Than $10,000")
Edited by litlmike
Posted

You strip out the currency formatting before you compare using StringReplace()

$amount = "$10,000"

$amount = StringReplace($amount, "$", "")

$amount = StringReplace($amount, "$", "")

-or-

$amount = StringRegExpReplace($amount, "\D", "")

  • Moderators
Posted (edited)

#include <array.au3>
Local $s = "agas09eu0293kjasas-0-340,a9d09203kjad90$123,099a;sd9093"
Local $aArray = _ReturnNumGreaterThan10K($s)
If @error = 0 Then 
    _ArrayDisplay($aArray)
    If Number(StringReplace($aArray[0], ",", "")) > 10000 Then MsgBox(64, "Info", "Greater Than")
EndIf

Func _ReturnNumGreaterThan10K($sString)
    Local $aSRE = StringRegExp($sString, "(?s)(?i)\$(\d{2,},\d+)", 3)
    If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0)
    Return $aSRE
EndFunc

Edit:

Sorry, dummied it down a bit.

Edit2:

Had [1-9] there, but 2nd integer could be a zero, so just put \d{2,} for any two plus digits. You shouldn't have an issue unless these sites have something like: $01,328 or something :) like that!

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

StringRegExp comes to mind as a possible way to do get some of this work done.

But if I personally was trying to accomplish this, I would rely on the return value of StringInStr to find the first (and next) occurrance of "$", and use that in a StringMid function, returning the following number and the remainer of the string to two different variables. The proceedure could have some sort of loop.

Das Häschen benutzt Radar

Posted

#include <array.au3>
Local $s = "agas09eu0293kjasas-0-340,a9d09203kjad90$123,099a;sd9093"
Local $aArray = _ReturnNumGreaterThan10K($s)
If @error = 0 Then 
    _ArrayDisplay($aArray)
    If Number(StringReplace($aArray[0], ",", "")) > 10000 Then MsgBox(64, "Info", "Greater Than")
EndIf

Func _ReturnNumGreaterThan10K($sString)
    Local $aSRE = StringRegExp($sString, "(?s)(?i)\$(\d{2,},\d+)", 3)
    If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0)
    Return $aSRE
EndFunc

Edit:

Sorry, dummied it down a bit.

Edit2:

Had [1-9] there, but 2nd integer could be a zero, so just put \d{2,} for any two plus digits. You shouldn't have an issue unless these sites have something like: $01,328 or something :) like that!

Worked like a charm, thanks!

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
  • Recently Browsing   0 members

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