PDA

View Full Version : bug using overloaded



Rafael
16-Dec-2008, 02:45 PM
Someone used overloaded in VDF apps?

I found a bug (I think) in VDF2008 that works in VDF10.

Something like this:

Object oButton1 is a Button
Set Location to 4 177
Set Label to "oButton1"

Procedure ShowInfo Overloaded Integer iFile String sField
Showln iFile "-" sField
End_Procedure

Procedure ShowInfo Overloaded Integer iField
Integer iFile
String sField
Move Customer.File_Number to iFile
Get_Attribute DF_FIELD_NAME of iFile iField to sField
Send ShowInfo iFile sField
End_Procedure

// fires when the button is clicked
Procedure OnClick
Send ShowInfo 3 // Showln=25-Address
Send ShowInfo Field Customer.Address //Error
End_Procedure

End_Object

I did it in Customer.vw on Order Entry example...

Rafael
17-Dec-2008, 05:48 AM
If I change the code to this, Order Entry Example don't compile:

Object oButton1 is a Button
Set Location to 4 177
Set Label to "oButton1"

Procedure ShowInfo Overloaded Integer iFile String sField String
sValue
Showln iFile "-" sField
End_Procedure

Procedure ShowInfo Overloaded Integer iField
Integer iFile
String sField
String sValue
Move Customer.File_Number to iFile
Get_Attribute DF_FIELD_NAME of iFile iField to sField
Get_Field_Value Customer.File_Number iField to sValue
Send ShowInfo iFile sField sValue
End_Procedure

// fires when the button is clicked
Procedure OnClick
Send ShowInfo 3 // Showln=25-Address
Send ShowInfo Field Customer.Address // Compile Error: 4306
Forward Reference not resolved
End_Procedure

End_Object

"Rafael" <rafael@softdata.com.br> escreveu na mensagem
news:dTPnKc7XJHA.2072@dacmail.dataaccess.com...
> Someone used overloaded in VDF apps?
>
> I found a bug (I think) in VDF2008 that works in VDF10.
>
> Something like this:
>
> Object oButton1 is a Button
> Set Location to 4 177
> Set Label to "oButton1"
>
> Procedure ShowInfo Overloaded Integer iFile String sField
> Showln iFile "-" sField
> End_Procedure
>
> Procedure ShowInfo Overloaded Integer iField
> Integer iFile
> String sField
> Move Customer.File_Number to iFile
> Get_Attribute DF_FIELD_NAME of iFile iField to sField
> Send ShowInfo iFile sField
> End_Procedure
>
> // fires when the button is clicked
> Procedure OnClick
> Send ShowInfo 3 // Showln=25-Address
> Send ShowInfo Field Customer.Address //Error
> End_Procedure
>
> End_Object
>
> I did it in Customer.vw on Order Entry example...
>

Igor van Houttum
17-Dec-2008, 07:25 AM
Rafael,

When calling an overloaded method you need to use exactly the same
number of parameters as defined in any of the overloaded procedures. You
use 2, but only define 1 and 3.


Regards,
Igor van Houttum
Data Access Europe BV

Rafael
17-Dec-2008, 08:48 AM
Actually, I use only one parameter, "Field Customer.Address".
"Field" is used to send the field# and not the value.



"Igor van Houttum" <igordotvandothouttum@dataaccess.nl> escreveu na mensagem
news:0dO8$JEYJHA.5244@dacmail.dataaccess.com...
> Rafael,
>
> When calling an overloaded method you need to use exactly the same number
> of parameters as defined in any of the overloaded procedures. You use 2,
> but only define 1 and 3.
>
>
> Regards,
> Igor van Houttum
> Data Access Europe BV

A Paul Anthony
17-Dec-2008, 09:58 AM
Rafael wrote:
> If I change the code to this, Order Entry Example don't compile:
>
> Object oButton1 is a Button
> Set Location to 4 177
> Set Label to "oButton1"
>
> Procedure ShowInfo Overloaded Integer iFile String sField String
> sValue
> Showln iFile "-" sField
> End_Procedure
>
> Procedure ShowInfo Overloaded Integer iField
> Integer iFile
> String sField
> String sValue
> Move Customer.File_Number to iFile
> Get_Attribute DF_FIELD_NAME of iFile iField to sField
> Get_Field_Value Customer.File_Number iField to sValue
> Send ShowInfo iFile sField sValue
> End_Procedure
>
> // fires when the button is clicked
> Procedure OnClick
> Send ShowInfo 3 // Showln=25-Address
> Send ShowInfo Field Customer.Address // Compile Error: 4306
> Forward Reference not resolved
> End_Procedure
>
> End_Object
>
I stopped using OVERLOADED some time ago in favour of "Num_Arguments". I
found OVERLOADED was actually global and so overloading a property such
as Value in a custom class cause all sorts of problems with just about
every UI control by overloading their namesake functions. I was trying
to extend the Array class to be two dimensional, so this was some time
ago and probably doesn't still have the same issue, but I found
Num_Arguments to be generally more flexable anyway and so have stuck
with it.

Anyway, a similar effect to overloading however can be obtained using
the aforementioned num_arguments by re-structure you code so that if
methods are called without arguments then default values can be assumed
instead.


Incidentally I assume you second ShowInfo line was supposed to be as follows

Send ShowInfo File_Field Customer.Address Customer.Address //
Compile Error: 4306"


File_Field is a very useful parameter keyword that automatically parsew
out the file.field constant into two integer variables, iFile and iField
in this case, then the second Customer.Address actually passes the
field's value.

--

A Paul Anthony
Software Developer

A Paul Anthony
17-Dec-2008, 10:03 AM
Rafael wrote:
> Actually, I use only one parameter, "Field Customer.Address".
> "Field" is used to send the field# and not the value.
>
So if both of your lines actually were intended to send the same thing -
that is, call the function with only one argument? Why do you need to
overloading at all, then?

--

A Paul Anthony
Software Developer

Rafael
17-Dec-2008, 10:46 AM
I did it like a example.
But I in my application, I had a method with 2 parameters, and I change the
method to receive only one parameter. Then, to don't change ALL source, I
overloaded my method to use both methods, but in VDF2008 its not works
because I use reserved word "FIELD" to call the method. When I use the
reserved word FIELD in method's parameters the compiler "thinks" that "he"
must call the method with 2 parameters, but actually, "he" must call the
method with one parameter because "FIELD CUSTOMER.ADDRESS" is the same of
"3", in Order Entry Example.

"A Paul Anthony" <Paul@asckey.com> escreveu na mensagem
news:wlReNiFYJHA.2076@dacmail.dataaccess.com...
> Rafael wrote:
>> Actually, I use only one parameter, "Field Customer.Address".
>> "Field" is used to send the field# and not the value.
>>
> So if both of your lines actually were intended to send the same thing -
> that is, call the function with only one argument? Why do you need to
> overloading at all, then?
>
> --
>
> A Paul Anthony
> Software Developer

Rafael
17-Dec-2008, 10:54 AM
All right...
But in my application I had the same method with two and one parameters.
This code I made like a example, it's not my real situation.
My real situation is like this:

Procedure myMethod Overloaded Integer iParam String sParam
Procedure myMethod Overloaded Integer iParam

I could use Num_argments in this case, because the parameter of the second
method is equal to first parameter of first method. But If my case is
different. Is something like this:

Procedure myMethod Overloaded Integer iParam String sParam
Procedure myMethod Overloaded String sParam

How I could write some code to use Num_arguments, because my original method
is the first method? I could change de first parameter to String and use
Num_arguments to do a cast. But in my opinion, is not the correct way to fix
it. I think that is a bug in VDF2008. It's works in VDF10, why is not works
in VDF14?

Rafael

"A Paul Anthony" <Paul@asckey.com> escreveu na mensagem
news:fHX99fFYJHA.2076@dacmail.dataaccess.com...
> Rafael wrote:
>> If I change the code to this, Order Entry Example don't compile:
>>
>> Object oButton1 is a Button
>> Set Location to 4 177
>> Set Label to "oButton1"
>>
>> Procedure ShowInfo Overloaded Integer iFile String sField String
>> sValue
>> Showln iFile "-" sField
>> End_Procedure
>>
>> Procedure ShowInfo Overloaded Integer iField
>> Integer iFile
>> String sField
>> String sValue
>> Move Customer.File_Number to iFile
>> Get_Attribute DF_FIELD_NAME of iFile iField to sField
>> Get_Field_Value Customer.File_Number iField to sValue
>> Send ShowInfo iFile sField sValue
>> End_Procedure
>>
>> // fires when the button is clicked
>> Procedure OnClick
>> Send ShowInfo 3 // Showln=25-Address
>> Send ShowInfo Field Customer.Address // Compile Error: 4306
>> Forward Reference not resolved
>> End_Procedure
>>
>> End_Object
>>
> I stopped using OVERLOADED some time ago in favour of "Num_Arguments". I
> found OVERLOADED was actually global and so overloading a property such as
> Value in a custom class cause all sorts of problems with just about every
> UI control by overloading their namesake functions. I was trying to extend
> the Array class to be two dimensional, so this was some time ago and
> probably doesn't still have the same issue, but I found Num_Arguments to
> be generally more flexable anyway and so have stuck with it.
>
> Anyway, a similar effect to overloading however can be obtained using the
> aforementioned num_arguments by re-structure you code so that if methods
> are called without arguments then default values can be assumed instead.
>
>
> Incidentally I assume you second ShowInfo line was supposed to be as
> follows
>
> Send ShowInfo File_Field Customer.Address Customer.Address //
> Compile Error: 4306"
>
>
> File_Field is a very useful parameter keyword that automatically parsew
> out the file.field constant into two integer variables, iFile and iField
> in this case, then the second Customer.Address actually passes the field's
> value.
>
> --
>
> A Paul Anthony
> Software Developer

A Paul Anthony
17-Dec-2008, 11:13 AM
Rafael wrote:
> All right...
> But in my application I had the same method with two and one parameters.
> This code I made like a example, it's not my real situation.
> My real situation is like this:
>
> Procedure myMethod Overloaded Integer iParam String sParam
> Procedure myMethod Overloaded Integer iParam
>
> I could use Num_argments in this case, because the parameter of the second
> method is equal to first parameter of first method. But If my case is
> different. Is something like this:
>
> Procedure myMethod Overloaded Integer iParam String sParam
> Procedure myMethod Overloaded String sParam
>
> How I could write some code to use Num_arguments, because my original method
> is the first method? I could change de first parameter to String and use
> Num_arguments to do a cast. But in my opinion, is not the correct way to fix
> it. I think that is a bug in VDF2008. It's works in VDF10, why is not works
> in VDF14?
>
> Rafael
>
To be honest I'm not sure what I'd do in your situation as VDF doesn't
overload by type but purely by number of arguments. Its one of the joys
of a loosely typed language which unfortunately does pose interesting
scenarios like these. You could always use a variant :-)

--

A Paul Anthony
Software Developer

Ian Smith
18-Dec-2008, 09:25 AM
Hi Rafael

I think the following is happening.

The compile checks the number of parameters being passed to the method
and tries to resolve the method. It sees 2 parameters
1. Field
2. Customer.Address
This results in the error as the compile can not find a method called
ShowInfo which accepts 2 parameters.

If you code

Send ShowInfo Field Customer.Address Customer.Address

the compiler is happy as it counts 3 parameters and can find a method
called ShowInfo that accepts 3 parameters.

However if you do that and put a break point in the ShowInfo method
you will see that the third parameter is missing. After first counting
Field as one of the parameters the compile removes it as it then
considers Field to be a parameter modifier (which it is). This results
in only 2 parameters begin passed to the showInfo method.

The issue is where in the compile process, parameter modifiers are
applied. There are several options, but they all require changes to
the compiler or FMAC. If the parameter count is read only then the
compile will have to be changed. If the parameter count can be changed
then it may be possible to fix this via FMAC which should be quicker
to implement.

However this is definitely one for DAW and in the mean time I think
Paul's suggestion to use Num_Arguments is the best / only option.

Ian Smith


On Tue, 16 Dec 2008 17:45:57 -0200, "Rafael" <rafael@softdata.com.br>
wrote:

>Someone used overloaded in VDF apps?
>
>I found a bug (I think) in VDF2008 that works in VDF10.
>
>Something like this:
>
>Object oButton1 is a Button
> Set Location to 4 177
> Set Label to "oButton1"
>
> Procedure ShowInfo Overloaded Integer iFile String sField
> Showln iFile "-" sField
> End_Procedure
>
> Procedure ShowInfo Overloaded Integer iField
> Integer iFile
> String sField
> Move Customer.File_Number to iFile
> Get_Attribute DF_FIELD_NAME of iFile iField to sField
> Send ShowInfo iFile sField
> End_Procedure
>
> // fires when the button is clicked
> Procedure OnClick
> Send ShowInfo 3 // Showln=25-Address
> Send ShowInfo Field Customer.Address //Error
> End_Procedure
>
> End_Object
>
>I did it in Customer.vw on Order Entry example...
>

Rafael
19-Dec-2008, 08:48 AM
Yeah, I think that use Num_arguments is the only option for now.

Thanks

Rafael

"Ian Smith" <Dataflex@ablescan.com> escreveu na mensagem
news:0mlkk41f899iif62q0r872lkvt161gkugk@4ax.com...
> Hi Rafael
>
> I think the following is happening.
>
> The compile checks the number of parameters being passed to the method
> and tries to resolve the method. It sees 2 parameters
> 1. Field
> 2. Customer.Address
> This results in the error as the compile can not find a method called
> ShowInfo which accepts 2 parameters.
>
> If you code
>
> Send ShowInfo Field Customer.Address Customer.Address
>
> the compiler is happy as it counts 3 parameters and can find a method
> called ShowInfo that accepts 3 parameters.
>
> However if you do that and put a break point in the ShowInfo method
> you will see that the third parameter is missing. After first counting
> Field as one of the parameters the compile removes it as it then
> considers Field to be a parameter modifier (which it is). This results
> in only 2 parameters begin passed to the showInfo method.
>
> The issue is where in the compile process, parameter modifiers are
> applied. There are several options, but they all require changes to
> the compiler or FMAC. If the parameter count is read only then the
> compile will have to be changed. If the parameter count can be changed
> then it may be possible to fix this via FMAC which should be quicker
> to implement.
>
> However this is definitely one for DAW and in the mean time I think
> Paul's suggestion to use Num_Arguments is the best / only option.
>
> Ian Smith
>
>
> On Tue, 16 Dec 2008 17:45:57 -0200, "Rafael" <rafael@softdata.com.br>
> wrote:
>
>>Someone used overloaded in VDF apps?
>>
>>I found a bug (I think) in VDF2008 that works in VDF10.
>>
>>Something like this:
>>
>>Object oButton1 is a Button
>> Set Location to 4 177
>> Set Label to "oButton1"
>>
>> Procedure ShowInfo Overloaded Integer iFile String sField
>> Showln iFile "-" sField
>> End_Procedure
>>
>> Procedure ShowInfo Overloaded Integer iField
>> Integer iFile
>> String sField
>> Move Customer.File_Number to iFile
>> Get_Attribute DF_FIELD_NAME of iFile iField to sField
>> Send ShowInfo iFile sField
>> End_Procedure
>>
>> // fires when the button is clicked
>> Procedure OnClick
>> Send ShowInfo 3 // Showln=25-Address
>> Send ShowInfo Field Customer.Address //Error
>> End_Procedure
>>
>> End_Object
>>
>>I did it in Customer.vw on Order Entry example...
>>

Dennis Piccioni
19-Dec-2008, 12:29 PM
Hi Rafael,

in my testing this I found that the 'Field" keyword seems to be what
causes the error. I got it working using the code below:

Procedure ShowInfo Overloaded Integer iFile String sField
Showln iFile "-" sField
End_Procedure

Procedure ShowInfo Overloaded Integer iField
Integer iFile
String sField
Move Customer.File_Number to iFile
Get_Attribute DF_FIELD_NAME of iFile iField to sField
Send ShowInfo iFile sField
End_Procedure

// fires when the button is clicked
Procedure OnClick
Integer iField
Send ShowInfo 3 // Showln=25-Address
Move 5 to iField
Clear Customer
Find gt Customer by 1
Send ShowInfo iField Customer.Address //Error, call ShowInfo with
two parameters
End_Procedure


On Tue, 16 Dec 2008 17:45:57 -0200, "Rafael" <rafael@softdata.com.br>
wrote:

>Someone used overloaded in VDF apps?
>
>I found a bug (I think) in VDF2008 that works in VDF10.
>
>Something like this:
>
>Object oButton1 is a Button
> Set Location to 4 177
> Set Label to "oButton1"
>
> Procedure ShowInfo Overloaded Integer iFile String sField
> Showln iFile "-" sField
> End_Procedure
>
> Procedure ShowInfo Overloaded Integer iField
> Integer iFile
> String sField
> Move Customer.File_Number to iFile
> Get_Attribute DF_FIELD_NAME of iFile iField to sField
> Send ShowInfo iFile sField
> End_Procedure
>
> // fires when the button is clicked
> Procedure OnClick
> Send ShowInfo 3 // Showln=25-Address
> Send ShowInfo Field Customer.Address //Error
> End_Procedure
>
> End_Object
>
>I did it in Customer.vw on Order Entry example...
>

Regards,
Dennis