Re: Help,Help,Help and Hello again
- Posted by Irv Mullins <irv at ELLIJAY.COM> Sep 22, 2000
- 388 views
On Fri, 22 Sep 2000, David Mosley wrote: > Hi > First my name is David Mosley for anyone that does not know me I was on the > list awhile back and I am a beginner Programmer I have programmed in > basic(Liberty Basic,jiffy Basic,GW Basic) the jiffy basic was the basic on > the C-64.Well I have started to get Euphoria after about 2 year's of > studying,but still have problems with it I don't understand it I can make a > Basic program (I have written about 50 or so) but when it comes to Euphoria > to get lost on the RDS page it says that Euphoria is SIMPLE for > who??????????????. No offense intended, but it seems that BASIC experience is a hindrance to learning Euphoria. If you can put that experience aside for a while, you'll find Euphoria easier. >did anyone write a book > on Euphoria I would buy it in a minte as long it was for the BEGINNER > programer,is there a Web site out there for the Beginner????????. I don't know of a book (yet) > Well I have a ? about some thing here it goes when you print to a file I use > 1(print) 2 (puts) I have tried both and find that print does ok but when I > try to read back the file I get this {56,57,45,32,} and when I use puts I > get {oct,and then some strange characters} attached is a program that I am > working on it is good for the beginners I use the puts allot and the print > too.Thanks for the help You can use the combination of print() and get() to write and read data very easily, if you structure that data correctly. I would restructure the program in order to save myself a lot of typing and debugging opportunities. When you reference many "loose" variables, there's always a chance of missing some whenever you make a minor change to your program, plus it's much more convenient to read or write an entire batch of related data with one command, instead of with dozens of lines. Your menu code was just fine, as was your use of Gabriel Boehms' PRINT.E. Try using your menu to call the routines below: Regards, Irv -- Budget include get.e include print.e constant MONTH = 1, INCOME = 2, EXP = 3, NAME = 1, AMOUNT = 2 object budget budget = {" ", -- month 0, -- income {{"T-Rent: ",0}, -- expenses {"S-Rent: ",0}, {"Electric: ",0}, {"Phome: ",0}, {"Gas: ",0}, {"Misc 1: ",0}, {"Misc 2: ",0}, {"Misc 3: ",0}, {"Pawn: ",0}}} procedure get_amounts() clear_screen() budget[MONTH] = prompt_string("Month: ") budget[INCOME] = prompt_number("Income: ",{0,4000}) for i = 1 to length(budget[EXP]) do budget[EXP][i][AMOUNT] = prompt_number(budget[EXP][i][NAME],{}) end for end procedure procedure show_total() atom total_exp clear_screen() total_exp = 0 printf(1,"Balance for month of %s\n",{budget[MONTH]}) printf(1,"Total income: %8.2f\n",budget[INCOME]) printf(1,"Itemized expenses:\n",{}) for i = 1 to length(budget[EXP]) do printf(1,"%14s =%8.2f\n",{budget[EXP][i][NAME],budget[EXP][i][AMOUNT]}) total_exp += budget[EXP][i][AMOUNT] end for printf(1,"Total expenses: %8.2f\n",total_exp) printf(1," ________\n",{}) printf(1,"Balance: %8.2f\n",budget[INCOME]-total_exp) end procedure function save_data() atom fn sequence fname fname = prompt_string("Enter filename: ") fn = open(fname,"w") if fn < 1 then return fn else print(fn,budget) close(fn) return 1 end if end function procedure new() get_amounts() show_total() if save_data() then puts(1,"DATA SAVED") else puts(1,"ERROR SAVING DATA FILE") end if end procedure procedure load_data() atom fn sequence fname fname = prompt_string("Filename to load: ") fn = open(fname,"r") if fn < 1 then puts(1,"CANNOT OPEN FILE") abort(1) else budget = get(fn) budget = budget[2] close(fn) end if end procedure