1. getText() and setText() program not working
- Posted by "Arthur B. Mashiatshidi" <arthurm at GOLDFIELDS.CO.ZA> Sep 15, 2000
- 477 views
I am new to Euphoria Programming, I have the following program which works only half way but does not perform other functions, particularly the calculate routine has failed to work, and I am frustrated. The program is well commented on the non-working parts. The program calls up a file called PROFILE.WIN - this a text file with a single sequence which is 8 long eg. {5,6,9,11,23,34,45,560} - You may simply copy this and paste in a note and save it as PROFILE.WIN Run the program to see how it works, your help is appreciated! --Profiler.exw -- by Arthur B. Mashiatshidi --Program to calculate Payout Profile --uses numbers taken from Profile.win file --Together with input numbers found in "ExDv1"... --Should be simple multiplication, ------------- but doesn't work! include win32lib.ew without warning --with trace --trace(1) -- These constant are holders for both static and dynmic information constant ProfWin = create(Window, " Payoff Profile Calculator ", 0, 150, 100, 650, 510, 0), --main titles PrLHd0 = create(CText, "P R I Z E D I V I S I O N S", ProfWin, 10, 5, 580, 30, 0), PrHdg1 = create(RText, " Division", ProfWin, 5, 45, 95, 30, 0), PrHdg2 = create(RText, " Tickets Matching ", ProfWin, 100, 45, 280, 30, 0), PrHdg3 = create(RText, " Ticket Value ", ProfWin, 390, 45, 100, 30, 0), PrHdg4 = create(RText, " Div R 0.00", ProfWin, 510, 45, 100, 30, 0), --Division heading titles HdDv1 = create(RText, "Div. 1 :", ProfWin, 10, 85, 80, 30, 0), HdDv2 = create(RText, "Div. 2 :", ProfWin, 10, 120, 80, 30, 0), HdDv3 = create(RText, "Div. 3 :", ProfWin, 10, 155, 80, 30, 0), HdDv4 = create(RText, "Div. 4 :", ProfWin, 10, 190, 80, 30, 0), HdDv5 = create(RText, "Div. 5 :", ProfWin, 10, 225, 80, 30, 0), HdDv6 = create(RText, "Div. 6 :", ProfWin, 10, 260, 80, 30, 0), HdDv7 = create(RText, "Div. 7 :", ProfWin, 10, 295, 80, 30, 0), --Numbers of Tickets Matched in each category TxDv1 = create(RText, " ", ProfWin, 100, 85, 280, 30, 0), TxDv2 = create(RText, " ", ProfWin, 100, 120, 280, 30, 0), TxDv3 = create(RText, " ", ProfWin, 100, 155, 280, 30, 0), TxDv4 = create(RText, " ", ProfWin, 100, 190, 280, 30, 0), TxDv5 = create(RText, " ", ProfWin, 100, 225, 280, 30, 0), TxDv6 = create(RText, " ", ProfWin, 100, 260, 280, 30, 0), TxDv7 = create(RText, " ", ProfWin, 100, 295, 280, 30, 0), -- Actual Payout per ticket ... input these numbers ExDv1 = create(EditText, " ", ProfWin, 400, 85, 100, 30, 0), ExDv2 = create(EditText, " ", ProfWin, 400, 120, 100, 30, 0), ExDv3 = create(EditText, " ", ProfWin, 400, 155, 100, 30, 0), ExDv4 = create(EditText, " ", ProfWin, 400, 190, 100, 30, 0), ExDv5 = create(EditText, " ", ProfWin, 400, 225, 100, 30, 0), ExDv6 = create(EditText, " ", ProfWin, 400, 260, 100, 30, 0), ExDv7 = create(EditText, " ", ProfWin, 400, 295, 100, 30, 0), -- Calculated Payout per Category AxDv1 = create(RText, " ", ProfWin, 520, 85, 100, 30, 0), AxDv2 = create(RText, " ", ProfWin, 520, 120, 100, 30, 0), AxDv3 = create(RText, " ", ProfWin, 520, 155, 100, 30, 0), AxDv4 = create(RText, " ", ProfWin, 520, 190, 100, 30, 0), AxDv5 = create(RText, " ", ProfWin, 520, 225, 100, 30, 0), AxDv6 = create(RText, " ", ProfWin, 520, 260, 100, 30, 0), AxDv7 = create(RText, " ", ProfWin, 520, 295, 100, 30, 0), TtlAx = create(RText, " ", ProfWin, 400, 330, 100, 30, 0), -- show number of bets as well Nxbets = create(RText, " ", ProfWin, 50, 340, 250, 30, 0), betVTx = create(RText, "Bet Amount: ", ProfWin, 50, 380, 210, 30, 0), -- not yet implemented betVal = create(LText, " ", ProfWin, 400, 410, 100, 30, 0), -- but harmless TtlxD = create(RText, "Gross :", ProfWin, 400, 410, 100, 30, 0), -- and this one -- some buttons to control the window btnClr = create(PushButton, "Clear", ProfWin, 210, 410, 100, 30, 0), btnCalc = create(PushButton, "Calculate", ProfWin, 320, 410, 120, 30, 0), btnClose = create(PushButton, "Close", ProfWin, 450, 410, 80, 30, 0), -- basic menu to exit gracefully MenuFile = create(Menu, "&File", ProfWin, 0, 0, 0, 0, 0), MenuExit = create(MenuItem, "E&xit", MenuFile, 0, 0, 0, 0, 0) -- set the background color and do font stuff setWindowBackColor( ProfWin, getSysColor(COLOR_APPWORKSPACE)) setFont(HdDv1,"Arial",10,1) setFont(HdDv2,"Arial",10,1) setFont(HdDv3,"Arial",10,1) setFont(HdDv4,"Arial",10,1) setFont(HdDv5,"Arial",10,1) setFont(HdDv6,"Arial",10,1) setFont(HdDv7,"Arial",10,1) setFont(TxDv1,"Arial",10,0) setFont(TxDv2,"Arial",10,0) setFont(TxDv3,"Arial",10,0) setFont(TxDv4,"Arial",10,0) setFont(TxDv5,"Arial",10,0) setFont(TxDv6,"Arial",10,0) setFont(TxDv7,"Arial",10,0) setFont(AxDv1,"Arial",10,0) setFont(AxDv2,"Arial",10,0) setFont(AxDv3,"Arial",10,0) setFont(AxDv4,"Arial",10,0) setFont(AxDv5,"Arial",10,0) setFont(AxDv6,"Arial",10,0) setFont(AxDv7,"Arial",10,0) setFont(PrLHd0,"Arial",14,1) setFont(PrHdg1,"Arial",10,1) setFont(PrHdg2,"Arial",10,1) setFont(PrHdg3,"Arial",10,1) setFont(PrHdg4,"Arial",10,1) setFont(Nxbets,"Arial",10,1) setFont(TtlxD,"Arial",10,1) setFont(TtlAx,"Arial",10,1) setFont(betVTx,"Arial",10,1) setFont(betVal,"Arial",10,1) --some global variables sequence axm1, axm2, axm3, axm4, axm5, axm6, axm7, -- temporary number holders to enable packaging and data conversions VxDv1, VxDv2, VxDv3, VxDv4, --holding the calculated numbers VxDv5, VxDv6, VxDv7, txm1, txm2, txm3, txm4, txm5, txm6, txm7, -- number of matches in each category txm, -- match numbers sTxDv1, sTxDv2, sTxDv3, sTxDv4, --holding the combination of text and numbers sTxDv5, sTxDv6, sTxDv7, stbx, Txbets, entry, allentries, holder integer result, junk, numbets function CollectData() --Some how this is not working, I am trying to get the data from the EditText boxes -- I have tried | entry1 = getText(ExDv1) .... entry7 = getText(ExDv7) - the same results entry = getText(ExDv1) & "," & getText(ExDv2) & "," & getText(ExDv3) entry=entry & "," & getText(ExDv4) & "," & getText(ExDv5) & "," entry=entry & getText(ExDv6) & "," & getText(ExDv7) & "," if (length(entry)=7) then junk = message_box("Type pay values in the boxes! \n" & "All boxes must have a value or zero", "Empty entries no allowed!", MB_TASKMODAL + MB_ICONWARNING) setFocus(ExDv1) end if --(next line is this allowed, storing the data in a sequence ... is entry a sequence accessible in that manner? -- if possible, then maybe I should be returning entries without re packaging it? -- in previous attempts where I have used entry1...entry7 it was easy to make these members of a sequence but -- still it did not work allentries = {entry[1],entry[2],entry[3],entry[4],entry[5],entry [6],entry[7]} return allentries end function procedure clear_all() setText(ExDv1,{}) setText(ExDv2,{}) setText(ExDv3,{}) setText(ExDv4,{}) setText(ExDv5,{}) setText(ExDv6,{}) setText(ExDv7,{}) end procedure procedure on_btnClear() clear_all() setFocus(ExDv1) end procedure procedure on_btnCalculate() --what to do when calculating holder = CollectData() axm1 = sprintf("%4.2d", holder[1]) --convert numbers to decimal axm2 = sprintf("%4.2d", holder[2]) --otherwise won't recognise axm3 = sprintf("%4.2d", holder[3]) axm4 = sprintf("%4.2d", holder[4]) axm5 = sprintf("%4.2d", holder[5]) axm6 = sprintf("%4.2d", holder[6]) axm7 = sprintf("%4.2d", holder[7]) VxDv1 = txm1 * axm1 -- the second column of multiplicands is carried over from the calculations VxDv2 = txm2 * axm2 -- carried out in the procedure "procedure onLoad_ProfWin()" below VxDv3 = txm3 * axm3 -- and they work pretty well in that procedure with no hassles VxDv4 = txm4 * axm4 VxDv5 = txm5 * axm5 VxDv6 = txm6 * axm6 VxDv7 = txm7 * axm7 -- Punch the numbers into their boxes setText( AxDv1, VxDv1 ) -- put numbers into the static holders declared at the benning of the program setText( AxDv2, VxDv2 ) -- seems to be working when observed from a "traced" run setText( AxDv3, VxDv3 ) setText( AxDv4, VxDv4 ) setText( AxDv5, VxDv5 ) setText( AxDv6, VxDv6 ) setText( AxDv7, VxDv7 ) setFocus(btnClose) end procedure procedure onMenu_Exit() closeWindow(ProfWin) end procedure procedure onbtn_Close() closeWindow(ProfWin) end procedure procedure onLoad_ProfWin() -- this one works well --what to do when window is opened --Load files and get required numbers and display them atom handle -- file with matches -- lets open file with win sequence handle = open("Payoff.win", "r") if handle != -1 then txm = get(handle) --read first, only line close(handle) end if txm1 = sprintf("%4d", txm[2][1]) --same above txm2 = sprintf("%4d", txm[2][2]) txm3 = sprintf("%4d", txm[2][3]) txm4 = sprintf("%4d", txm[2][4]) txm5 = sprintf("%4d", txm[2][5]) txm6 = sprintf("%4d", txm[2][6]) txm7 = sprintf("%4d", txm[2][7]) stbx = sprintf("%4d", txm[2][8]) sTxDv1 = "Six Numbers : " & " " & txm1 sTxDv2 = "Five Numbers and Bonus: " & " " & txm2 sTxDv3 = "Five Numbers : " & " " & txm3 sTxDv4 = "Four Numbers and Bonus: " & " " & txm4 sTxDv5 = "Four Numbers : " & " " & txm5 sTxDv6 = "Three Numbers and Bonus: " & " " & txm6 sTxDv7 = "Three Numbers : " & " " & txm7 Txbets = "Total numbers of bets were: " & " " & stbx setText( TxDv1, sTxDv1 ) setText( TxDv2, sTxDv2 ) setText( TxDv3, sTxDv3 ) setText( TxDv4, sTxDv4 ) setText( TxDv5, sTxDv5 ) setText( TxDv6, sTxDv6 ) setText( TxDv7, sTxDv7 ) setText(Nxbets, Txbets) end procedure onOpen[ProfWin] = routine_id("onLoad_ProfWin") onClick[MenuExit] = routine_id("onMenu_Exit") onClick[btnClr] = routine_id("on_btnClear") onClick[btnCalc] = routine_id("on_btnCalculate") onClick[btnClose] = routine_id("onMenu_Exit") WinMain(ProfWin,Normal)
2. Re: getText() and setText() program not working
- Posted by Brian Broker <bkb at CNW.COM> Sep 15, 2000
- 485 views
Looks like you are mixing up numbers and text representations of those numbers. I'm working on cleaning things up for you and I'll send you my resulting program. There are many simplifications that can be made so it's taking a little longer than I expected... Later, Brian