This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Subtract seconds (math) [Help]

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Subtract seconds (math) [Help]

Post by juanamores »

In the file "djhora" I have stored the time value "count4d" .
What I want is to recover this value and subtract it to the current time .
If the result is equal to 180 seconds then execute a command.

Code: Select all

.....more commands.....
if {![file exists djhora]} { 	
	set count4d [clock seconds] 
	    	
	set temp [open "djhora" w+]
    puts $temp "$count4d"
	close $temp
	}

set temp [open "djhora" r]
set djh [gets $temp]
close $temp

	if {[expr {[clock seconds] - $djh}] == 180} { do more commands..... }
What is wrong ?
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: Subtract seconds (math) [Help]

Post by willyw »

Are you sure you want to use == ?

Whatever you are doing, won't it be difficult to hit it exactly on 180 seconds?

Perhaps you want >= or <= ?
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Re: Subtract seconds (math) [Help]

Post by juanamores »

Thanks willyw, work fine! :D
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply