SunQuest
           Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old October 12th, 2000, 02:58 AM
slacker_x slacker_x is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 1 slacker_x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have been working on a little alarm clock script just to try and introduce myself to perl. I am almost done now, but I am having problems with one part. The program doesn't seem to want to advance through an array of alarm times so that it is set for the correct time. I'll show you the problem causing code here:

sub setAlarmDay {
&updateDate;
($alarm_day_week,$alarm_hour,$alarm_minute) = split /:/, $alarm_times[$array_counter];
if ($day_week == $alarm_day_week) {
&setAlarmHour;
} else {
$array_counter=$array_counter+1;
if ($array_counter > 6) {
$array_counter=0;
}
&setAlarmDay;
}
}

sub setAlarmHour {
if ($hour >= $alarm_hour && $minute >= $alarm_minute) {
$array_counter=$array_counter+1;
($alarm_day_week,$alarm_hour,$alarm_minute) = split /:/, $alarm_times[$array_counter];
&setAlarmDay;
} else {
print "alarm set to: day: $alarm_day_week hour: $alarm_hour minute: $alarm_minuten";
&checkDay;
}
}

sub updateDate {
$date=`/bin/date`;
($day_week,$month,$day,$time,$time_zone,$year) = split / /, $date;
($hour,$minute,$second) = split /:/, $time;
}

@days_week=("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun");
@alarm_times=("Mon:06:30",
"Tue:07:30",
"Wed:08:30",
"Thu:00:12",
"Fri:08:30",
"Sat:11:00",
"Sun:10:00");

I hope that is enough. The script seems to get stuck on Monday because the array_counter is initialized to 0. I would appreciate any suggestions.

Reply With Quote
  #2  
Old October 13th, 2000, 06:13 AM
MeijdenB MeijdenB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: Alkmaar, The Netherlands
Posts: 123 MeijdenB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
I have one question:
Why don't you change this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
if ($array_counter > 6) {
$array_counter=0;
}
[/quote]
by this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
if ($array_counter > 6) {
$array_counter=$array_counter%6;
}
[/quote]

And I have one suggestion.
Try a foreach loop.

------------------
Good luck,
Bas

------------------
E-mail me at: b.vandermeijden@pecoma.nl

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Fairly simple problem.....I hope!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway