Skip to content

Commit

Permalink
[samples] fixed Flexvalue sample
Browse files Browse the repository at this point in the history
  • Loading branch information
exilon committed Mar 9, 2020
1 parent a9fa5a8 commit 3be0cf9
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 23 deletions.
22 changes: 0 additions & 22 deletions samples/delphi/QuickValue/QuickValue.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,6 @@ var
arr : TArray<string>;
value : TValue;

function Test(aValue : variant) : string;
var
i : Integer;
serializer : TJsonSerializer;
arr : array of variant;
parr : Pointer;
begin

serializer := TJsonSerializer.Create(TSerializeLevel.slPublicProperty);
if VarIsArray(aValue) then
begin
parr := VarArrayLock(aValue);
var a := VarArrayGet(aValue,[1]);
var b := VarTypeAsText(VarType(a) and VarTypeMask);
SetLength(arr,VarArrayHighBound(aValue,1) + 1);
arr := [aValue];
Result := serializer.ArrayToJson(TValue.FromVariant(aValue));
end;
end;

function Test2(aValue : Pointer) : string;
var
arr : TMyArray;
Expand Down Expand Up @@ -93,8 +73,6 @@ begin

arr := ['item1','item2','item3','item4'];
flexvalue := arr;
var a := Test(arr);
SetLength(arr,0);
arr := TArray<string>(flexvalue.AsPointer);
coutFmt('arr[1]=%s',[arr[1]],etInfo);
ConsoleWaitForEnterKey;
Expand Down
Loading

0 comments on commit 3be0cf9

Please sign in to comment.