gumby Posted June 20, 2005 Share Posted June 20, 2005 Hi, sorry i this is obvious, but this is the first program i've ever written.. .. basically i've made sort of caluculator, but I need it to return the figures with the commas inserted into the thousands.. ie 1,000.00 etc... can't figure it for the life of me help appreciate... code is as follows cheers from the gumby.. include <GUIConstants.au3> Opt("GUIOnEventMode", 1) GuiCreate("title", 450, 450) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $font="Arial" GUISetFont (10,20,$font) GuiSetState() Dim $total,$tdec, $total2, $marginreq, $totbroke, $breakeven, $code2, $moveinc, $brokex1,$netloss, $broke, $SS_LEFT, $code1, $position BitOr($GUI_SS_DEFAULT_LABEL, $SS_LEFT, $ES_UPPERCASE, $ES_RIGHT) Opt("WinTitleMatchMode", "") StringFormat ( "var2=%.2f#", $total, $tdec, $total2, $marginreq, $totbroke, $breakeven,$moveinc, $brokex1,$netloss, $broke ) $font="Arial" ;1st line, stoke code, volume & price GUICtrlCreateGroup ("", 5, 0, 440, 70) $font="Arial Bold" GUICtrlCreateLabel ("CODE", 10, 15,100,20) GUICtrlSetBkColor(-1,0xF9EC20) ;YELLOW $code=GUICtrlCreateInput ("", 10, 30, 100, 35,($ES_UPPERCASE)) GUICtrlSetFont (-1,20,$font) GUICtrlSetBkColor(-1,0xF9EC20) ;GUICtrlSetOnEvent ( -1, "codeentered" ) $Shortlong=GUICtrlCreateButton ( "short", 125,20 , 70, 22) GUICtrlSetOnEvent ( -1, "buttonclicked" ) $shortlong2=GUICtrlCreateButton ( "long", 125,42 , 70, 22) GUICtrlSetOnEvent ( -1, "button2clicked" ) GUICtrlCreateLabel ("Amount", 200, 25, 70) GUICtrlSetBkColor(-1,0xF9EC20) ;YELLOW $volume=GUICtrlCreateInput ("", 200, 40, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Price", 275, 25, 70, 20) ; GUICtrlSetBkColor(-1,0xF9EC20) ;YELLOW $price=GUICtrlCreateInput ("", 275, 40, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Total Outlay", 350, 10,70, 35,($SS_CENTER)) $var2=GUICtrlCreateInput ("", 350, 40, 70, 20, ($ES_RIGHT)) ;2nd line , margin percent, margin required GUICtrlCreateLabel ("CFD/Share", 5, 90, 80, 15) GUICtrlSetBkColor(-1,0xF9EC20) ;YELLOW $cfdshare=GUICtrlCreateCombo ("", 5,105, 80, 20) GUICtrlSetData(-1,"CFD 5%|CFD 10%|Share","") GUICtrlCreateLabel ("Margin %", 125, 88,) GUICtrlSetColor(-1,0x00aa00) ; green $margin=GUICtrlCreateInput ("", 125, 105, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Margin Required", 350, 73, 70, 30, ($SS_CENTER)) $var3=GUICtrlCreateInput ("", 350, 105, 70,20 , ($ES_RIGHT)) ;3rd line, brokerage x1, total brokerage GUICtrlCreateLabel ("Brokerage x 1", 275, 126,65,35,($SS_CENTER) ) $var4=GUICtrlCreateInput ("", 275, 160, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Total Brokerage", 350, 126,65,35,($SS_CENTER)) GUICtrlSetColor(-1,0xff0000) ; Red $var5=GUICtrlCreateInput ("", 350, 160, 70, 20, ($ES_RIGHT)) ;4th line, movement in c to cover brokerage, breakeven price GUICtrlCreateLabel ("Move in c to cover broke", 270, 183,75,35,($SS_CENTER) ) $var6=GUICtrlCreateInput ("", 275, 215, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Break Even Price", 350, 183, 70, 35, ($SS_CENTER)) $var7=GUICtrlCreateInput ("", 350, 215, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Profit / loss per c move", 350, 240,70,30, ($SS_CENTER)) $var8=GUICtrlCreateInput ("", 350, 275, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Take Profit target", 200, 298, 70,35,($SS_CENTER)) ; PROFIT GUICtrlSetBkColor(-1,0xF9EC20) ;YELLOW $takeprot=GUICtrlCreateInput ("", 200, 330, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Net profit on target", 350, 298, 70, 35, ($SS_CENTER)) $var9=GUICtrlCreateInput ("", 350, 330, 70, 20, ($ES_RIGHT)) GUICtrlCreateGroup ("", 5, 350, 440, 75) ; STOP LOSS GUICtrlCreateLabel ("STOP LOSS", 10, 350,) GUICtrlCreateLabel ("Stop Loss set at", 200, 365, 70,35, ($SS_CENTER)) GUICtrlSetColor(-1,0xff0000) ; Red $stoploss=GUICtrlCreateInput ("", 200, 400, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Points from Entry", 275, 365, 70,35, ($SS_CENTER)) GUICtrlSetColor(-1,0xff0000) ; Red $var10=GUICtrlCreateInput ("", 275, 400, 70, 20, ($ES_RIGHT)) GUICtrlCreateLabel ("Net loss incl broke", 350, 365,70,35, ($SS_CENTER)) GUICtrlSetColor(-1,0xff0000) ; Red $var11=GUICtrlCreateInput ("", 350, 400, 70, 20, ($ES_RIGHT)) AutoItSetOption("WinTitleMatchMode", 4) sleep(5000) Func buttonclicked() GUISetBkColor (0xF2D4D5) $position="short" EndFunc Func button2clicked() GUISetBkColor (0xD4ECF7) $position="long" EndFunc $code1=GUICtrlRead($code) WinSetTitle("title","",$code1) While 1 ;StringFormat ("var2=%.2f#", $total, $tdec, $total2, $marginreq, $totbroke, $breakeven,$moveinc, $brokex1,$netloss, $broke ) $CFD=GUICtrlRead ($cfdshare) If $CFD ="CFD 5%" Then $CFD2="5" GUICtrlSetData($margin,$CFD2,"") $broke=($total* 0.001) $broke2=StringFormat ("%.2f",$broke) GUICtrlSetData($var4,$broke2,"") ElseIf $CFD="CFD 10%" Then $CFD2="10" GUICtrlSetData($margin,$CFD2,"") $broke=($total* 0.001) $broke2=StringFormat ("%.2f",$broke) GUICtrlSetData($var4,$broke2,"") Else If $CFD="Share" Then $broke="34.00" $CFD4="" GUICtrlSetData($margin,$CFD4,"") GUICtrlSetData($var4,$broke,"") EndIf EndIf $total=(GUICtrlRead ($volume) * GUICtrlRead ($price)) $total2=StringFormat("%.2f",$total) GUICtrlSetData($var2,$total2,"") $marginreq=((GUICtrlRead ($margin) * $total)/100) $marginreq2=StringFormat("%.2f",$marginreq) GUICtrlSetData($var3,$marginreq2,"") $totbroke=($broke * 2) $totbroke2=StringFormat("%.2f",$totbroke) GUICtrlSetData($var5,$totbroke2,"") $moveinc=($totbroke/ GUICtrlRead ($volume)) $moveincr = Round($moveinc, 2) GUICtrlSetData($var6,$moveincr,"") If $position ="short" Then $breakeven=(GUICtrlRead ($price) - $moveinc) $breakevenr = Round($breakeven, 3) $breakevenr2=StringFormat("%.2f",$breakevenr) GUICtrlSetData($var7,$breakevenr2,"") ElseIf $position ="long" Then $breakeven=(GUICtrlRead ($price) + $moveinc) $breakevenr = Round($breakeven, 3) $breakevenr2=StringFormat("%.2f",$breakevenr) GUICtrlSetData($var7,$breakevenr,"") EndIf $profitloss=(GUICtrlRead ($volume) *0.01) $profitloss2=StringFormat("%.2f",$profitloss) GUICtrlSetData($var8,$profitloss2,"") If $position ="short" Then $netprofit=((GUICtrlRead ($price)- GUICtrlRead ($takeprot))* GUICtrlRead ($volume)-$totbroke) $netprofitr = Round($netprofit, 2) $netprofitr2=StringFormat("%.2f",$netprofitr) GUICtrlSetData($var9,$netprofitr2,"") ElseIf $position="long" Then $netprofit=(((GUICtrlRead ($takeprot) * GUICtrlRead ($volume))-$totbroke)-$total) $netprofitr = Round($netprofit, 2) $netprofitr2=StringFormat("%.2f",$netprofitr) GUICtrlSetData($var9,$netprofitr2,"") EndIf If $position ="short" Then $points=(GUICtrlRead ($stoploss) - GUICtrlRead ($price)) $pointsr = Round($points, 2) $pointsr2 = StringFormat("%.2f",$pointsr) GUICtrlSetData($var10,$pointsr2,"") ElseIf $position="long" Then $points=(GUICtrlRead ($price) - GUICtrlRead ($stoploss)) $pointsr = Round($points, 2) $pointsr2 = StringFormat("%.2f",$pointsr) GUICtrlSetData($var10,$pointsr2,"") EndIf If $position ="short" Then $netloss=((GUICtrlRead ($volume) *$points)+$totbroke) $netlossr=Round($netloss, 2) $netlossr2=StringFormat("%.2f",$netlossr) GUICtrlSetData($var11,$netlossr2,"") ElseIf $position ="long" Then $netloss=((GUICtrlRead ($volume) *$points)+$totbroke) $netlossr=Round($netloss, 2) $netlossr2=StringFormat("%.2f",$netlossr) GUICtrlSetData($var11,$netlossr2,"") EndIf WEnd Link to comment Share on other sites More sharing options...
GaryFrost Posted June 20, 2005 Share Posted June 20, 2005 #81600 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...
gumby Posted June 21, 2005 Author Share Posted June 21, 2005 Hi, thanx for this, however it won't work with the decimal places? Any ideas? cheers Link to comment Share on other sites More sharing options...
buzz44 Posted June 21, 2005 Share Posted June 21, 2005 Hey, I just updated my function so it now supports decimal places . Try the above link again and look at my latest post /w the update. qq Link to comment Share on other sites More sharing options...
gumby Posted June 23, 2005 Author Share Posted June 23, 2005 Legend! 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