Data Access Worldwide Knowledge Base

Article ID 2137
Article Title PROBLEM: Variable name causes compiler error
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2137
KBase Category DATAFLEX (GENERAL)
Date Created 07/06/2005
Last Edit Date 07/22/2005


Article Text
PROBLEM:
The following code generates a compiler error in both Windows as character mode DataFlex.

Use UI // Replace this with WINDOWS if compiling under windows
class jim is an array
function fred returns integer
    local integer RetVal U
    function_return RetVal
end_function
end_class

The compiler error is "ERROR: 4345 Type check error |SI1, INTEGER NOT ALLOWED ON LINE: 9 (6049) OF FILE: C:\Develop\Wintest\compilererror.src".

ANSWER/EXPLANATION:
The compiler error is given on the following internal (in the command) test.
#CHECK !1 U
The !1 is replaced with the ICODE notation of the variable named RETVAL (in this case |SI1) and the U is replaced with the ICODE notation of the variable named U. The U however is supposed to have a special meaning and checks whether RETVAL is defined or not. The compiler would - and should - give an error if RETVAL was used while not defined.

SOLUTION:
Do not use reserved words for variables. The use of one character variable names - as in this example - will make the hit chance bigger. Data Access also advises to use hungarian notation on variable names, objects and so on.

Using a reserved word like a command for creating a variable leads to a similar error situation. If you create a variable called BEGIN or END and later want to use these commands the compiler will tell you that a reserved word cannot be used.


Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu

Web Links Related to this Article
Bug 3423: It is not possible to create a local variable named U without getting a compiler error elsewhere in the code
URL=http://www.dataaccess.com/bugtracker/PrintBug.asp?ArticleID=3423


Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.