Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why does this code erase all locations?
Message
De
07/12/2006 07:04:51
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
06/12/2006 17:12:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01175423
Message ID:
01175538
Vues:
9
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform