Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why does this code erase all locations?
Message
From
07/12/2006 07:04:51
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
06/12/2006 17:12:34
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01175423
Message ID:
01175538
Views:
8
>Why does this code erase all the locations when it should only remove those not in the scan line of code?
>
>Scan For Alltrim(crimetype) <> "B&E Cabin" OR  Alltrim(crimetype) <> "B&E Home" ;
OR Alltrim(crimetype) <> "B&E Business" OR  Alltrim(crimetype) <> "B&E Garage"
>	ShapeID = localcrime1.shapename
>	Thisform.RemoveObject(ShapeID)
>Endscan
>
Grady,
That expression would always return .t..
c = "hello"
if m.c <> 'hello' or m.c <> 'there' && .F. or .T. result .T.
if m.c <> 'there' or m.c <> 'hello' && .T. or .F. result .T., shortcuts in first .T.
I think you meant AND instead.
While you can fix it by replacing ORs with ANDs, or surrounding all of them with parentheses and having NOT. ie:
c = "hello"
if !(m.c <> 'hello' or m.c <> 'there') && !(.F. or .T.) result .F.
if !(m.c <> 'there' or m.c <> 'hello') && !(.T. or .F.) result .F., shortcuts in first .T.
it gets more and more ugly as your checklist have more elements. One way is to use inlist(), however that too is limited (25 according to documentation). Also there would be casing issue with that. Another approach would be using ascan(). ie:
ALINES(aExclude,"B&E Cabin,B&E Home,B&E Business,B&E Garage",1,',')
scan for ascan(aExclude,alltrim(crimetype),1,-1,1,7)=0
*...
endscan
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform