Solved

Pointers, what do I do wrong here?

Posted on 2008-10-21
3
164 Views
Last Modified: 2010-04-05
var LPRGBTripleArray : ^TRGBTripleArray;
    LBitmapScanned : array[0..125] of ^TRGBTripleArray;
   
    i : Integer;
begin
  for i := 0 to 125 do
  begin
    LBitmapScanned[i] := MyBitmap.ScanLine[i];    
 
  end;
 
  LPRGBTripleArray := LBitmapScanned[0]; //compiler says that the type is different here, but it is ^TRGBTripleArray in both cases...
 
end;  

Thank you

panJames
 
0
Comment
Question by:panJames
  • 2
3 Comments
 
LVL 6

Expert Comment

by:ChristianWimmer
ID: 22768784
Define a new type called PRGBTripleArray and use it instead.
type

  PRGBTripleArray = ^TRGBTripleArray;
 

var LPRGBTripleArray : PRGBTripleArray;

    LBitmapScanned : array[0..125] of PRGBTripleArray;

Open in new window

0
 

Author Comment

by:panJames
ID: 22774357
It compiles fine now, thank you.

But what was wrong with my approach?

panJames
0
 
LVL 6

Accepted Solution

by:
ChristianWimmer earned 500 total points
ID: 22775147
You define an anonymous type (^TRGBTripleArray) for every variable declaration. Although the data structure is the same, Delphi does not consider them to be the same. They are declared twice and thus are different types. If you create a new type and let the variables use them instead, the assignment is no more a problem.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now