Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: D10, TextMagic API


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Jim Sawyer

Posts: 214
Registered: 1/3/10
D10, TextMagic API  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 31, 2018 9:08 AM
I am trying to incorporate TextMagic into a program to use for bulk testing. The TextMagic
Delphi wrapper was written for XE7 I think and gives the following errors when used with
Delphi 10.2 Tokyo. I feel sure that for people a bit smarter than I am, upgrading the code
would not be a problem. The problem code and the errors are following. I would very
much appreciate someone telling what changes need to be made.

The TextMagic wrapper gives the following errors in Delphi 10.2.

function SA(const Args: array of const): ISuperArray;
var
  I: Integer;
  SArray: ISuperArray;
  SObject: ISuperObject;
begin
  Result := TSuperArray.Create;
  for I := 0 to High(Args) do
      case PVarRec(@Args[I]).VType of
          vtInteger : Result.Add(TJSONInteger.Create(PVarRec(@Args[I]).VInteger));
          vtInt64   : Result.Add(TJSONInteger.Create(PVarRec(@Args[I]).VInt64^));
          vtBoolean : Result.Add(TJSONBoolean.Create(PVarRec(@Args[I]).VBoolean));
          {$IFNDEF NEXTGEN}
          vtChar    : Result.Add(TJSONString.Create(PVarRec(@Args[I]).VChar));
          vtString  : Result.Add(TJSONString.Create(PVarRec(@Args[I]).VString^));
          vtPChar   : Result.Add(TJSONString.Create(PVarRec(@Args[I]).VPChar^));
          vtAnsiString: Result.Add(TJSONString.Create(AnsiString(PVarRec(@Args[I]).VAnsiString)));
          {$ENDIF}
          vtWideChar: Result.Add(TJSONString.Create(PVarRec(@Args[I]).VWideChar));
          vtExtended: Result.Add(TJSONFloat.Create(PVarRec(@Args[I]).VExtended^));
          vtCurrency: Result.Add(TJSONFloat.Create(PVarRec(@Args[I]).VCurrency^));
          vtWideString: Result.Add(TJSONString.Create(PWideChar(PVarRec(@Args[I]).VWideString)));
          vtUnicodeString: Result.Add(TJSONString.Create(String(PVarRec(@Args[I]).VUnicodeString)));
          vtInterface:
            if PVarRec(@Args[I]).VInterface = nil then
               Result.Add(TJSONNull.Create(False))
            else if IInterface(PVarRec(@Args[I]).VInterface).QueryInterface(ISuperObject, SObject) = 0 then
                Result.Add(SObject)
            else if IInterface(PVarRec(@Args[I]).VInterface).QueryInterface(ISuperArray, SArray) = 0 then
                Result.Add(SArray)
            else
                Assert(False);
          vtPointer :
            if PVarRec(@Args[I]).VPointer = nil then
               Result.Add(TJSONNull.Create(False))
            else
               Result.Add(TJSONInteger.Create(PtrInt(PVarRec(@Args[I]).VPointer)));
          vtVariant:
            Result.Add(PVarRec(@Args[I]).VVariant^);
          vtObject:
            if PVarRec(@Args[I]).VPointer = nil then
               Result.Add(TJSONNull.Create(False))
            else
               Result.Add(TJSONInteger.Create(PtrInt(PVarRec(@Args[I]).VPointer)));
          vtClass:
            if PVarRec(@Args[I]).VPointer = nil then
               Result.Add(TJSONNull.Create(False))
            else
               Result.Add(TJSONInteger.Create(PtrInt(PVarRec(@Args[I]).VPointer)));
          else
            Assert(false);
      end;
end;


Line
vtChar : Result.Add(TJSONString.Create(PVarRec(@Args[I]).VChar));
has error
W1057 Implicit string cast from 'AnsiChar' to 'string'

line
vtString : Result.Add(TJSONString.Create(PVarRec(@Args[I]).VString^));
has error
W1057 Implicit string cast from 'ShortString' to 'string'

line
vtPChar : Result.Add(TJSONString.Create(PVarRec(@Args[I]).VPChar^));
has error
W1057 Implicit string cast from 'AnsiChar' to 'string'

line
vtAnsiString: Result.Add(TJSONString.Create(AnsiString(PVarRec(@Args[I]).VAnsiString)));
has error
W1057 Implicit string cast from 'AnsiString' to 'string'

and the code

class destructor TJSONDateManager.Destroy;
var
  I: Integer;
begin
  if Assigned(FFormats) then
  begin
    for I := 0 to FFormats.Count - 1 do
        FFormats[I]._Release;
    FFormats.Free;
  end;
end;


the line
FFormats[I]._Release;
has error
Not enough Actual Parameters.

If someone smarter than I could direct me on how to correct these wrapper
errors, I will be forever grateful.

Thanks,
Jim Sawyer
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02