As Les says, USE is a command. Commands do not return anything, but they do set the @ERROR macro. Because they do not return anything thay cannot be used in an expression. The IF construct is expecting an expression.
Functions do return a value (and set @ERROR) so can be used in a conditional construct such as IF and WHILE.
In this case you need to write your code as:
Code:
USE X: \\server\share
If @ERROR
"ERROR" ?
Else
"SUCCESS" ?
EndIf
IF takes an expression which must evaluate to true or false. In the case of USE it won't work because USE does not return a value.
For something like WriteValue() which does return a value you can check it in an expression. It will return a zero value when there is no error, or an error code when there is an error.
This means that these two statements are exactly the same:
Code:
If WriteValue(a,b,c)
"ERROR" ?
EndIf
... and ...
If WriteValue(a,b,c) <> 0
"ERROR" ?
EndIf
You can reverse the test using Not, so
Code:
If WriteValue(a,b,c)=0
"SUCCESS" ?
EndIf
... is the same as ...
If Not WriteValue(a,b,c)
"SUCCESS" ?
EndIf