Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Slim Code - List of Shortcuts?
Message
From
02/07/2010 09:57:23
 
 
To
01/07/2010 11:53:26
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Novell 6.x
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01471199
Message ID:
01471287
Views:
86
In talking with my coworker Justin Roper about trying to develop a reference list of such functions and commands and their limitations, he gave this as a good thing to consider when using the inlist() function:

INLIST() is a great "slim" code function however, you need to know its flaws. For example, you only want Jon *******(login name JON) and Bill *******(login name BILL) to be the only ones to have access to a certain thing in the program. You would probably write it as
IF INLIST(loggeduser,"JON","BILL")
*** ALLOW ***
ENDIF

That will work however, you also gave access to Joni ****(JONI), (JONESY), and (BILLR)
The way around it is to write it the old faction way
IF loggeduser == "JON" .or. loggeduser == 'BILL'
***ALLOW ***
ENDIF

This will only work if you put in the double equals or if the set("exact") is set to ON. Only one equal sign and set exact off will give you the same results as the first example.

You could also do this....

IF INLIST(loggeduser,"JON ","BILL ")
*** ALLOW ***
ENDIF

The spaces after the names prevent the other users return TRUE.


The part about the example
IF test = X .or. test = Y .or. test = Z could be IF INLIST(test,X,Y,Z)
you could also use
test $ "XYZ"
to get the same answer, but it must be a one char field or it will return TRUE whenever a X, Y or Z is found in test.
Previous
Reply
Map
View

Click here to load this message in the networking platform