Zimmer Posted April 5, 2009 Share Posted April 5, 2009 Here is a python version of sleep just convert to you OS enjoy! Also please comment on errors or features you want. CODE: import time import sys drop=False for i in sys.argv: if i == '-m': t='m' if i == '-min': i='min' if i == '-hour': t='hour' else: try: num=int(i) except: drop=True if t=='hour': num=int(num)*3600 if t=='m': num=int(num)/100 if t=='min': num=int(num) try: time.sleep(int(num)) except: print 'An Unknown Error Ocurred. Press Enter to Exit' raw_input(' ') sys.exit(1) Quote Link to comment Share on other sites More sharing options...
Joerg Posted April 6, 2009 Share Posted April 6, 2009 Is time.sleep(1) on windows the same as time.sleep(1) on linux? Quote Link to comment Share on other sites More sharing options...
Zimmer Posted April 6, 2009 Author Share Posted April 6, 2009 Is time.sleep(1) on windows the same as time.sleep(1) on linux? Basically this is a python script to have a sleep command on windows and mac ox x, both I believe don't have a command except if ping to >nul (clumsy). the time.sleep(1) is python module time and the command sleep sleeping for 1 second. This script excepts -m for milliseconds -s for seconds (defaults to that) -min for minutes and -hour for hours. It then scans the arguments and parses them if there is a problem it quits with 1 as a return value (saying it failed) and saying something went wrong. Quote Link to comment Share on other sites More sharing options...
MuNk Posted April 6, 2009 Share Posted April 6, 2009 C++ Sleep command, made it for my NintendoDS as DevKitARM dont have a sleep command. void sleep(int secs) { int start = time(NULL); while ((time(NULL) - start) < secs) { //DO NOTHING! } } Delphi port procedure sleep(secs:integer); var start:integer; begin start:=time(nil); while (time(nil) - start) < secs) do begin //DO NOTHING! end; end; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.