Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Converting some legacy code - TP VisualPlanit



Permlink Replies: 5 - Last Post: Feb 26, 2018 1:33 AM Last Post By: Ian Branch
Ian Branch

Posts: 442
Registered: 9/23/99
Converting some legacy code - TP VisualPlanit
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2018 9:20 PM
Hi Team,
D10.2.2, TP VisualPlanit v 1.03.
Yes an oldie but I'm having a play.

The following is a function in the code..
		function TVpResources.GetItem(Index: Integer): TVpResource;
		begin
		  result := TVpResource(FResourceList.List^[Index]);
		end;
		

This of course gives me an 'E2017 Pointer type required' error.

So I changed the code to this..
		function TVpResources.GetItem(Index: Integer): TVpResource;
		begin
		  result := TVpResource(Pointer(FResourceList.List)^[Index]);
		end;
		

It's happy with the pointer now but I get an 'E2016 Array type required' error for the Index.

I am not sure what to do here about Index as Index is supposed to be indicating a position in the list.

Versions of this code are scattered all through VP so it will get rid of a lot of errors if this issue can be resolved.
Thoughts/suggestions appreciated.

Regards & TIA,
Ian
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Converting some legacy code - TP VisualPlanit
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2018 11:43 PM   in response to: Ian Branch in response to: Ian Branch
Ian Branch wrote:

Hi Team,
D10.2.2, TP VisualPlanit v 1.03.
Yes an oldie but I'm having a play.

The following is a function in the code..
		function TVpResources.GetItem(Index: Integer): TVpResource;
		begin
		  result := TVpResource(FResourceList.List^[Index]);
		end;
		

This of course gives me an 'E2017 Pointer type required' error.

It probably gives you that since FResourceList.List is a pointer type
in the original code. If it is now a standard TList, for instance, just
remove the caret.


--
Peter Below
TeamB

Ian Branch

Posts: 442
Registered: 9/23/99
Re: Converting some legacy code - TP VisualPlanit
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 25, 2018 12:44 PM   in response to: Peter Below in response to: Peter Below
Hi Peter,
Thank you. Removing the caret eliminated all the errors around that construct. Yet to see if it is going to work. ;-)

I've resolved a couple of other issues however the following has me a little stumped as to what it is trying to do let
alone how to resolve it. Never done anything with inheriting however reading the doco on 'inherited' the construct
doesn't seem right.
		{==TVpMemoryStream===================================================}
		procedure TVpMemoryStream.SetPointer(Ptr : Pointer; Size : Integer);
		begin
		  Assert(not Assigned(Memory));
		  inherited;
		end;
		

This gives a 'E2008 Incompatible types' error for the 'inherited;'.
Your thoughts appreciated.

Regards & TIA,
Ian
Ian Branch

Posts: 442
Registered: 9/23/99
Re: Converting some legacy code - TP VisualPlanit
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 25, 2018 12:47 PM   in response to: Ian Branch in response to: Ian Branch
Should have included the following type definition from the start of the unit..

	  {The TVpMemoryStream class is used to expose TMemoryStream's SetPointer method.}
	  TVpMemoryStream = class(TMemoryStream)
	  public
	    procedure SetPointer(Ptr : Pointer; Size : Longint);
	  end;
	
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Converting some legacy code - TP VisualPlanit
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 25, 2018 11:10 PM   in response to: Ian Branch in response to: Ian Branch
Ian Branch wrote:

Hi Peter,
Thank you. Removing the caret eliminated all the errors around that
construct. Yet to see if it is going to work. ;-)

I've resolved a couple of other issues however the following has me
a little stumped as to what it is trying to do let alone how to
resolve it. Never done anything with inheriting however reading the
doco on 'inherited' the construct doesn't seem right.
 
{==TVpMemoryStream===================================================}
procedure TVpMemoryStream.SetPointer(Ptr : Pointer; Size : Integer);
begin 		  Assert(not Assigned(Memory));
		  inherited;
		end;
		

This gives a 'E2008 Incompatible types' error for the 'inherited;'.
Your thoughts appreciated.

Look at how TMemoryStream.SetPointer is defined in the Delphi version
you are using:

procedure SetPointer(Ptr: Pointer; const Size: NativeInt);

The type of the size parameter has changed. You can resolve this
conflict only by changing the declaration of your
TVpMemoryStream.SetPointer to match the one it is replacing in the
parent class.

--
Peter Below
TeamB

Ian Branch

Posts: 442
Registered: 9/23/99
Re: Converting some legacy code - TP VisualPlanit
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 26, 2018 1:33 AM   in response to: Peter Below in response to: Peter Below
Thanks Peter,
I see it has to match exactly, including the const.
All good now.
Regards,
Ian
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02