!This file is part of VEL_demo, copyright David Keyes, 2007. ! !This source file is free software: you can redistribute it and/or modify !it under the terms of the GNU General Public License as published by !the Free Software Foundation, either version 3 of the License, or !(at your option) any later version. ! !This code is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !For terms of the GNU General Public license see . MACRO MODULE dec_impdemo(); INT main_id, quit_but, calc_but, edit_id, info_but, info_but2, event_id; INT res_id, res_res; STRING input*132, output*132; FLOAT rtn_flt; FLOAT d_inch; INT feet; INT inches; INT den; INT num; BEGINMODULE ! first put the buttons in ! main_id:=cre_win(vec(20,20),350,300,"Decimal to Imperial Demo"); info_but:=cre_button(main_id,vec(10,20),330,20,0,"Decimal to feet & inches",""); info_but2:=cre_button(main_id,vec(10,50),330,20,0,"For example 78.375 becomes 6'-6 3/8",""); edit_id:=cre_edit(main_id, vec(10,90), 250, 25, 1, "78.375", 48); res_id:=cre_button(main_id,vec(10,170),80,25,0,"Result",""); res_res:=cre_button(main_id,vec(100,170),180,25,0," ",""); quit_but:=cre_button(main_id,vec(290,260),50,25,2,"QUIT","QUIT"); calc_but:=cre_button(main_id,vec(10,260),80,25,2,"EVAL","EVAL"); ! show the window! show_win(main_id); loop: event_id:=wait_win(main_id); if event_id = calc_but then input:=get_edit(main_id, edit_id); d_inch:=fval(input); part(#1, dec_imp(d_inch ,feet, inches, den, num)); output:=str(feet,1,0) + "'-" + str(inches,1,0) + " " + str(num,1,0) + "/" + str(den,1,0); del_win(main_id, res_res); res_res:=cre_button(main_id,vec(100,170),180,25,0,output,""); goto loop; elif event_id = quit_but then del_win(main_id); exit(); else goto loop; endif; ENDMODULE