| | |
C++ to Delphi conversion
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
I am trying to convert a piece of code into Delphi but fall down when it comes to this example :
Could you please help
Pascal and Delphi Syntax (Toggle Plain Text)
void __stdcall GetBuffers( short **xBuffers, unsigned long nValues) { ....... memcpy(TargetA, xBuffers[0], nValues * sizeof(short)); memcpy(TargetB, xBuffers[1], nValues * sizeof(short)); memcpy(TargetC, xBuffers[3], nValues * sizeof(short)); memcpy(Targetd, xBuffers[4], nValues * sizeof(short)); }
•
•
Join Date: Oct 2009
Posts: 10
Reputation:
Solved Threads: 4
0
#2 Nov 13th, 2009
MemCpy (Destination, Source, Num)
destination - Pointer to the destination array where the content is to be copied
source - Pointer to the source of data to be copied
num - Number of bytes to copy.
Delphi
procedure Move(const Source; var Dest; Count: Integer);
Move(Source, Destination, SizeOf(Destinaton)); { SizeOf = safety! }
destination - Pointer to the destination array where the content is to be copied
source - Pointer to the source of data to be copied
num - Number of bytes to copy.
Delphi
procedure Move(const Source; var Dest; Count: Integer);
Move(Source, Destination, SizeOf(Destinaton)); { SizeOf = safety! }
•
•
Join Date: Nov 2009
Posts: 41
Reputation:
Solved Threads: 5
0
#4 Nov 17th, 2009
If I am right, **ptr is a pointer to an array of pointers to short integers... in delphi it is not used like this (thanks, Lord!).
If you know the lengths of the arrays when coding:
Then you pass a as paramter, and use a[0] as the first pointer, a[1]... etc.
If the lengths are not know (as i suppose), you just make this:
And in the code, to set the lengths:
So you don't need to play with pointers of pointer to pointer that point to shorts or any other tipycal C puzzles, just pass an "a" and it is done.
If you know the lengths of the arrays when coding:
Pascal and Delphi Syntax (Toggle Plain Text)
var a: array[0..10, 0..20] of short;
Then you pass a as paramter, and use a[0] as the first pointer, a[1]... etc.
If the lengths are not know (as i suppose), you just make this:
Pascal and Delphi Syntax (Toggle Plain Text)
a: array of array of short;
And in the code, to set the lengths:
Pascal and Delphi Syntax (Toggle Plain Text)
SetLength(a, 10); //10 pointers to arrays of shorts; for i:= Low(a) to High(a) do SetLength(a[i], 20); //Each one with 20 elements (could be different for each array)
So you don't need to play with pointers of pointer to pointer that point to shorts or any other tipycal C puzzles, just pass an "a" and it is done.
![]() |
Similar Threads
- delphi conversion software (Pascal and Delphi)
- Hard C++ to Delphi Conversion (Pascal and Delphi)
- Delphi to C++ Conversion (C++)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Format string in Delphi
- Next Thread: Converting Delphi Components
Views: 1124 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Pascal and Delphi
animation api app array button compile console data database dbisam delete delphi delphihelpimageforloop documentcomplete2 edit environment error errors events file form function gdi gis lasrautoinc media navigatecomplete2 network object open opengl pascal passing path player procedure search set sql table twebbrowser username variable win7 windows





