Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Small Basic - Create an alarm


  • Please log in to reply
8 replies to this topic

#1 teatrap

teatrap

  • Members
  • 121 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:31 PM

Posted 23 November 2013 - 01:30 PM

OK, still following a tutorial but the answer provided doesn't work so I'm not sure what the problem is. 
 
Basically I'm trying to create a program that will read the time, and at a certain point change the desktop background and trigger an alarm sound (one of the built in ones, bellring)
 
I couldn't get it working so I thought that Id focus on getting the alarm triggering first (without the desktop change) and then come back to that. 
 
here's the code :
 
 
subSetAlarm()

 
up:
If Clock.Time = alarm Then     
    Sound.PlayBellRing()            
EndIf
Program.Delay(1000)
Goto up
 
Sub subSetAlarm
  TextWindow.WriteLine("Set Alarm")
  TextWindow.Write("Enter Hour: ")
  hour = TextWindow.ReadNumber()
  TextWindow.Write("Enter Minute: ")
  minute = TextWindow.ReadNumber()
  alarm = hour + ":" + minute + ":00 "
  TextWindow.WriteLine("Alarm Time: " + alarm)
EndSub


 
 
 
 
when this is entered I get the following window :
 
4w83dTS.png
 
So I enter the time information, but when the time comes round (6:23 PM) nothing happens. I tried entering 24 hour time and getting rid of the AM PM arguments, but that didn't work either.

As far as I understand the Program.Delay should be refreshing the program within the "up:" label every second. I also tried displaying the current time with the up loop, but it didn't keep refreshing, is this the problem? 
 
 
Maybe there's something obvious, I'm not too sure though. 
 
Thank you for any help.

Operating system_Windows 8.1 Pro with Media Center (9600)
CPU_Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Motherboard_Hewlett-Packard (1966)
RAM_12063mb
Hard Drive_931gb (HGST HTS541010A9E680)
Graphics card_Intel® HD Graphics 4600
Sound card_IDT High Definition Audio CODEC


BC AdBot (Login to Remove)

 


#2 Sirawit

Sirawit

    Bleepin' Brony


  • Malware Response Team
  • 4,163 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Thailand
  • Local time:01:31 AM

Posted 26 November 2013 - 09:23 AM

Hi again.

This is the bug called "invisible space":

alarm = hour + ":" + minute + ":00 "

That space after :00 make you alarm data wrong, that means you cannot check with clock.time becuase it have another space after the time.

 

This is common bug. Careful next time. :)

 

Thank you.


If I don't reply back to you in 2 days, feel free to send me a PM.

 

“You’re lying… just like you were lying to me before. You have to hate me. I’ve been the worst daughter in the world… you should hate me.”

“But I don’t, Nyx. Because, Nyx, I’m your mother, and a mother will always love her daughter, no matter what.” -Past sins by Pen stroke.


#3 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:31 PM

Posted 26 November 2013 - 04:28 PM

To elaborate slightly, a blank space in a string is a valid character, so you are actually trying to match on "00 " instead of "00". And as Sirawit already stated, leaving blanks in the wrong space is a common developer error.



#4 teatrap

teatrap
  • Topic Starter

  • Members
  • 121 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:31 PM

Posted 26 November 2013 - 05:14 PM

Ahh  :rolleyes: classic... excel has strops about the same thing but it usually gives you a warning!

 

Thanks both for the heads up


Operating system_Windows 8.1 Pro with Media Center (9600)
CPU_Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Motherboard_Hewlett-Packard (1966)
RAM_12063mb
Hard Drive_931gb (HGST HTS541010A9E680)
Graphics card_Intel® HD Graphics 4600
Sound card_IDT High Definition Audio CODEC


#5 teatrap

teatrap
  • Topic Starter

  • Members
  • 121 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:31 PM

Posted 30 November 2013 - 10:20 AM

I still can't get this program to run  :blush:

 

the current code is :

subSetAlarm()
imagePath = program.Directory + "C:\Users\George Lenton\Pictures\Owl.png"
 
up:
If Clock.Time = alarm Then  
    Desktop.SetWallPaper(imagePath)   
    Sound.PlayBellRing()            
EndIf
Program.Delay(1000)
Goto up
 
Sub subSetAlarm
  TextWindow.WriteLine("Set Alarm")
  TextWindow.Write("Enter Hour: ")
  hour = TextWindow.Read()
  TextWindow.Write("Enter Minute: ")
  minute = TextWindow.Read()
  
  alarm = hour + ":" + minute
  TextWindow.WriteLine("Alarm Time: " + alarm)
EndSub

I have removed the offending minutes part with the blank text. 

 

I enter in the time and it just sits there, when the time comes round nothing happens and the only thing that I could think of is that it's not updating the time or something? But If i enter it for the current time it doesn't work either, so I'm not sure whether that's it or not. 


Operating system_Windows 8.1 Pro with Media Center (9600)
CPU_Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Motherboard_Hewlett-Packard (1966)
RAM_12063mb
Hard Drive_931gb (HGST HTS541010A9E680)
Graphics card_Intel® HD Graphics 4600
Sound card_IDT High Definition Audio CODEC


#6 Sirawit

Sirawit

    Bleepin' Brony


  • Malware Response Team
  • 4,163 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Thailand
  • Local time:01:31 AM

Posted 30 November 2013 - 10:22 AM

Replace alarm line with this:

alarm = hour + ":" + minute + ":00"

Thank you.


If I don't reply back to you in 2 days, feel free to send me a PM.

 

“You’re lying… just like you were lying to me before. You have to hate me. I’ve been the worst daughter in the world… you should hate me.”

“But I don’t, Nyx. Because, Nyx, I’m your mother, and a mother will always love her daughter, no matter what.” -Past sins by Pen stroke.


#7 teatrap

teatrap
  • Topic Starter

  • Members
  • 121 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:31 PM

Posted 30 November 2013 - 10:47 AM

Ahhh the times didn't match because it was missing the seconds.... Thank you. It's the little assumptions that make the mistakes! 


Operating system_Windows 8.1 Pro with Media Center (9600)
CPU_Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Motherboard_Hewlett-Packard (1966)
RAM_12063mb
Hard Drive_931gb (HGST HTS541010A9E680)
Graphics card_Intel® HD Graphics 4600
Sound card_IDT High Definition Audio CODEC


#8 Sirawit

Sirawit

    Bleepin' Brony


  • Malware Response Team
  • 4,163 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Thailand
  • Local time:01:31 AM

Posted 30 November 2013 - 10:48 AM

You're welcome! Hope you can understand a lot about Small Basic! :) :thumbsup:

 

Thank you.


If I don't reply back to you in 2 days, feel free to send me a PM.

 

“You’re lying… just like you were lying to me before. You have to hate me. I’ve been the worst daughter in the world… you should hate me.”

“But I don’t, Nyx. Because, Nyx, I’m your mother, and a mother will always love her daughter, no matter what.” -Past sins by Pen stroke.


#9 teatrap

teatrap
  • Topic Starter

  • Members
  • 121 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:31 PM

Posted 30 November 2013 - 10:51 AM

Things like this error seem very silly (even to me looking at it now!) but because it's a bit of a different way of thinking I sometimes don't realise the (obvious) error I've made. 

 

But I'm enjoying it, thanks for your help  :thumbup2:


Operating system_Windows 8.1 Pro with Media Center (9600)
CPU_Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Motherboard_Hewlett-Packard (1966)
RAM_12063mb
Hard Drive_931gb (HGST HTS541010A9E680)
Graphics card_Intel® HD Graphics 4600
Sound card_IDT High Definition Audio CODEC





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users