I would like to “clean” up some of my code by using the NOT statement. The code I want to use is: IF NOT USERID then (CODE) But I recieve and error message telling me “This Prefix operator cannot be used on text”. I assume that I am using the NOT statement in the wrong context, so is there something like this that I can do ?
You would normally use not on logic operators so in you case IF NOT(USERID=’’) THEN CODE
You can only use the NOT statement on boolean values. Eg.
IF NOT User.GET(UserID) THEN
CLEAR(User)
or when evaluating a statement to boolean datatype. A lot of the C/Side function/call provide you with a return value like the GET. Soren Nielsen, moderator Integration/Developer NOLUG
You can not do this. The “most clean” solution would be:
IF USERID = '' THEN
(code);
But otherwise, then I agree with you. So much more could be archived this way, and not many developers are using it. In example I’ve seen code like this many times:
Found := FIND('-');
IF Found = FALSE THEN
The “clean” solution would be:
IF NOT FIND('-') THEN
Best regards, Erik P. Ernst, webmaster Navision Online User Group
Maybe I need to expand a little on my last post. What I need to do is: The user (Whoever that may be) logs into Navision, and if the user does not exist in a particular table, then I do not want the code to execute. But, if the user does exist in this table, then I want the code to execute. This is why I tried to use the NOT statement, hoping that it would not execute if the user was not found. Any Suggestions ?
Simple:
SomeTable.SETRANGE(UserID, USERID);
IF SomeTable.FIND('-') THEN BEGIN
..
my code if user exists
..
END ELSE BEGIN
..
my code if user does not exist
..
END;
Soren Nielsen, moderator Integration/Developer NOLUG
If the tables primary key is the USERID then you can also use this: IF SomeTable.GET(USERID) THEN BEGIN … my code if user exists … END ELSE BEGIN … my code if user does not exist … END; Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117