Page 1 of 1 1
Topic Options
#52386 - 2000-11-27 05:58 PM Determining Site.
Roger Offline
Fresh Scripter

Registered: 2000-11-27
Posts: 26
Loc: Urbandale, IA USA
Ok, what the heck am I doing wrong here? This script is supposed to look at the 3rd Octet of the IP address and set a variable to indicate the users site. Right now it wants to set $L to Downtown Des Moines every time. It's like it skips the first line after the Select statement.

$ipad = val(LTRIM(SUBSTR(@IPADDRESS0,9,3)))

? "$ipad"

Select
Case "$ipad" = "45" or "46" or "48" or "49" or "50" or "51" or "52" or "53"
$L = "Downtown Des Moines"
Case "$ipad" = "11" or "12"
$L = "Lincoln Regional Office"
Case "$ipad" = "16"
$L = "Battlecreek Regional Office"
Case "$ipad" = "17"
$L = "Portland Regional Office"
Case "$ipad" = "18" and $site = "sea"
$L = "Seattle Regional Office"
Case "$ipad" = "18" and $site = "pho"
$L = "Phoenix Regional Office"
Case "$ipad" = "20"
$L = "Camarillo Regional Office"
Case "$ipad" = "22"
$L = "Salt Lake City Regional Office"
Case "$ipad" = "23"
$L = "Minneapolis Regional Office"
Case "$ipad" = "24"
$L = "Lincoln Processing Center"
Case "$ipad" = "27"
$L = "Santa Rosa Regional Office"
Case "$ipad" = "28"
$L = "Denver Regional Office"
Case "$ipad" = "54" or "55" or "56" or "62"
$L = "Portland"
Case "$ipad" = "32"
$L = "San Diego Regional Office"
Case "$ipad" = "35"
$L = "Freeport Regional Office"
Case "$ipad" = "43"
$L = "Dial In User"
Case "$ipad" = "62"
$L = "VPN Connected User"

EndSelect


? "$L"
? "$ipad"


Any thoughts would be appreciated.

Roger

Top
#52387 - 2000-11-27 06:13 PM Re: Determining Site.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Roger:

Sorry to say - that you have to say ...

Case "$ipad" = "45" or "$ipad" = "46" or "$ipad" = "48" etc,etc...

What I would do is take off the double-quotes and do a numeric test like this ...

Case $ipad > 44 and $ipad < 54

Shawn.


Ahhh - that screws up #47 though - anyway - you get the idea.

[This message has been edited by Shawn (edited 27 November 2000).]

Top
#52388 - 2000-11-27 06:50 PM Re: Determining Site.
Roger Offline
Fresh Scripter

Registered: 2000-11-27
Posts: 26
Loc: Urbandale, IA USA
Thanks Shawn. I'll try that. I'm curious, why does it set the variable to the first $L defined doing it the way I had it?

Roger

Top
#52389 - 2000-11-27 07:08 PM Re: Determining Site.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Your case statment was wrong...

Case "$ipad" = "45" or "46" or "48" or "49" or "50" or "51" or "52" or "53"

for some reason is always true.....

Bryce

Top
#52390 - 2000-11-27 07:12 PM Re: Determining Site.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Roger:

Well - it kinda goes like this ...

You want to check conditions (expressions) for true or false ...

case "condition" or "condition" or "condition"

or one can read it like this...

if "condition" or "condition" or "condition"

Using "IF" statements instead - the first condition is perfectly valid ...

if "$ipad" = "45"

then you have your "OR", then kix reads the second part of your expression like this ...

if "46"

and the third, like this ...

if "48"

These last two pieces of the case statement will always evaluate TRUE - and because of the "OR" - the entire case expression will always evaluate TRUE.

Did that make sense - because if it did - will you explain it to me ?

Shawn.

One last thing - you may wonder why "45" is always TRUE - well any non-empty string is interpreted as TRUE - "" is FALSE.


[This message has been edited by Shawn (edited 27 November 2000).]

Top
#52391 - 2000-11-27 07:23 PM Re: Determining Site.
Roger Offline
Fresh Scripter

Registered: 2000-11-27
Posts: 26
Loc: Urbandale, IA USA
Gotcha!

It works now. I think I'll just trust the fact that is the way it is, and needs to be.

Why ask why?

Drink Bud dry!!!

Roger

Top
#52392 - 2000-11-27 07:38 PM Re: Determining Site.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well drinking Bud Dry is par for the course right now because I've been drinking alot of beer and doing alot of noggin bashing of late.

But make mine a Molson Canadian or a Labatts Blue will yeah? You know what they say about "that American beer" !

Shawn.

[I wonder if American beer bottles are softer than Canadian ones - hmmmmm....]

[This message has been edited by Shawn (edited 27 November 2000).]

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2358 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.433 seconds in which 0.367 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org