Asked — Edited

2 Scripts, Say Time, Say Date Not Working

I found these two scripts in the online section of ez robot script examples. Neither of them are working, not sure why.. Could someone please take a look? This is say time........

if ($hour>12) $hour_word=($hour-12) ELSE $hour_word=$hour endif

if ($hour_word=0) $hour_word=12 endif

if ($Minute = 0) $thetime = $hour_word ELSEif ($minute = 1) $thetime = "one minute past" + $hour_word ELSEif ($minute = 15) $thetime = "quarter past" + $hour_word ELSEif ($minute = 30) $thetime = "half past " + $hour_word ELSEif ($minute 30) $hour_word=$hour_word+1 $minute_word = 60-$minute $thetime = $minute_word + " minutes to " + $hour_word ELSE $thetime = $hour_word + $minute endif

if ($hour 21) $thetime = $thetime + " at night" ELSEif ($hour > 17) $thetime = $thetime+ " in the evening" ELSEif ($hour > 11) $thetime = $thetime + " in the afternoon" endif

$phrase=("The time is " +$thetime) ControlCommand("Script Manager", ScriptStart, "Speak phrase")

Sorry not sure how to format this code for the forum. Chris


ARC Pro

Upgrade to ARC Pro

Unleash your robot's full potential with the cutting-edge features and intuitive programming offered by Synthiam ARC Pro.

PRO
Synthiam
#1  

Where did you find this? This isn't from an ezrobot example project. What are you wanting to do? It will make more sense to help if you could share what you're expected result is.

PRO
Synthiam
#2  

I cleaned the code to create this... is this what you wanted to happen?


if ($hour > 12)
  $hour_word= $hour - 12
ELSE
  $hour_word=$hour
endif

if ($hour_word=0)
  $hour_word=12
endif

if ($Minute = 0)
  $thetime = $hour_word
ELSEif ($minute = 1)
  $thetime = "one minute past" + $hour_word
ELSEif ($minute = 15)
  $thetime = "quarter past" + $hour_word
ELSEif ($minute = 30)
  $thetime = "half past " + $hour_word
ELSEif ($minute = 30)
  $hour_word=$hour_word+1
  $minute_word = 60-$minute
  $thetime = $minute_word + " minutes to " + $hour_word
ELSE
  $thetime = $hour_word + $minute
endif

if ($hour = 21)
  $thetime = $thetime + " at night"
ELSEif ($hour > 17)
  $thetime = $thetime+ " in the evening"
ELSEif ($hour > 11)
  $thetime = $thetime + " in the afternoon"
endif

$phrase=("The time is " +$thetime)

# speak through the pc speaker
say($phrase)

# speak through the ezb speaker
sayezb($phrase)

#3  

Thanks for replying. The expected result is for the robot to tell the time thru the ezb when asked. Thanks

Germany
#4  

Hui, this script is very hard. In germany we have 1-24°clock. I have try this but EZB say "The time is 31". Do you have a script for europeans? :)

#5  

The first 2 if sections are converting it to a 12 hour clock. Just delete them and it will work on a 24 hour clock.

Alan

Germany
#6  

Oh i have found my old post here. With Blockly you can create your time really easy.

User-inserted image

Oh its in german. Translating here ;-) Es ist = It is Stunden und = houers and Minuten = minutes

I have tested this script and disabled the blocks for PC.

PRO
Synthiam
#7  

Glad that you're enjoying blockly:D