xsharp.eu • VO2740: BYTE PTR minus BYTE PTR data type?
Page 1 of 1

VO2740: BYTE PTR minus BYTE PTR data type?

Posted: Fri Nov 19, 2021 8:49 am
by kitz
Hello,
I use a BYTE PTR set to the beginning of a PSZ and another moving to the end.
So according to the Programmers Guide of 2.7 the subtraction end pointer minus begin pointer should give the byte count-1
I tried

Code: Select all

LOCAL pAnf, pEnd as BYTE PTR
LOCAL dwLen as DWORD
...
dwLen := pEnd - pAnf
But I get errors
converting PTR <-> DWORD: 51423
illegal automatic conversion to DWORD: 51521
Same happens with INT and LONGINT (similar errors of course)
Any hints?
BR Kurt

VO2740: BYTE PTR minus BYTE PTR data type?

Posted: Fri Nov 19, 2021 9:31 am
by Chris
Hi Kurt,

You can use

dwLen := (DWORD)pEnd - (DWORD)pAnf

but usually there's a better way of doing things in .Net than using pointers. What does the code do?

VO2740: BYTE PTR minus BYTE PTR data type?

Posted: Fri Nov 19, 2021 9:46 am
by kitz
Chris,
unfortunately that doesn't work:
bad statement syntax: 51402
This is in VO 2740, so no .net

I have strings with mixed ( !! ) Windows1252 and UTF-8 character set and try to distinguish ANSII >127 and valid UTF-8 codes to be able to partially convert UTF-8 to Windows1252 to have all on the same character set. Cleaning up mess...
I scan the PSZ-String using dereferenced pointers byte per byte.
BR Kurt

VO2740: BYTE PTR minus BYTE PTR data type?

Posted: Fri Nov 19, 2021 9:59 am
by Meinhard
Try
dwLen :=DWORD(_CAST, pEnd - pAnf)

Regards
Meinhard

VO2740: BYTE PTR minus BYTE PTR data type?

Posted: Fri Nov 19, 2021 5:14 pm
by kitz
Hello Meinhard,
that worked!
Thanks, Kurt