Kees,
The strange syntax in VO is for indexed assigns.
What is SELF:PKey in this context?
Robert
Miscellaneous questions about converting VO code to X#
Re: Miscellaneous questions about converting VO code to X#
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Re: Miscellaneous questions about converting VO code to X#
Kees,
I think that the code should be changed to:
SELF:PKey[nAUT] := #AUTNO
Most likely this was a bug in VO.
Robert
I think that the code should be changed to:
SELF:PKey[nAUT] := #AUTNO
Most likely this was a bug in VO.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Re: Miscellaneous questions about converting VO code to X#
Robert,
Well, you mentioned "assign" and I looked for it and indeed it is (also) an assign:
I never heard of "indexed assigns". Is there an explanation somewhere that I can study?
Kees.
Well, you mentioned "assign" and I looked for it and indeed it is (also) an assign:
Code: Select all
ASSIGN PKey(KeyVal, NameSym) CLASS _BPDataDialog
LOCAL i AS DWORD
IF Empty(SELF:FPKey)
SELF:FPKey := {{NameSym, KeyVal}}
ELSE
i := AScan(SELF:FPKey, {|aSub| aSub[1] = NameSym})
IF i = 0
AAdd(SELF:FPKey, {NameSym, KeyVal})
ELSE
SELF:FPKey[i,2] := KeyVal
ENDIF
ENDIF
RETURN KeyVal
Kees.
Re: Miscellaneous questions about converting VO code to X#
Kees,
You cannot have an EXPORT and ASSIGN with the same name.
If you rename the EXPORT then the syntax created by the Exporter should work.
Robert
You cannot have an EXPORT and ASSIGN with the same name.
If you rename the EXPORT then the syntax created by the Exporter should work.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Re: Miscellaneous questions about converting VO code to X#
Hi Kees,
About indexed assigns or accesses:
Normally you have a regular ACCESS like that:
ACCESS MovieLength AS INT
that you can call with
nLength := oMovie:MovieLength
but it is also possible to have an access with an index part as a parameter ("nMoviePart" below), which can be used to supply more information to the ACCESS, to return different values based on it:
ACCESS MovieLength( nMoviePart AS INT ) AS INT
This is called an "indexed" property, that you can call with this X# syntax:
nLength := oMovie:MovieLength[2] // get length of 2nd part
Similarly for ASSIGNs, for declaring regular ones you just need to supply a single parameter that holds the new value:
ASSIGN MovieLength(nNewLength AS INT)
...
SELF:MovieLength := 100
and for indexed properties you need to supply also the "index":
ASSIGN MovieLength(nNewLength AS INT, nMoviePart AS INT)
and those can be called like that in X# syntax:
SELF:MovieLength[2] := 100 // set the length of part 2 to 100
Unfortunately, instead of this easy to read and use syntax for calling indexed assigns, VO uses this bizarre one:
SELF:[MovieLength , 2] := 100
Just because this is so strange, instead of this syntax, in X# we went for the more "normal" one above.
About indexed assigns or accesses:
Normally you have a regular ACCESS like that:
ACCESS MovieLength AS INT
that you can call with
nLength := oMovie:MovieLength
but it is also possible to have an access with an index part as a parameter ("nMoviePart" below), which can be used to supply more information to the ACCESS, to return different values based on it:
ACCESS MovieLength( nMoviePart AS INT ) AS INT
This is called an "indexed" property, that you can call with this X# syntax:
nLength := oMovie:MovieLength[2] // get length of 2nd part
Similarly for ASSIGNs, for declaring regular ones you just need to supply a single parameter that holds the new value:
ASSIGN MovieLength(nNewLength AS INT)
...
SELF:MovieLength := 100
and for indexed properties you need to supply also the "index":
ASSIGN MovieLength(nNewLength AS INT, nMoviePart AS INT)
and those can be called like that in X# syntax:
SELF:MovieLength[2] := 100 // set the length of part 2 to 100
Unfortunately, instead of this easy to read and use syntax for calling indexed assigns, VO uses this bizarre one:
SELF:[MovieLength , 2] := 100
Just because this is so strange, instead of this syntax, in X# we went for the more "normal" one above.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: Miscellaneous questions about converting VO code to X#
I have renamed the export, and the syntax SELF:PKey[#AUTNO] seems to work. But, many times the class is inherited by another class and then the syntax is SELF:Owner:PKey[#AUTNO], where Owner is a USUAL. On those lines, I still get error XS9059 "Cannot convert Array Index from 'symbol' to 'int'".
Could it be that when the indexed access/assign is via a USUAL like Owner, you can't use Symbols?
Kees.
Re: Miscellaneous questions about converting VO code to X#
Hi Kees,
Yes, calling indexed properties is not supported (yet, at least) through late bound calls. You will ned to use an intermediate typed variable for that, like:
LOCAL oOwner AS ClassNameOfOwner
oOwner := (ClassNameOfOwner) SELF:Owner
oOwner:PKey[#AUTNO] := ...
where you will need to replace "ClassNameOfOwner" with the actual class name of course.
Yes, calling indexed properties is not supported (yet, at least) through late bound calls. You will ned to use an intermediate typed variable for that, like:
LOCAL oOwner AS ClassNameOfOwner
oOwner := (ClassNameOfOwner) SELF:Owner
oOwner:PKey[#AUTNO] := ...
where you will need to replace "ClassNameOfOwner" with the actual class name of course.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: Miscellaneous questions about converting VO code to X#
Chris,
Thank you for the explanation and also for the previous explanation! The problem exists in at least 137 locations (if I import more code, the number will go up) in the application so it will be a lot of work to modify them all to the workaround but I guess there is no other way...
Kees.
Thank you for the explanation and also for the previous explanation! The problem exists in at least 137 locations (if I import more code, the number will go up) in the application so it will be a lot of work to modify them all to the workaround but I guess there is no other way...
Kees.
Re: Miscellaneous questions about converting VO code to X#
Hi Kees,
If it helps, it can also be done without an intermediate variable, but in a single line, it's just less readable:
( (ClassNameOfOwner) SELF:Owner):PKey[#AUTNO] := ...
You will still need to supply the class name, but if it's the same in most cases, then a global search & replace might make things much easier..
If it helps, it can also be done without an intermediate variable, but in a single line, it's just less readable:
( (ClassNameOfOwner) SELF:Owner):PKey[#AUTNO] := ...
You will still need to supply the class name, but if it's the same in most cases, then a global search & replace might make things much easier..
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu