With the last Fox version I resumed my conversion work, by re-running the XPorter on my VO library. I get this error on some code to read/write the registry:
Error XS9040 The type of the first ASSIGN parameter must match the returntype of the ACCESS.
I would say it does? Below the code:
In the class:
PROTECT hKeyP AS PTR
Returntype and parameter are PTR's ....
Dick
ACCESS hKey STRICT
RETURN SELF:hKeyP
ASSIGN hKey( ptr_hKey AS PTR ) AS PTR STRICT
IF ( ptr_hKey == HKEY_CLASSES_ROOT .OR. ;
ptr_hKey == HKEY_CURRENT_USER .OR. ;
ptr_hKey == HKEY_LOCAL_MACHINE .OR. ;
ptr_hKey == HKEY_USERS .OR. ;
ptr_hKey == HKEY_CURRENT_CONFIG .OR. ;
ptr_hKey == HKEY_DYN_DATA ;
)
SELF:hKeyP := ptr_hKey
ELSE
// Default standard key:
SELF:hKeyP := HKEY_LOCAL_MACHINE
ENDIF
RETURN SELF:hKeyP
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Hi Dick,
The ASSIGN has a PTR param, while the ACCESS is untyped, so it returns a USUAL. Type the access AS PTR STRICT and it should be fine.
The ASSIGN has a PTR param, while the ACCESS is untyped, so it returns a USUAL. Type the access AS PTR STRICT and it should be fine.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Hello Chris,
Of course! I was so concentrated on SELF:hKeyP, PTR in both, that I missed that the access was actually untyped.
Adding AS PTR STRICT indeed solved it, thanks.
Dick
Of course! I was so concentrated on SELF:hKeyP, PTR in both, that I missed that the access was actually untyped.
Adding AS PTR STRICT indeed solved it, thanks.
Dick
-
- Posts: 97
- Joined: Tue Mar 01, 2016 11:50 am
- Location: Germany
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Hello Chris,
in VO an ASSIGN should never return a value - if I remember right an info from Robert. Then the assign should be
ASSIGN hKey (ptr_hKey AS PTR) AS VOID STRICT. So the return values of ASSIGN and ACCESS are not equal. Is this a problem in X#?
Thanks in advance.
Best regards
Gerhard
in VO an ASSIGN should never return a value - if I remember right an info from Robert. Then the assign should be
ASSIGN hKey (ptr_hKey AS PTR) AS VOID STRICT. So the return values of ASSIGN and ACCESS are not equal. Is this a problem in X#?
Thanks in advance.
Best regards
Gerhard
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Hi Gerhard,
X# translates the access/assign pair to a .NET property.
One of the prerequisites of the property is that the getter part has to return the same datatype as the setter part accepts, and the setter part has no return type.
So the correct access/assign pair in X# is for example:
In X# the relative code will look like this (short form)
Wolfgang
X# translates the access/assign pair to a .NET property.
One of the prerequisites of the property is that the getter part has to return the same datatype as the setter part accepts, and the setter part has no return type.
So the correct access/assign pair in X# is for example:
Code: Select all
assign hKey( ptrKey as ptr ) as void
return _ptrKey
access hKey as ptr
return _ptrKey
Code: Select all
property hKey as ptr get _ptrKey set _ptrKey := value
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Hi Gerhard,
As Wolfgang explained, param type of ASSIGN = return type of ACCESS. Indeed, ASSIGNs do not return anything in .Net.
As Wolfgang explained, param type of ASSIGN = return type of ACCESS. Indeed, ASSIGNs do not return anything in .Net.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Out of curiosity: Does anyone know, WHY this is so? I could understand, that MS thought this not essential, but why explicitely forbid a return value?Chris wrote:As Wolfgang explained, param type of ASSIGN = return type of ACCESS. Indeed, ASSIGNs do not return anything in .Net.
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
-
- Posts: 97
- Joined: Tue Mar 01, 2016 11:50 am
- Location: Germany
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Hi Wolfgang and Chris,
thanks for the clarification.
Gerhard
thanks for the clarification.
Gerhard
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Karl,
Try this in VO:
What do you think will be shown as the result of the assignment ?
And is the access called (try to set a break point there) ?
Robert
Try this in VO:
Code: Select all
CLASS Bar
PROTECT Value AS LONG
ASSIGN Foo(nNewValue) CLASS Bar
SELF:Value := nNewValue
RETURN nNewValue *2
ACCESS Foo CLASS Bar
RETURN SELF:Value
FUNCTION Start
LOCAL oBar AS Bar
oBar := Bar{}
? oBar:Foo := 10
WAIT
RETURN NIL
And is the access called (try to set a break point there) ?
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Error XS9040 The type of the first ASSIGN parameter must match the returntype...
Robert,
thx, that's short and clear - yes, it won't access the access.
@Gerhard, sorry for capering your thread...
thx, that's short and clear - yes, it won't access the access.
@Gerhard, sorry for capering your thread...
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)