Turn Old Post backup
Transferred from: http://www.cnblogs.com/whiteyun/archive/2009/08/10/1542913.html
Os.clock ()
Function: Returns an approximate value of the CPU time used by a program
For example:
Local x =os.clock ();
Print (Os.clock ())
Local s = 0;
For I =1, 100000000 do
s = s + i;
End
Print (String.Format ("ElapsedTime:%.2f\n", Os.clock ()-X));
Output:
0
Elapsed time:2.55
--------------------------------------------------------------------------------
os.date ([format [, TIME])
function: Returns a string or table that formats the date, times, or tables by format
If you set the timing parameter, Is formatted as time specifies, otherwise the
parameter is formatted as the current time:
format:
"!": Format by GMT.
"*t": will return a band year (4-bit), month (1-12), Day (1--31), hour (0-23), Min (0-59), SEC (0-61), wday (Days of the week, Sunday is 1), Yday (years Days), and ISDST (whether it is daylight saving time True/false) The table with the key name, and if no "*t" returns a string formatted with the Strftime function of C
Returns the formatted string as set by the current system if no parameters are present Os.date () <=>os.date ("%c")
For example:
t = Os.date ("*t", Os.time ());
for I, Vin pairs (t) do
print (i, v);
end
Output:
Hour 14
Min 58
Wday 2
Day 10
Month 8
Year 2009
SEC 18
Yday 222
ISDST false
For other format strings, os.date formats the date as a string
For example:
Print (Os.date ("Todayis%A, In%b"))-->today is Tuesday
Print (Os.date ("%x", 906000490))-->09/16/1998
All of the formatted strings are as follows:
%a abbreviation for days of the week (Wed)
%A full name of days of the week (Wednesday)
Abbreviation for%b month (SEP)
Full name of the%B month (September)
%c Date and Time (09/16/9823:48:10)
%d days of the one months (16) [0~ 31]
%H hours in the 24-hour system (23) [00~ 23]
%I Hours in 12-hour system (11) [01~ 12]
%j Day of the Year (259) [01~ 366]
%M minutes (48) [00~ 59]
%m months (09) [01~12]
%P "AM" or "PM" (PM)
%s seconds (10) [00 ~ 59]
%w Day of the Week (3) [0 ~ 6 = Sunday ~ Saturday]
%W Week of the year 0 ~52
%x Date (09/16/98)
%x time (23:48:10)
%y two-digit year [00~]
%y Full Year (2009)
%% string '% '
--------------------------------------------------------------------------------
Os.difftime (T2,T1)
Function: Returns the number of seconds T1 to T2
For example:
T1 =os.time ();
For I =0, 10000000 do
Os.time ();
End
T2 =os.time ();
Print (Os.difftime (T2,T1));
Output:
2
--------------------------------------------------------------------------------
Os.execute ([command])
Function: The system function equivalent to C, return the status code
For example:
Os.execute ("Pause")
Output:
Press any key to continue ...
--------------------------------------------------------------------------------
Os.exit ([code])
Function: equivalent to the Exit function of C, terminate the main program, code is the return value
For example:
Os.exit (1)
--------------------------------------------------------------------------------
Os.getenv (varname)-
Function: Returns the value of the environment variable varname of the current process and returns nil if the variable is not defined
For example:
Print (Os.getenv ("UserDomain"))
Print (Os.getenv ("SystemRoot"))
Print (Os.getenv ("Os2LibPath"))
Print (Os.getenv ("ProgramFiles"))
Print (Os.getenv ("APPDATA"))
Print (Os.getenv ("AllUsersProfile"))
Print (Os.getenv ("CommonProgramFiles"))
Print (Os.getenv ("COMPUTERNAME"))
Print (Os.getenv ("USERNAME"))
Print (Os.getenv ("UserProfile"))
Print (Os.getenv ("ComSpec"))
Print (Os.getenv ("LogonServer"))
print (Os.getenv ("Number_of_processors"))
print (os.getenv ("OS"))
print (Os.getenv ("Pathext")
print (Os.getenv ("Processor_architecture"))
print (os.getenv ("Processor_identifier"))
print ( Os.getenv ("Processor_level"))
print (Os.getenv (" Processor_revision "))
print (Os.getenv (" UserDomain "))
print (Os.getenv ("SystemRoot")
print (os.getenv ("TEMP"))
Output:
Rdev
C:\WINDOWS
Nil
C:\Program Files
C:\Documents and Settings\baiyun\applicationdata
C:\Documents and Settings\All Users
C:\Program Files\Common Files
Baiyun
Baiyun
C:\Documents and Settings\baiyun
C:\WINDOWS\system32\cmd.exe
http://www.cnblogs.com/whiteyun/admin/file://rdev1/
2
Windows_NT
. COM;. EXE;. BAT;. CMD;. VBS;. VBE;. JS;. JSE;. WSF;. WSH;. py;. Pyw;. Wlua
x86
x86 Family Model 6 stepping 5, Genuineintel
15
0605
Rdev
C:\WINDOWS
C:\docume~1\baiyun\locals~1\temp
--------------------------------------------------------------------------------
Os.remove (filename)
Function: Delete file or an empty directory, add nil plus error message if function call fails
--------------------------------------------------------------------------------
Os.rename (Oldname,newname)
Function: Change a file or directory name and add nil plus error message if the function call fails
--------------------------------------------------------------------------------
Os.setlocale (locale [, category])
Function: Sets the current setting of the program, the function returns the most recent value, and the failure returns nil
Parameters:
Locale: A string that specifies the current setting
"": An empty string, the current setting is treated as a local setting
' C ': current setting is treated as standard C setting
Nil: Returns the current value of the category indicating the setting name
Category: A name that describes the settings you want to change
"All" [default], "collate", "CType", "monetary", "numeric", "Time"
--------------------------------------------------------------------------------
Os.time ([table])
Function: Returns a time value (number) by the contents of the table and returns the current time without parameters
Fields for table:
Year, month, day, Hour, Min, sec,isdst
For example:
Print (Os.time ());
-->1249887340
Print (Os.time ({year=1970,month=1, Day=1, hour=0}));
-->10500
--------------------------------------------------------------------------------
Os.tmpname ()
Function: Returns a temporary file name
"Go" Lua OS Library