TMapAccess.maReadWrite not defined using DELPHI 11 - delphi

the code fragment below works fine for DELPHI 10.4 and FMX framework, but does not compile using DELPHI 11 . Error : maReadWrite not defined
[dcc64 Error] ImageUnit.FMX.pas(5340): E2003 Undeclared identifier: 'maReadWrite'
How to solve this issue and how to write code which compiles using DELPHI 10.4 and DELPHI 11 ?
var bit : TBitmap;
begin
if (Bit.Map(TMapAccess.maReadWrite, bitdata1)) then
try
for i := 0 to Bit.width - 1 do
for j := 0 to Bit.height - 1 do
begin

The TMapAccess values that begin with the ma prefix were deprecated before 10.4 to drop the prefix (ie maRead -> Read, maWrite -> Write, maReadWrite -> ReadWrite). You should have gotten compiler warnings about this in 10.4.
The prefixed values were finally removed completely in 11.0 Alexandria.
So, the correct way to write this code for both versions is to simply use the newer non-prefixed value names, eg:
if (Bit.Map(TMapAccess.ReadWrite, bitdata1)) then

Related

Indy/ssl cannot open file

I'm trying to use ssl with Indy and keep getting the following error:
Project MtApp.exe raised exception class EFOpenError with message 'Cannot open file "C:\Development\MyApp\Win64\Debug\㩃䑜癥汥灯敭瑮作浡牡屵汁呬楨杮即獹潬屧祓䱳杯楓屭祓䱳杯楓䍭湯潳敬坜湩㐶䑜扥杵浜剹潯䍴⹁数m". The system cannot find the file specified'.
It occurs in the IdSSLOpenSSL.pas file in the following function:
function by_Indy_unicode_file_ctrl(ctx: PX509_LOOKUP; cmd: TIdC_INT; const argc: PAnsiChar; argl: TIdC_LONG; out ret: PAnsiChar): TIdC_INT; cdecl;
The argc parameter appears to be passed in correctly. The IDE debugger shows it as "C:\Development\MyApp\Win64\Debug\myRootCA.pem". The problem seems to be when it is cast as a PWideChar and assigned to a String variable:
X509_FILETYPE_PEM:
begin
// Note that typecasting an AnsiChar as a WideChar is normally a crazy
// thing to do. The thing is that the OpenSSL API is based on ASCII or
// UTF8, not Unicode and we are writing this just for Unicode filenames.
LFileName := PWideChar(argc);
LOk := Ord(Indy_unicode_X509_load_cert_crl_file(ctx, LFileName, X509_FILETYPE_PEM) <> 0);
end;
The LFileName variable is 㩃䑜癥汥灯敭瑮作浡牡屵汁呬楨杮即獹潬屧祓䱳杯楓屭祓䱳杯楓䍭湯潳敬坜湩㐶䑜扥杵浜剹潯䍴⹁数m after the cast, causing a FileNotFound exception.
What am I doing wrong?
You did not say which version of Delphi or Indy you are using. But, the code you have shown is not the latest code that is currently in Indy.
What you have described was due to a regression bug that Embarcadero introduced in the Indy release that shipped in RAD Studio 10.3. They fixed that in a patch for RAD Studio 10.3.3:
https://blogs.embarcadero.com/rad-studio-10-3-3-indy-server-ssl-certificate-patch/
https://cc.embarcadero.com/item/30906
I suggest you update to the latest version of Indy from its GitHub repo:
https://github.com/IndySockets/Indy/
https://github.com/IndySockets/Indy/wiki/Updating-Indy

Indy TIdHashMessageDigest5 HashStringAsHex compile time error: Undeclared identifier: 'HashStringAsHex'

Using: D7
uses SysUtils, StrUtils, IdHash, IdHashMessageDigest;
..
var
idmd5: TIdHashMessageDigest5;
h, v: string;
begin
idmd5 := TIdHashMessageDigest5.Create;
try
h := idmd5.HashStringAsHex(v);
finally
idmd5.Free;
end;
I have this code which was compiling and running fine earlier in Delphi 7, with the bundled version of Indy. After I upgraded the Indy to the latest version (v10), I am getting the compile time error:
[Error] xxxx.pas(71): Undeclared identifier: 'HashStringAsHex'
Please help!
Additional:
I've solved it by changing
h := idmd5.HashStringAsHex(v);
to:
h := idmd5.AsHex(idmd5.HashValue(v));
However, the above code was in a package (custom component). In my main app, the same corrected code still throws the undeclared identifier when compiling.
This is really confusing now! How can the same code compile in one project, but throw a compile time error in another?!
Update
I've solved it. The component package was using the old Indy library. After removing that reference and updating the source to include the v10 libraries, it now works.

Using BDE API (BdiCopyTable) with Delphi 10.1 Berlin

The following code compiles and workes using Delphi 5 but not using Delphi 10.1 Berlin;
function CopyTable(const tSource: TwwTable; const Destination: string): DBIResult;
var
pSourceTableName, pDestination: array[0..DBIMAXTBLNAMELEN] of char;
begin
tSource.Open;
StrPCopy(pSourceTableName, tSource.TableName);
StrPCopy(pDestination, Destination);
Result := DbiCopyTable(tSource.DBHandle, False, pSourceTableName, nil, pDestination);
tSource.Close;
end;
Compiler reports [dcc32 Error] SUPPORT1.PAS(3655): E2010 Incompatible types: 'PAnsiChar' and 'array[0..260] of Char' twice.
How do I change it such that it compiles clean and works as intended?
NB. I cannot scrap the BDE at this stage of a large migration.
DbiCopyTable expects AnsiChar, so you should declare both char arrays accordingly.

FMX.Grid.TColumn.CellControlByRow function

I tried to compile file FMXTee.Chart.Grid.pas from TeeChart 9 for XE10 that used CellControlByRow function in FMX.Grid.pas for the following code :
with TColumnAccess(Columns[Col]).CellControlByRow(Row).BoundsRect.BottomRight do begin ... end;
I get running well when using RAD XE10 Seattle, and now I tried with RAD XE10.1 Berlin but get error message : [dcc32 Error] FMXTee.Chart.Grid.pas(1507): E2003 Undeclared identifier: 'CellControlByRow'
Then I compare file FMX.Grid.pas from XE10 packages versus FMX.Grid.pas from XE10.1 packages, and there are a lot of differences especially CellControlByRow() function does not exist any more in FMX.Grid.pas from XE10.1.
Now, I want ask how to change the code that use CellControlByRow function so it will run in RAD XE10.1 Berlin ?
I would like suggest you replace the code below:
result:=TColumnAccess(Columns[Col]).CellControlByRow(Row).BoundsRect.BottomRight;
For next :
...
var tmp : TFmxObject;
begin
tmp:=TColumnAccess(Columns[Col]).CellControl;
result:=TControl(tmp).BoundsRect.BottomRight
...
The above code should fix the compilation problem you’re experiencing. Could you confirm that?

Delphi XE2 static array assignment different on MacOS and Windows

I'm currently updating some existing Delphi code to compile on MacOS using Delphi XE2.
The Delphi XE2 Update 3 is installed.
On Win32 and Win64 a particular bit of the code works as expected and it also compiles/runs as expected when compiling with Delphi 4 all the way up to Delphi XE.
However, when compiling for MacOS the same piece of code doesn't work the same way. We've also had some crashes on the Mac - but that might have been the XE2 debugger.
type
TFixedSizeAnsiStringArray = array[0..255] of AnsiString;
procedure TForm1.Button1Click(Sender: TObject);
var
FirstArray: TFixedSizeAnsiStringArray;
SecondArray: TFixedSizeAnsiStringArray;
begin
FirstArray[0] := 'Apple';
FirstArray[1] := 'Banana';
FirstArray[2] := 'Pineapple';
// ...
SecondArray := FirstArray;
Memo1.Lines.Add(SecondArray[0]);
Memo1.Lines.Add(SecondArray[1]);
// ....
end;
On Windows, all the elements of SecondArray are the same as the elements of FirstArray.
But on MacOS (when it does run) only the first element of SecondArray has the correct value.
It's easy to fix with a for loop - but understanding why it's different between Windows and MacOS would be good to know.
Maybe something to do with the use of AnsiString?
That would appear to be a bug in the Mac OS compiler. Please can you submit a report to Quality Central.

Resources