Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If...then.. statements

Status
Not open for further replies.

Irishrule812

Instructor
Joined
Aug 28, 2007
Messages
1
Location
US
I know when usinf if..then.. statements you can write messages for the time of day and also for the day fo the week is there a way to do both at the same time?
Ex. Like have it say "At Work" on Monday between 8-14 Then "At Home" between 14-8.
Sometihng like that.
Thank You
 
You can use multiple tests in any "if" statement by using an operator to join them. Common logic operators are and (&&), or (||) and not (!). For example, this:

Code:
if (a == 1 && b == 2) {

would match if a was equal to one [!]and[/!] b was equal to 2, but not if either were not, whereas this:

Code:
if (a == 1 || b == 2) {

would match if [!]either[/!] a was equal to one [!]or[/!] b was equal to 2, regardless of the other.

So, you can simply join your test for the time of day and your test for day of the week together using one of those.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top