mannrak2003 Posted December 2, 2006 Share Posted December 2, 2006 (edited) Sir, I am writing a automatic login and reverse auction program based on a particular site $g_szVersion = "My Script 1.1" If WinExists($g_szVersion) Then Exit ; It's already running AutoItWinSetTitle($g_szVersion) HotKeySet("^!x", "MyExit") #include <IE.au3> Opt("WinWaitDelay",100) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) Opt("OnExitFunc", "endscript") $i=0.013 ;- The initial auction value $j=Round($i,2) ;-To make sure we enter only a whole number plus two decimal digits like 101.03 and not 101.0300000000000000 $oIE1=_IECreate("http://www.xxxxxx.com/page2.asp",1);- The initial page where we login _IELoadWait($oIE1) Do $oForm = _IEFormGetObjByName($oIE1,"frmbidsubmit") $oLoginName = _IEFormElementGetObjByName($oForm,"loginname") _IEFormElementSetValue ($oLoginName,"xxxxxxxxxx") $oBidAmount = _IEFormElementGetObjByName($oForm,"bid_amt") _IEFormElementSetValue ($oBidAmount,$j) $oSubmit = _IEFormElementGetObjByName($oForm,"Submit") _IEAction ($oSubmit, "click") $oIE2=_IEAttach("http://www.xxxxxx.com/page3.asp","url");- The page navigated to on submission of the form from first page. Is this the correct way? .I get lots of errors like --> IE.au3 Warning from function _IEAttach, $_IEStatus_NoMatch _IEImgClick($oIE2,"Bid Again","alt") ;- On clicking this image with alternate text we return to the initial page with $oIE1 Here error --> IE.au3 Error from function _IEImgClick, $_IEStatus_InvalidDataType _IELoadWait($oIE1) $j=$j+0.005 ;-I did this because it was the only way I could increment the values by .01. How is it incremented two times in a single Do ... Until loop ? Until $j=101.00 Func MyExit() Exit EndFunc The problem begins at the 33rd iteration of the "$j" value.At the 33rd iteration the Round function does not seem to work.and the form element value is set as a total of a 16 digit number including the decimal point.At the same time a javascript alert from the source of the page is triggered as given below var dot_posn = bid_amt.indexOf('.') if (dot_posn > 0) { var decplaces = bid_amt.substring(dot_posn+1) if (decplaces.length > 2) { alert("Your bid amount can be upto 2 decimal places only"); document.frmbidsubmit.bid_amt.focus(); return false; } } The full source of the page page2.asp is given below : expandcollapse popup<html> <head> <title>Bid</title> <script type="text/Javascript"> <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> function resetVal(val) { if((document.frmbidsubmit.bid_amt.value=="000.00") && val=="bid_amt") { document.frmbidsubmit.bid_amt.value=""; } } function setVal(val) { if((document.frmbidsubmit.bid_amt.value=="") && val=="bid_amt") { document.frmbidsubmit.bid_amt.value="000.00"; } } function checkform() { //alert("Hi"); //return false; if (document.frmbidsubmit.bid_amt.value=='') { alert("Please enter your bid amount!") document.frmbidsubmit.bid_amt.focus(); return false; } else if (isNaN(document.frmbidsubmit.bid_amt.value)) { alert("The bid amount entered is not a numeric value!") document.frmbidsubmit.bid_amt.focus(); return false; } var bid_amt = document.frmbidsubmit.bid_amt.value if (bid_amt <= 0) { alert("Your bid amount should be greater then zero!") document.frmbidsubmit.bid_amt.focus(); return false; } var dot_posn = bid_amt.indexOf('.') if (dot_posn > 0) { var decplaces = bid_amt.substring(dot_posn+1) if (decplaces.length > 2) { alert("Your bid amount can be upto 2 decimal places only"); document.frmbidsubmit.bid_amt.focus(); return false; } } if (document.frmbidsubmit.loginname.value=='') { alert("Please enter your userid!") document.frmbidsubmit.loginname.focus(); return false; } document.frmbidsubmit.submit() document.frmbidsubmit.Submit.disabled = true } </script> </head> <body> <form name="frmbidsubmit" action="bidsubmit.asp" method="post"> <tr> <td align="right" bgcolor="#8F0000"><label></label> <span class="style3">Enter Your Bid Amount Rs. </span></td> <td width="43%" align="left" bgcolor="#8F0000"><input name="bid_amt" type="text" class="box" id="bid_amt" value="000.00" size="15" maxlength="9" onfocus="java script: resetVal('bid_amt')" onblur="java script: setVal('bid_amt')"></td> </tr> <tr> <td align="right" bgcolor="#8F0000"><span class="style3">Enter C2W User ID </span></td> <td align="left" bgcolor="#8F0000"><input name="loginname" type="text" class="box" id="loginname" size="15" maxlength="50" onfocus="java script: resetVal('loginname')" onblur="java script: setVal('loginname')"></td> </tr> <tr> <td width="57%" align="right" bgcolor="#8F0000" class="style1"></td> <td align="center" bgcolor="#8F0000"><input type="button" name="Submit" value="Submit" onclick="return checkform()"></td> </tr> </body> </html> Edited December 2, 2006 by mannrak2003 Link to comment Share on other sites More sharing options...
Valuater Posted December 2, 2006 Share Posted December 2, 2006 here is a skeleton of your use of $j $j is not rounded within the loop $i=0.013 ;- The initial auction value $j=Round($i,2) ;-To make sure we enter only a whole number plus two decimal digits like 101.03 and not 101.0300000000000000 $count = "" Do $count += 1 MsgBox(64, "Test #" & $count, "Rounded $j = " & $j, 1) $j=$j+0.005 ;-I did this because it was the only way I could increment the values by .01. How is it incremented two times in a single Do ... Until loop ? ;$j=Round($i,2) Until $j=101.00 8) Link to comment Share on other sites More sharing options...
GaryFrost Posted December 2, 2006 Share Posted December 2, 2006 $i=0.013 ;- The initial auction value $j=Round($i,2) ;-To make sure we enter only a whole number plus two decimal digits like 101.03 and not 101.0300000000000000 Do ConsoleWrite("$j " & $j & @TAB & @TAB & "Rounded $j = " & StringFormat("%.2f",$j) & @LF) $j+=0.005 ;-I did this because it was the only way I could increment the values by .01. How is it incremented two times in a single Do ... Until loop ? Until StringFormat("%.2f",$j)=101.00 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
mannrak2003 Posted December 2, 2006 Author Share Posted December 2, 2006 $i=0.013 ;- The initial auction value $j=Round($i,2) ;-To make sure we enter only a whole number plus two decimal digits like 101.03 and not 101.0300000000000000 Do ConsoleWrite("$j " & $j & @TAB & @TAB & "Rounded $j = " & StringFormat("%.2f",$j) & @LF) $j+=0.005 ;-I did this because it was the only way I could increment the values by .01. How is it incremented two times in a single Do ... Until loop ? Until StringFormat("%.2f",$j)=101.00Thank You for helping me ,Sir.I will post the final code a little later Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now