Portfolio

UPTIME SCRIPT

Posted in MIRC with 628 views.

A nice cleaned script that calculates the Uptime of your system. It saves your uptime record as well.

This weekend I wanted to see how long my computer is up. So I made this script that does it :) It calculates the record as well. It saves it as a variable within MiRC Varibles when you see the scripting page. It is well documented and I guess there are no bugs...

Feel free to take this code!

CODE:
; **/
; * Shows the uptime
; * 
; * @author Mohamed Mansour
; * @since 5/26/2006
; * @build 1.0
; */
on 1:EXIT:{
	var %current_uptime = $duration($Tools.GetUptimeSystem())
	if ( %current_uptime > %record_uptime ) {
		set %record_uptime %current_uptime
		set %record_uptime_date $ctime
	} 
	else if ( !%record_uptime || !%record_uptime_date ) {
		set %record_uptime %current_uptime
		set %record_uptime_date $ctime
	}
}

; **/
; * Calculates the System Uptime Record
; */
alias Tools.getUptimeRecord {

	;// Check if Variables are defined
	if (%record_uptime && %record_uptime_date ) {
		return $duration(%record_uptime)
	}
	else {
		return $Tools.GetUptimeSystem()
	}

}

; **/
; * Calculates the System Uptime
; */
alias Tools.getUptimeRecordDate {

	;// Initialize the Text Variable
	var %txt

	;// Lets check if the variables are defined
	if (%record_uptime && %record_uptime_date ) {
		%txt = %record_uptime_date
	} 
	else {
		%txt = $ctime
	}

	;// Return nicely formated time
	return $asctime(%txt,dddd mmmm doo yyyy) at $asctime(%txt,hh:nn tt)

}

; **/
; * Calculates the System Uptime
; */
alias Tools.GetUptimeSystem {
	return $uptime(system, 1)
}

; **/
; * Prints the Uptime
; */
alias Tools.Uptime {

	;// Output String
	var %output = UPTIME: Current: 
	%output = $+(%output, $Tools.GetUptimeSystem())
	%output = $+(%output,  Record: $Tools.getUptimeRecord())
	%output = $+(%output, $chr(32) set on $Tools.getUptimeRecordDate())

	;// Message out the buffer
	/MSG $active $1

}

;// ### Menu
menu query,channel {
	-
	Uptime: /Tools.Uptime
	-
}

Download here: uptime.mrc