Experienced a similar thing a while back and decided to use NAP as well. Even went as far as changing the NAP depending on how long the period of inactivity has been.
Sample code: LASTTIME = TIME() FOUND.CMD = @FALSE LOOP UNTIL FOUND.CMD DO ELAPSED = TIME() - LASTTIME GOSUB SET.NAP.TIME IF TIME() - LASTTIME GT QUIT.TIME THEN STOP (or exit or whatever is best for you) INPUTIF TCL.CMD THEN FOUND.CMD = @TRUE ELSE NAP NAPTIME REPEAT *------------ SET.NAP.TIME: *------------ * Minimise looping by NAPing before doing the next INPUTIF check. * Set NAP time as an increasing amount depending on the period of * inactivity BEGIN CASE CASE ELAPSED LT 60 NAPTIME = 100 ; * Up to 1 min, pause for 0.1 seconds CASE ELAPSED LT 300 NAPTIME = 200 ; * Up to 5 mins, pause for 0.2 seconds CASE ELAPSED LT 600 NAPTIME = 500 ; * Up to 10 mins, pause for 0.5 seconds CASE ELAPSED LT 900 NAPTIME = 1000 ; * Up to 15 mins, pause for 1 second CASE 1 NAPTIME = 2000 ; * More than 15 mins, pause for 2 seconds END CASE RETURN Brendon -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of HENDERSON MIKE, MR Sent: Wednesday, 27 October 2010 8:31 AM To: U2 Users List Subject: Re: [U2] INPUTIF statement in Universe {Unclassified} I.E., add the line with "NAP" in it. You may want to try different NAP intervals to work out the best balance between snappy user response and CPU usage. ________________________________________________________ OK = 0 ; START.DT = DATE() ; START.TM = TIME(); TIME.OUT = 900 LOOP INPUTIF PSN THEN OK = @TRUE ELSE NAP 100 ; Doze 100 milliseconds = 1/10 sec OK = ((DATE()-START.DT)*86400)+TIME()-START.TM > TIME.OUT IF OK THEN IF EDIT.FLG THEN PSN = '' ELSE PSN = 'Q' END END UNTIL OK DO REPEAT __________________________________________________________ -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of fft2...@aol.com Sent: Wednesday, 27 October 2010 10:14 a.m. To: u2-users@listserver.u2ug.org Subject: Re: [U2] INPUTIF statement in Universe In a message dated 10/26/2010 11:58:58 AM Pacific Daylight Time, eric.rosenzw...@petco.com writes: > In testing, it's the INPUTIF statement that's utilizing the CPU, not the > timer calculation. > > Is there a better, less CPU intensive way to do this? > > Thanks in advance. >> > INPUTIF checks the type-ahead buffer every time slice. You're getting so many slices that your CPU is consumed with this one task of checking the type-ahead buffer. It's frenetic, a CPU on crystal meth. In the old days, we would say Release Timeslices RQM. Today you can solve that issue as well, by adding a Sleep for a 1 second. On systems that allow sleeping for periods less than a second, you only really need to add a sleep for a tenth of a second, to see your CPU suddenly quiesce. Will Johnson _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users The information contained in this Internet Email message is intended for the addressee only and may contain privileged information, but not necessarily the official views or opinions of the New Zealand Defence Force. If you are not the intended recipient you must not use, disclose, copy or distribute this message or the information in it. If you have received this message in error, please Email or telephone the sender immediately. _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users