What does this mean in C++ AType(Ptr)[index]

S

SGi

I wonder if anyone here knew Pascal before C++, perhaps you could help me
out. I'm converting some pascal code into C++, and I can't seem to
understand what AType(Ptr)[index] is trying to accomplish. Any helps would
be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);
 
M

mlimber

SGi said:
I wonder if anyone here knew Pascal before C++, perhaps you could help me
out. I'm converting some pascal code into C++, and I can't seem to
understand what AType(Ptr)[index] is trying to accomplish. Any helps would
be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked in a
more appropriate forum. See this FAQ for what is on-topic here and for
some possible forums you can post in:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M
 
V

Victor Bazarov

mlimber said:
SGi said:
I wonder if anyone here knew Pascal before C++, perhaps you could
help me out. I'm converting some pascal code into C++, and I can't
seem to understand what AType(Ptr)[index] is trying to accomplish.
Any helps would be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked in a
more appropriate forum. See this FAQ for what is on-topic here and for
some possible forums you can post in:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M

Don't just the gun, M. In the expression

Move(AType(Ptr)[index], ...

The part

AType(Ptr)[index]

is an explicit type conversion from 'Ptr' to 'AType' ("functional notation")
and then applying of the indexing operator to it.

V
 
S

SGi

AType(Ptr)[index]
is an explicit type conversion from 'Ptr' to 'AType' ("functional
notation")
and then applying of the indexing operator to it.


Thanks a lot Vic.
 
M

mlimber

Victor said:
mlimber said:
SGi said:
I wonder if anyone here knew Pascal before C++, perhaps you could
help me out. I'm converting some pascal code into C++, and I can't
seem to understand what AType(Ptr)[index] is trying to accomplish.
Any helps would be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked in a
more appropriate forum. See this FAQ for what is on-topic here and for
some possible forums you can post in:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M

Don't just the gun, M. In the expression [...]

But it's a *Pascal* expression!

Cheers! --M
 
R

Rolf Magnus

Victor said:
mlimber said:
SGi said:
I wonder if anyone here knew Pascal before C++, perhaps you could
help me out. I'm converting some pascal code into C++, and I can't
seem to understand what AType(Ptr)[index] is trying to accomplish.
Any helps would be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked in a
more appropriate forum. See this FAQ for what is on-topic here and for
some possible forums you can post in:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M

Don't just the gun, M. In the expression

Move(AType(Ptr)[index], ...

The part

AType(Ptr)[index]

is an explicit type conversion from 'Ptr' to 'AType' ("functional
notation") and then applying of the indexing operator to it.

Maybe that's the case. I don't know Pascal. Anyway, since we're not in a
Pascal group, this is off-topic.
 
V

Victor Bazarov

mlimber said:
Victor said:
mlimber said:
SGi wrote:
I wonder if anyone here knew Pascal before C++, perhaps you could
help me out. I'm converting some pascal code into C++, and I can't
seem to understand what AType(Ptr)[index] is trying to accomplish.
Any helps would be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked
in a more appropriate forum. See this FAQ for what is on-topic here
and for some possible forums you can post in:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M

Don't just the gun, M. In the expression [...]

But it's a *Pascal* expression!

Why do you think that? For all I know it's a C++ expression written
after four (three) lines of something that isn't C++. *If* we assume
that it's a C++ expression, my explanation holds, doesn't it? IOW,
I gave the interpretation of that expression _as_if_ it were a C++ one.
You, however, immediately dismissed it as non-C++ one. What's more
surprising, you managed to conclude that it *was* a Pascal expression
(and not a C++ expression). How the hell did you know? The expression

Move(AType(Ptr)[index], dest_word, 2);

looks like C++ to me. What led you to believe it wasn't?

V
 
V

Victor Bazarov

Rolf said:
Victor said:
mlimber said:
SGi wrote:
I wonder if anyone here knew Pascal before C++, perhaps you could
help me out. I'm converting some pascal code into C++, and I can't
seem to understand what AType(Ptr)[index] is trying to accomplish.
Any helps would be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked
in a more appropriate forum. See this FAQ for what is on-topic here
and for some possible forums you can post in:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M

Don't just the gun, M. In the expression

Move(AType(Ptr)[index], ...

The part

AType(Ptr)[index]

is an explicit type conversion from 'Ptr' to 'AType' ("functional
notation") and then applying of the indexing operator to it.

Maybe that's the case. I don't know Pascal. Anyway, since we're not
in a Pascal group, this is off-topic.

Another one! What makes you think that "Move(AType(Ptr)[index], .."
is not a C++ expression. For all I know about C++, that expression
surely looks like C++. I just explained what it is in C++. Did you
think otherwise? What gave you that idea?

V
 
M

mlimber

Victor said:
Why do you think that?

Because the OP said, "I'm converting some pascal code into C++, and I
can't seem to understand what AType(Ptr)[index] is trying to
accomplish," and then gave the Pascal definitions for AType and Ptr. It
may have looked like a duck, but in reality it was a goose!

Cheers! --M
 
K

Kai-Uwe Bux

Victor said:
mlimber said:
Victor said:
mlimber wrote:
SGi wrote:
I wonder if anyone here knew Pascal before C++, perhaps you could
help me out. I'm converting some pascal code into C++, and I can't
seem to understand what AType(Ptr)[index] is trying to accomplish.
Any helps would be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked
in a more appropriate forum. See this FAQ for what is on-topic here
and for some possible forums you can post in:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M

Don't just the gun, M. In the expression [...]

But it's a *Pascal* expression!

Why do you think that? For all I know it's a C++ expression written
after four (three) lines of something that isn't C++. *If* we assume
that it's a C++ expression, my explanation holds, doesn't it? IOW,
I gave the interpretation of that expression _as_if_ it were a C++ one.
You, however, immediately dismissed it as non-C++ one. What's more
surprising, you managed to conclude that it *was* a Pascal expression
(and not a C++ expression). How the hell did you know? The expression

Move(AType(Ptr)[index], dest_word, 2);

looks like C++ to me. What led you to believe it wasn't?

Hm, I wonder what it is that makes believe that "Hand" in

"Hand me that book, please."

is English and not German. If someone would ask for the meaning of "Hand",
and gives that example sentence, would it be appropriate to say that "Hand"
is a noun in German that refers to those five-fingered things at the ends
of our arms?


Best

Kai-Uwe Bux
 
S

SGi

Another one! What makes you think that "Move(AType(Ptr)[index], .."
is not a C++ expression. For all I know about C++, that expression
surely looks like C++. I just explained what it is in C++. Did you
think otherwise? What gave you that idea?

Move((void*)static_cast<BYTE*>(Ptr)[index], &w, 2);


Almost pure C++...
 
R

Rolf Magnus

Victor said:
Rolf said:
Victor said:
mlimber wrote:
SGi wrote:
I wonder if anyone here knew Pascal before C++, perhaps you could
help me out. I'm converting some pascal code into C++, and I can't
seem to understand what AType(Ptr)[index] is trying to accomplish.
Any helps would be appreciated. Thanks.

type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

This is a Pascal (or perhaps Delphi) question and should be asked
in a more appropriate forum. See this FAQ for what is on-topic here
and for some possible forums you can post in:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M

Don't just the gun, M. In the expression

Move(AType(Ptr)[index], ...

The part

AType(Ptr)[index]

is an explicit type conversion from 'Ptr' to 'AType' ("functional
notation") and then applying of the indexing operator to it.

Maybe that's the case. I don't know Pascal. Anyway, since we're not
in a Pascal group, this is off-topic.

Another one! What makes you think that "Move(AType(Ptr)[index], .."
is not a C++ expression.
For all I know about C++, that expression
surely looks like C++. I just explained what it is in C++. Did you
think otherwise? What gave you that idea?

The OP. He wanted some Pascal code converted to C++ and wanted to know how
to do that for a specific piece of code. And that piece was:
type
AType = array[0..$FF] of byte;

var Ptr : Pointer;

Move(AType(Ptr)[index], dest_word, 2);

So what gave you the idea that the last line is supposed to be C++? Just
that it looked like C++? Where would he get that line from without knowing
what it means if he wants to convert Pascal code to C++?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top