Multiplying variables

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
allthenames
Newbie
Posts: 18
Joined: Wed Aug 18, 2010 5:51 pm

Multiplying variables

Post by allthenames » Wed Aug 18, 2010 7:22 pm

Code: Select all

//Modify buffer size if required ...
Let>SPAN70_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,70,0,SPAN70,r

]Let>15=SPAN70*.10
WaitReady>1
Let>WIN_REGEX=1
SetFocus>notepad*
WaitWindowOpen>Notepad*
wait>2
Send>15
I haven't been able to find any examples or ways of doing this on the forum. I'm using a screen scrape script made with WebRecorder however the information that i have scraped (the variable SPAN70) needs to be multiplied by .10 in order to remove the last two zeros.
Thanks for your help
-Ben

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Aug 18, 2010 8:18 pm

needs to be multiplied by .10 in order to remove the last two zeros.

Code: Select all

Let>SPAN70=0.03
Let>Result=SPAN70*.1
MessageModal>Result
This gives the result of 0.003

needs to be multiplied by .10 in order to remove the last two zeros.
Not sure what you want to do here..... multiplying by 10 will move the decimal point one place to the right. Multiplying by 0.10 will move the decimal point one place to the LEFT.

If you really need the data formatted to a specific pattern there are better ways to do this - some methods use VBScript functions.

If you could provide more information on the valid values for SPAN70 and what you want the values transformed into, then someone can give a more specific solution to your problem.

Note: In your code you are creating a variable with the name of 15 - That is not wise. Try to name your variables starting with an Alpha character and be more descriptive.

allthenames
Newbie
Posts: 18
Joined: Wed Aug 18, 2010 5:51 pm

multiplying variables from screen scrape

Post by allthenames » Wed Aug 18, 2010 9:19 pm

Thanks for your help.
For clarity here is my entire script. As you can see this is a screen scraping script that assigns each tag a variable. I'm trying to then multiply that variable by .01 in order to get rid of the last two zeros which are actually the cents amount. for example $3,000 is actually coming to $3,00000 because of the extra two zeros.

Also when send these variables to notepad there is a space after the number I don't know if that is the reason why it is not calculating correctly.

Code: Select all

// Generated by MacroScript WebRecorder 2.1
// Recorded on Wednesday, August 18, 2010, at 12:23 PM

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[0]

IE_Navigate>%IE[0]%,http://www.ksl.com/index.php?nid=443,r
IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

//Modify buffer size if required ...
Let>SPAN14_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,14,0,SPAN14,r
*
//Modify buffer size if required ...
Let>SPAN18_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,18,0,SPAN18,r

//Modify buffer size if required ...
Let>SPAN22_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,22,0,SPAN22,r

//Modify buffer size if required ...
Let>SPAN26_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,26,0,SPAN26,r

//Modify buffer size if required ...
Let>SPAN30_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,30,0,SPAN30,r

//Modify buffer size if required ...
Let>SPAN34_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,34,0,SPAN34,r

//Modify buffer size if required ...
Let>SPAN38_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,38,0,SPAN38,r

//Modify buffer size if required ...
Let>SPAN42_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,42,0,SPAN42,r

//Modify buffer size if required ...
Let>SPAN46_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,46,0,SPAN46,r

//Modify buffer size if required ...
Let>SPAN50_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,50,0,SPAN50,r

//Modify buffer size if required ...
Let>SPAN54_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,54,0,SPAN54,r

//Modify buffer size if required ...
Let>SPAN58_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,58,0,SPAN58,r

//Modify buffer size if required ...
Let>SPAN62_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,62,0,SPAN62,r

//Modify buffer size if required ...
Let>SPAN66_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,66,0,SPAN66,r

//Modify buffer size if required ...
Let>SPAN70_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,70,0,SPAN70,r

WaitReady>1
Let>Result=SPAN70*.01
MessageModal>Result

Code: Select all


This is the result i get from message Modal:
$1,50000 *.01

now that i think about it i wonder if it is not calculating due to the $ sign or the space after $1,50000.  Any way around that?

I'm obviously new and i'm not sure if there is another route i should be looking into in order to get these screen scraped variables multiplied.


Thanks again
-Ben

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Aug 18, 2010 10:22 pm

Try something like this then:

Code: Select all

Let>temp=$1,50000%SPACE%
Trim>temp,temp
StringReplace>temp,$,,temp
Let>comma=,
StringReplace>temp,comma,,temp
Let>result=temp*.01
MessageModal>result
The Trim takes off any spaces, and then StringReplace gets rid of the $ and comma. You were on the right track..... for a value to be recognized as a number it cannot have spaces or special characters.

allthenames
Newbie
Posts: 18
Joined: Wed Aug 18, 2010 5:51 pm

wow

Post by allthenames » Mon Jan 17, 2011 1:37 am

that worked beautifully. thanks. now i just have a simple easy question.

i'm trying to do the click tag function and its not working.

heres my new script

// Generated by MacroScript WebRecorder 2.1
// Recorded on Wednesday, January 12, 2011, at 09:50 AM

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[0]

IE_Navigate>%IE[0]%,http://www.ksl.com/index.php?nid=443,r
IE_Wait>%IE[0]%,r
Wait>delay


Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

//Modify buffer size if required ...
Let>SPAN18_SIZE=4098
IE_ExtractTag>%IE[0]%,,SPAN,18,0,SPAN18,r
MidStr>r_6,1,r,SPAN18

Let>temp=%SPAN18%
Trim>temp,temp
StringReplace>temp,$,,temp
Let>comma=,
StringReplace>temp,comma,,temp
Let>result=temp*.01
Let>offer=result*.7


wait>3

IE_ClickTag>%IE[0]%,,SPAN,18,0,SPAN18,r
MessageModal>offer

Label>end_script















everything works great except the click tag.
-Ben

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts