VO conversion - PTR issue

This forum is meant for questions and discussions about the X# language and tools
Post Reply
boonnam
Posts: 88
Joined: Mon May 08, 2017 6:42 pm
Location: USA

VO conversion - PTR issue

Post by boonnam »

I'm testing our converted VO application. It is using VO dialect, and I am on v1.03.

Here is an example method:

METHOD AgtStmtHdr(iPage, nPageCnt, dVdate, lFinal)
.
.
.
.
IF iPage != 0
.
.
ELSE
.
.
ENDIF

iPage++
.
.
.
.

RETURN


A calling method look something like this:

METHOD Execute()
LOCAL page as INT
.
.
.
page := 0
SELF:AgtStmtHdr(@page,@nPageCnt,dVdate,lFinal)
.
.
.

RETURN

When I run it, it would crashed on line, "IF iPage != 0". The error is "Value does not fall within the expected range". In VO iPage (inside AgtStmtHdr) is 0, but while debugging in X#, I see a big number like 19745096 (PTR), but if I expand it, I see something like 0x01a781c for the "value".

My focus is to fix issue with iPage. The same fix would apply to nPageCnt.

I resolved one small class with same issue by creating a protected variable for the page and use it, instead of passing it as a parameter.

Anyone run into similar issue and what is the best way to correct it? Is there a way to correct the codes inside AgtSmtHdr method? I'm trying to minimize the amount of changes as much as possible.

Thanks,

Boonnam
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

VO conversion - PTR issue

Post by robert »

Boonnam,

What you are doing in this code is passing USUAL values by reference.
The Vulcan runtime does not support this.
If you control this code, then I would advise to change it a little bit:

Code: Select all

METHOD AgtStmtHdr(iPage REF USUAL, nPageCnt REF USUAL, dVdate AS USUAL, lFinal AS USUAL)
Or use more correct types, such as INT, INT, DATE and LOGIC

And in the calling code:

Code: Select all

SELF:AgtStmtHdr(@page,@nPageCnt,dVdate,lFinal)
This requires compiler option /vo7 (Implicit Casts And Conversions)

or better (since it documents what you are doing)

Code: Select all

SELF:AgtStmtHdr(REF page, REF nPageCnt,dVdate,lFinal)
This will also compile without /vo7

In VO REF variables and the addressof operator (@) are mixed. In most languages these are 2 completely different things.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply