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.

expected integer but got "08" (looks like invalid

Help for those learning Tcl or writing their own scripts.
Post Reply
h
hmetall
Voice
Posts: 3
Joined: Thu May 07, 2009 11:01 am
Contact:

expected integer but got "08" (looks like invalid

Post by hmetall »

Good morning to All.

He/she/you would like to know how to solve this problem:
expected integer but got " 08 " (looks like invalid octal number)

This is a script that calculates time hour of the last command
given in the channel.
Plus when it arrives some mainly schedule 08, 09 him of the
this mistake expected integer but got " 08 " (looks like invalid octal number)

Part of the Code is this:

Code: Select all


set horaam "00"
set minam "00"
set segam "00"
set am "$horaam:$minam:$segam"
set horasave "00"
set minsave "00"
set segsave "00"
set saves "$horasave:$minsave:$segsave"

proc salvar {nick uhost hand chan rest} {
  global topico
  global shard
  global news
  global am
  global saves
  global horasave
  global minsave
  global segsave
  global statTS
  global statMAP

  set horaant "$horasave"
  set minant "$minsave"
  set segant "$segsave"
  set horasave "[strftime %H]"
  set minsave "[strftime %M]"
  set segsave "[strftime %S]"
  set saves "$horasave:$minsave:$segsave"

  set math "((($horasave * 60) * 60) + ($minsave * 60) + $segsave ) -  ((($horaant * 60) * 60) + ($minant * 60) + $segant)"

  set amaux [expr $math]

  if {$amaux < 0} {
    set math "((($horasave * 60) * 60) + ($minsave * 60) + $segsave ) + (84600 - ((($horaant * 60) * 60) + ($minant * 60) + $segant))"
    set amaux [expr $math]
  }
  set math "(($amaux / 60) / 60)"
  set horaant [expr $math]

  set math "$amaux - (($horaant * 60) * 60)"
  set amaux [expr $math]

  set math "$amaux / 60"
  set minant [expr $math]

  set math "$amaux - ($minant * 60)"
  set segant [expr $math]

  set mensagem "^C7,1Já se passaram^C9,1 $horaant ^C7,1hora(s)^C9,1 $minant ^C7,1minutos e^C9,1 $segant ^C7,1segundos desde o último save!"

#  putchan $chan $mensagem
  puthelp "PRIVMSG $chan :$mensagem"

  putserv "TOPIC $chan :^B^_^C4,1\[^_^B^C4,1^BE^B^C0,1mpires ^C4,1^BB^B^C0,1lasters^B^_^C4,1\]^_^B ^B^_\[^_^B^C7,1Shard:^C9,1 $shard ^C4,1^B^_\]^_^B ^B^_\[^_^B^C7,1TS:^C9,1 $statTS ^C4,1^B^_\]^_^B ^B^_\[^_^B^C7,1MAP:^C9,1 $statMAP ^C4,1^B^_\]^_^B ^B^_\[^_^B^C8,1 $topico ^C4,1^B^_\]^_^B ^B^_\[^_^B^C7,1AM:^C9,1 $am ^C4,1^B^_\]^_^B ^B^_\[^_^B^C7,1Save:^C9,1 $saves ^C4,1^B^_\]^_^B ^B^_\[^_^B^C7,1News:^C11,1 $news ^C4,1^B^_\]^O"
  putlog "\002\[Mv\]\002 <<$nick>> !$hand! topic $rest"

return 1
}
then when I execute the command for instance the:
08:10:00 or 09:00:00 if he/she has 09 08 in any to call
he doesn't print, more he/she makes him/it I calculate everything it carries the variable
more in the hour of printing of giving the topic and the putserv he/she doesn't do
anything. and of the the mistake in the bot
expected integer but got " 08 " (looks like invalid octal number)

If somebody can me to help I am I thank.
At once I Thank.

He/she/you excuses English I used a translator.

Thank you.
Sou Brasileiro.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The problem is that you are using %H, %M and %S when retrieving the hour, minute, and second. These will always output 2 digits, 0-padding if needed.
At the same time, any number starting with 0 is considered being an octal number (base 8 contrary to base 10 in the decimal number system). Being base 8, "octals" 08 and 09 are considered invalid.

That said, seems to me you are simply calculating time differences in seconds, so why don't you just use unixtime timestamps all together instead? Saves you a lot of maths...

I'm having slight issues following your maths, but I believe what you're trying to do is pretty much this:

Code: Select all

set timestamp [clock seconds]

proc salvar {nick host handle channel rest} {
 global topico shard news am statTS statMAP timestamp
 set diff [expr {([clock seconds] - $timestamp) % 84600}]
 set timestamp [clock seconds]
 putserv "TOPIC $channel :... Save: [clock format $diff -format "%H"] ..." 
}
NML_375
Post Reply