Re: wxEuphoria Problems
- Posted by Richard Egdahl <robotdestiny at hotmail.com> Nov 02, 2006
- 534 views
Matt, Basically, what I am trying to write is a credit timer for a coin op internet terminal. I want the user to be able to use a browser(where the focus will be) till the time is up, then it will disable the browser or cover the screen with the euphoria app or flash animation. I figured I would hardwire one of rarely used keys to the switch that accepts the quarter but disable it in the keyboard- if I have to, I will run the switch to the parallel port. The background color change is meant to get the user's attention that their time is ending. I have no problem with the logic portion of the coding- it is the syntax and capabities that get me. This is the code I have thus far:
without warning include wxEuphoria.e include wxGraphics.e include wxText.e include wxTimer.e atom sec atom reset sequence clock atom key atom quarter sec=300 reset=0 clock = "5:00" key=50 quarter=0 constant MyFrame = create( wxFrame, {0, -1, "Timer", 500,100, 125, 50,wxSTAY_ON_TOP}), MyPanel = create( wxPanel, {MyFrame,-1,0,0,125,50}), TextLabel = create(wxStaticText,{MyPanel,-1,"before the fact",10,10}), OtherTextLabel = create(wxStaticText,{MyPanel,-1,"Please Insert a Quarter",10,30}), Timer = create(wxTimer,{MyFrame,-1}), red = create( wxColour, {"Red"}) procedure onPaint_MyPanel( atom this, atom event, atom it, atom event_type ) set_label(TextLabel,"after the fact") wx_puts( this, " ") end procedure procedure drawclock() clock=sprint(floor(sec/60))&":" if sec-(floor(sec/60)*60)<10 then clock=clock&"0" end if clock=clock&sprint(sec-(floor(sec/60)*60)) if key=126 then sec=sec+150 key=0 end if if sec=0 and reset=0 then reset=1 system("calc.exe",2) end if set_label(TextLabel,clock) if quarter>0 then quarter=quarter-1 end if if quarter=0 then set_label(OtherTextLabel,"Please Insert a Quarter") end if end procedure procedure on_timer( atom this, atom event, atom it ,atom event_type ) if sec>0 then sec=sec-1 end if drawclock() if sec<60 then set_back_color( MyPanel, red ) end if end procedure procedure key_event( atom this, atom event_type, atom id, atom event ) key = get_key_code(event) if key=126 then set_label(OtherTextLabel,"Quarter Accepted!") quarter=3 drawclock() end if end procedure set_event_handler( MyPanel, get_id(MyPanel), wxEVT_PAINT, routine_id( "onPaint_MyPanel" )) set_event_handler( MyFrame, -1, wxEVT_TIMER, routine_id("on_timer")) set_event_handler( MyPanel, get_id(MyPanel), wxEVT_KEY_DOWN , routine_id("key_event")) start_timer( Timer, 1000, 0 ) wxMain( MyFrame )