Jump to content
Sign in to follow this  
smellyfingers

Help with decimal output

Recommended Posts

smellyfingers

Hi all, im trying to understand what is going on in this script, im getting a value from a webpage like 8,5378 and when multiplying with any other value it ignores the decimal, so if i input 10 the output becomes 80 when it should be 85,378, any idea?

#include <IE.au3>
#include <Misc.au3>
#include <String.au3>
#include <Array.au3>

Global $oIE
Global $kr
Global $eur
Global $prop
Global $summa
Global $frame
Global $newinfo
Global $varde
Global $swe = InputBox("SEK - EUR","Skriv in EUR du vill omvadla till SEK")

$oIE = _IECreate("http://www.nordea.se/F%c3%b6retag/Utland/Valutahantering/Daglig%2bmittkurs/1528952.html",0,0)
_IELoadWait($oIE)
Sleep(1000)
$frame = _IEBodyReadText($oIE)
;MsgBox(262144,"info1",$frame)
;Sleep(2000)
$prop = _StringBetween($frame," Euroområdet EUR Euro "," ")
;_ArrayDisplay($prop, 'Default Search')
$varde = $prop[0]
;StringReplace($varde,".",",",3)
MsgBox(262144,"info1",$varde)
;MsgBox(262144,"info2",$varde)
_IELoadWait($oIE)
_IEQuit($oIE)
$eur = Int($varde, 9)
$kr = Int($swe, 9)
$summa = Int($eur*$kr, 9)
MsgBox(262144,"EUR - SEK","SEK värde i EUR per " & " " & $swe & " KR " & "är" & " " & $summa)

Share this post


Link to post
Share on other sites
FireFox

Hi,

The comma is not recognized as a decimal, so you need to replace it with a point.

ConsoleWrite(Number("8,5378") & @CrLf)
ConsoleWrite(Number("8.5378") & @CrLf)

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
smellyfingers

#include <IE.au3>
#include <Misc.au3>
#include <String.au3>
#include <Array.au3>

Global $oIE
Global $kr
Global $eur
Global $prop
Global $summa
Global $slutsumma
Global $frame
Global $varde
Global $swe = InputBox("SEK - EUR","Skriv in EUR du vill omvadla till SEK")

$oIE = _IECreate("http://www.nordea.se/F%c3%b6retag/Utland/Valutahantering/Daglig%2bmittkurs/1528952.html",0,0)
_IELoadWait($oIE)
Sleep(1000)
$frame = _IEBodyReadText($oIE)
;MsgBox(262144,"info1",$frame)
;Sleep(2000)
$prop = _StringBetween($frame," Euroområdet EUR Euro "," ")
;_ArrayDisplay($prop, 'Default Search')
$varde = $prop[0]
$eur = StringReplace($varde,",",".",1)
$kr = StringReplace($swe,",",".",1)
MsgBox(262144,"info1",$eur & " " & $swe)
_IELoadWait($oIE)
_IEQuit($oIE)
$summa = $eur*$kr
$slutsumma = StringReplace($summa,",",".",1)
MsgBox(262144,"EUR - SEK","SEK värde i EUR per " & " " & $swe & " KR " & "är" & " " & $slutsumma)

Thanx Firefox! i forgot to actually save the stringreplace into a variable in the first place too and i noticed i tried replacing the wrong thing aswell. "blaming the headache" :)

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  

×