Posts: 56
Threads: 14
Joined: Jul 2008
Ok my last Question before my call center macro is done is about currency.
What i want to do is use currency to take a total of two Rich edit boxes and add them together
so i want to get the numbers from edit box number one and get the numbers from edit box number 2 and add them together in Edit box number two so
i can get a sum number
Thanks!
Posts: 229
Threads: 22
Joined: Sep 2007
str edit1 edit2
int add ed1 ed2
edit1.getwintext(id(? "?")
edit2.getwintext(id(? "?")
ed1=val(edit1)
ed2=val(edit2)
add = ed1+ed2
out add
Posts: 56
Threads: 14
Joined: Jul 2008
That code doesnt work for Currency.
It will not get the numbers behind the (comma) (,) or decimal...
Thanks for help anyways
Posts: 1,000
Threads: 253
Joined: Feb 2008
double d1(10.5) d2(1.5)
d1+d2
out d1
CURRENCY c1(10.5) c2(1.5)
c1.add(c2)
out c1
Posts: 1,000
Threads: 253
Joined: Feb 2008
I think this might be more help!!
str wText1="$13.75"
str wText2="$0.25"
wText1.trim('$')
wText2.trim('$')
CURRENCY c1 c2
c1=val(wText1 2)
c2=val(wText2 2)
c1.add(c2)
out c1
Posts: 1,000
Threads: 253
Joined: Feb 2008
Question from me on this:
How do you get the format fields to work?
Syntax
%[flags][width][.precision][h|l|I64|L]type
I've been wanting to show the decimal places on currency...I know how to get the right values, but how do you get "$14.00" to show up! I can only get $14
I just don't know where or how to call the flags and formatting options. Can we get an example?
Thanks.
Jimmy Vig
Posts: 229
Threads: 22
Joined: Sep 2007
Ghost Wrote:That code doesnt work for Currency.
It will not get the numbers behind the (comma) (,) or decimal...
Thanks for help anyways
sorry read question wrongly
Posts: 56
Threads: 14
Joined: Jul 2008
Gintaras you think that you might be able to help me on this one.
I need to get the Numbers from an ID edit not a string.
Posts: 56
Threads: 14
Joined: Jul 2008
Ok this is what i want to do
s.getwintext(id(2"EditBox")) ;;Checks for amount in box ....Example Amount is 2,204.00
s.setwintext(id(4"CallCenter")) ;; Sets the amount in My Edit box for my dialog
Now i want to check the number in id*(2) edit box and If it is greater then 0 to take the amount and add it into the amount of 2,204.00
So Amount in the dialog would be = to s (2,204.00)
and new amount next time macro checks the edit box *2 is 3,000
so i want it to take old amount that is stored in the dialog and take the new amount that is in editbox *2 and add them to form a sum in the dialog editbox...
Posts: 41
Threads: 10
Joined: Jun 2008
This is what i would do.
str a.getwintext(id(2 "EditBox"))
str b.getwintext(id(4 "CallCenter"))
a.findreplace("," "")
b.findreplace("," "")
a.trim('$')
b.trim('$')
CURRENCY c1 c2
c1=val(a 2)
c2=val(b 2)
c1.add(c2)
str c= c1
strrev c
a.replacerx("(\d{3})(?=\d+($|[^\.\w]))" "$1,")
strrev c
out c
Posts: 1,000
Threads: 253
Joined: Feb 2008
Here is a quick example of manipulating edit box values:
Function Dialog2
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 75 110 "Dialog"
;1 Button 0x54030001 0x4 18 72 48 14 "OK"
;2 Button 0x54030000 0x4 18 86 48 14 "Cancel"
;3 Edit 0x54030080 0x200 20 14 42 14 ""
;4 Edit 0x54030080 0x200 20 32 42 14 ""
;5 Edit 0x54030080 0x200 20 50 42 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""
str controls = "3 4 5"
str e3 e4 e5
e3="$0.00"
e4="$0.00"
e5="$0.00"
if(!ShowDialog("Dialog2" &Dialog2 &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
;Formats text in e3 when click out (ie $1,000.00)
,case EN_KILLFOCUS<<16|3
,str wText1.getwintext(id(3 win("Dialog" "#32770")))
,wText1.trim('$')
,wText1.findreplace("," "")
,double cText1
,cText1=val(wText1 2)
,wText1.format("$%.2f" cText1)
,strrev wText1
,wText1.replacerx("(\d{3})(?=\d+($|[^\.\w]))" "$1,")
,strrev wText1
,wText1.setwintext(id(3 win("Dialog" "#32770")))
;Formats text in e3 when click out (ie $1,000.00)
,case EN_KILLFOCUS<<16|4
,str wText2.getwintext(id(4 win("Dialog" "#32770")))
,wText2.trim('$')
,wText2.findreplace("," "")
,double cText2
,cText2=val(wText2 2)
,wText2.format("$%.2f" cText2)
,strrev wText2
,wText2.replacerx("(\d{3})(?=\d+($|[^\.\w]))" "$1,")
,strrev wText2
,wText2.setwintext(id(4 win("Dialog" "#32770")))
;Updates when text is changed in e3 and e4
,case [EN_CHANGE<<16|3,EN_CHANGE<<16|4]
,;gets window text from text box id 3 and assigns it to CURRENCY c1
,double c1
,wText1.getwintext(id(3 win("Dialog" "#32770")))
,wText1.trim('$')
,wText1.findreplace("," "")
,c1=val(wText1 2)
,;gets window text from text box id 4 and assigns it to CURRENCY c2
,double c2
,wText2.getwintext(id(4 win("Dialog" "#32770")))
,wText2.trim('$')
,wText2.findreplace("," "")
,c2=val(wText2 2)
,out c1
,out c2
,;math section...can be anything you want to see. Right now just adds the two
,double c3=c1+c2
;Formats the final output (ie $1,000.00)
,str Total.format("$%.2f" c3)
,strrev Total
,Total.replacerx("(\d{3})(?=\d+($|[^\.\w]))" "$1,")
,strrev Total
,Total.setwintext(id(5 win("Dialog" "#32770")))
,
,case IDOK
,case IDCANCEL
ret 1
with the getwintext/setwintext you can pretty much get data and put it where ever you want.
Posts: 473
Threads: 33
Joined: Aug 2007
I took TheVig's example and tweaked it a little.
Function Ghost_Dialog
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 170 109 "Dialog"
;1 Button 0x54030001 0x4 38 88 48 14 "OK"
;2 Button 0x54030000 0x4 94 88 48 14 "Cancel"
;3 Edit 0x54030080 0x200 22 20 42 14 ""
;4 Edit 0x54030080 0x200 98 20 42 14 ""
;5 Edit 0x54030080 0x200 60 66 44 14 ""
;6 Button 0x54032000 0x0 58 38 48 14 "Get Total"
;7 Static 0x54000000 0x0 30 10 24 8 "Price 1"
;8 Static 0x54000000 0x0 106 10 24 8 "Price 2"
;9 Static 0x54000000 0x0 72 58 18 8 "Total"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""
str controls = "3 4 5"
str e3 e4 e5
e3="$0.00"
e4="$0.00"
e5="$0.00"
if(!ShowDialog("Ghost_Dialog" &Ghost_Dialog &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
;Grabs money Value of Price 1.
,case EN_KILLFOCUS<<16|3
,CURRENCY- c1
,str wText1.getwintext(id(3 hDlg))
,wText1.trim('$')
,wText1.findreplace("," "")
,c1=val(wText1 2)
,wText1.getwintext(id(3 hDlg))
,wText1.trim('$')
,wText1.format("$%s" wText1)
,wText1.setwintext(id(3 hDlg))
;Grabs money value of Price 2.
,case EN_KILLFOCUS<<16|4
,CURRENCY- c2
,str wText2.getwintext(id(4 hDlg))
,wText2.trim('$')
,wText2.findreplace("," "")
,c2=val(wText2 2)
,wText2.getwintext(id(4 hDlg))
,wText2.trim('$')
,wText2.format("$%s" wText2)
,wText2.setwintext(id(4 hDlg))
,case 6 ;;Hit button for Combined total.
,CURRENCY c3
,c3.add(c1 c2)
,str Total=c3
,Total.format("$%s" Total)
,Total.setwintext(id(5 hDlg))
,case IDOK
,case IDCANCEL
ret 1
Taking on Quick Macros one day at a time
|