03-15-2008, 08:12 AM
I am working up a count out dialog that will eventually be part of a simple book keeping program...here is what I have so far.
This is the dialog "Cash_Count":
Then the Math and stuff "Cash_Math":
A quick question about it all...how do I format the str so that it shows up as a dollar amount (i.e. $0.00)
I need to call the Count Out dialog from a button in a dialog (yet to be created) called "Deposit Form". Then grab the sTotal variable and put it in an edit box named TotalCash.
I just can't seem to get this to work. When I make an event for the button (case 4) and then put the function in there, QM states the function is expecting 4 arguments. I don't know what 4 it expects, but I wasn't planning on sending any in the first place!?!? A ShowDialog works here, but I don't think that's the right way to go about things at all, but it is the only way I have gotten any success at this.
Oh...and are there any ways to simplify the code I already have. I feel like it is a bit clunky. I am amazed I got what I have to work in the first place!
Please help.
Thanks.
This is the dialog "Cash_Count":
/Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 135 135 "Cash Count"
;1101 Edit 0x54030080 0x200 40 6 16 14 ""
;1102 Edit 0x54030080 0x200 40 22 16 14 ""
;1103 Edit 0x54030080 0x200 40 38 16 14 ""
;1104 Edit 0x54030080 0x200 40 54 16 14 ""
;1105 Edit 0x54030080 0x200 40 70 16 14 ""
;1106 Edit 0x54030080 0x200 40 86 16 14 ""
;1107 Edit 0x54030080 0x200 40 102 16 14 ""
;1108 Edit 0x54030080 0x200 94 6 16 14 ""
;1109 Edit 0x54030080 0x200 94 22 16 14 ""
;1110 Edit 0x54030080 0x200 94 38 16 14 ""
;1111 Edit 0x54030080 0x200 94 54 16 14 ""
;1112 Edit 0x54030080 0x200 94 70 16 14 ""
;1113 Edit 0x54030080 0x200 94 86 16 14 ""
;1119 Edit 0x54030080 0x200 94 102 38 14 ""
;1 Button 0x54030001 0x4 22 120 48 14 "OK"
;2 Button 0x54030000 0x0 76 120 48 14 "Cancel"
;20 Static 0x54000000 0x0 12 8 48 12 "$100"
;21 Static 0x54000000 0x0 12 24 48 12 "$50"
;22 Static 0x54000000 0x0 12 40 48 12 "$20"
;23 Static 0x54000000 0x0 12 56 48 12 "$10"
;24 Static 0x54000000 0x0 12 72 48 12 "$5"
;25 Static 0x54000000 0x0 12 88 48 12 "$2"
;26 Static 0x54000000 0x0 12 104 48 12 "$1"
;27 Static 0x54000000 0x0 66 8 48 12 "$1"
;28 Static 0x54000000 0x0 66 24 48 12 "$0.50"
;29 Static 0x54000000 0x0 66 40 48 12 "$0.25"
;30 Static 0x54000000 0x0 66 56 48 12 "$0.10"
;31 Static 0x54000000 0x0 66 72 48 12 "$0.05"
;32 Static 0x54000000 0x0 66 88 48 12 "$0.01"
;33 Static 0x54000000 0x0 66 104 48 12 "TOTAL"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "*" "1" ""
str controls = "1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119"
str e1101 e1102 e1103 e1104 e1105 e1106 e1107 e1108 e1109 e1110 e1111 e1112 e1113 e1119
e1101="0"
e1102="0"
e1103="0"
e1104="0"
e1105="0"
e1106="0"
e1107="0"
e1108="0"
e1109="0"
e1110="0"
e1111="0"
e1112="0"
e1113="0"
if(!ShowDialog("Cash_Count" &Cash_Count &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case EN_CHANGE<<16|1101
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1102
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1103
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1104
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1105
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1106
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1107
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1108
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1109
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1110
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1111
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1112
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case EN_CHANGE<<16|1113
,Cash_Math hDlg 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1119
,case IDOK
,case IDCANCEL
,case LBN_SELCHANGE<<16|3
ret 1
Then the Math and stuff "Cash_Math":
;/
function hDlg hundred fifty twenty ten five two one onec fiftyc quarterc dimec nickelc pennyc total
str sTotal
int sumHun sumFif sumTwe sumTen sumFiv sumTwo sumOne sumOnec sumFifc sumQuac sumDimc sumNicc sumPenc
str hundreds e1101.getwintext(id(hundred hDlg))
foreach(hundreds e1101) sumHun+val(hundreds)
str fiftys e1102.getwintext(id(fifty hDlg))
foreach(fiftys e1102) sumFif+val(fiftys)
str twentys e1103.getwintext(id(twenty hDlg))
foreach(twentys e1103) sumTwe+val(twentys)
str tens e1104.getwintext(id(ten hDlg))
foreach(tens e1104) sumTen+val(tens)
str fives e1105.getwintext(id(five hDlg))
foreach(fives e1105) sumFiv+val(fives)
str twos e1106.getwintext(id(two hDlg))
foreach(twos e1106) sumTwo+val(twos)
str ones e1107.getwintext(id(one hDlg))
foreach(ones e1107) sumOne+val(ones)
str onecs e1108.getwintext(id(onec hDlg))
foreach(onecs e1108) sumOnec+val(onecs)
str fiftycs e1109.getwintext(id(fiftyc hDlg))
foreach(fiftycs e1109) sumFifc+val(fiftycs)
str quartercs e1110.getwintext(id(quarterc hDlg))
foreach(quartercs e1110) sumQuac+val(quartercs)
str dimecs e1111.getwintext(id(dimec hDlg))
foreach(dimecs e1111) sumDimc+val(dimecs)
str nickelcs e1112.getwintext(id(nickelc hDlg))
foreach(nickelcs e1112) sumNicc+val(nickelcs)
str pennycs e1113.getwintext(id(pennyc hDlg))
foreach(pennycs e1113) sumPenc+val(pennycs)
CURRENCY Hun Fif Twe Ten Fiv Two One Onec Fifc Quac Dimc Nicc Penc sumTotal
Hun.mul(sumHun 100)
Fif.mul(sumFif 50)
Twe.mul(sumTwe 20)
Ten.mul(sumTen 10)
Fiv.mul(sumFiv 5)
Two.mul(sumTwo 2)
One.mul(sumOne 1)
Onec.mul(sumOnec 1)
Fifc.mul(sumFifc 0.5)
Quac.mul(sumQuac 0.25)
Dimc.mul(sumDimc 0.10)
Nicc.mul(sumNicc 0.05)
Penc.mul(sumPenc 0.01)
sumTotal.add(Hun Fif)
sumTotal.add(sumTotal Twe)
sumTotal.add(sumTotal Ten)
sumTotal.add(sumTotal Fiv)
sumTotal.add(sumTotal Two)
sumTotal.add(sumTotal One)
sumTotal.add(sumTotal Onec)
sumTotal.add(sumTotal Fifc)
sumTotal.add(sumTotal Quac)
sumTotal.add(sumTotal Dimc)
sumTotal.add(sumTotal Nicc)
sumTotal.add(sumTotal Penc)
sTotal=sumTotal
sTotal.setwintext(id(total hDlg))
A quick question about it all...how do I format the str so that it shows up as a dollar amount (i.e. $0.00)
I need to call the Count Out dialog from a button in a dialog (yet to be created) called "Deposit Form". Then grab the sTotal variable and put it in an edit box named TotalCash.
I just can't seem to get this to work. When I make an event for the button (case 4) and then put the function in there, QM states the function is expecting 4 arguments. I don't know what 4 it expects, but I wasn't planning on sending any in the first place!?!? A ShowDialog works here, but I don't think that's the right way to go about things at all, but it is the only way I have gotten any success at this.
Oh...and are there any ways to simplify the code I already have. I feel like it is a bit clunky. I am amazed I got what I have to work in the first place!
Please help.
Thanks.