Data Access Worldwide Knowledge Base

Article ID 2104
Article Title INFO: Call by Reference - byRef versus Variant
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2104
KBase Category VDF11
Date Created 04/06/2005
Last Edit Date 04/13/2005


Article Text
QUESTION:
There seems to be two ways of declaring the parameter to be By Reference on the "procedure" line:

1. Procedure AddOne Integer ByRef iValue

2. Procedure GetData Variant vData

What is the difference?


ANSWER:
Use of the ByRef keyword is replacing the old syntax of declaring by-ref parameters using the Variant type.

Prior to Visual DataFlex 11 you had to declare by-ref parameters using the Variant type, no matter what the intended parameter type was. This was very confusing and unintuitive, and it doesn't work with structs and arrays in VDF11.

As of VDF 11, the recommended syntax is to always use ByRef and follow it by the proper intended data type. This is more intuitive and it also works with all data types, including structs and arrays.

The old syntax, using the Variant type for by-ref parameters, still works the same way it always has for backward compatibility, but it's no longer the recommended syntax. Users of the old syntax may want to consider changing their code to the new syntax for clarity and consistency, even though it's not a requirement.

You may also have noticed that the documentation no longer suggests the usage of the Variant type to specify by-ref parameters; it's simply been replaced with ByRef. However, we seem to be missing a note about this in the What's New doc.





Contributed By:
Sonny Falk
Company: Data Access Worldwide
Web Site: http://www.dataaccess.com


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.