

Here is my ServerMethod sample code : TsmOrder = class(TDSServerModule)įunction GetOrder(const AID: Integer): TOrder įunction SetOrder(const AOrder: TOrder): Integer Procedure TOrder.SetNumber(const Value: Variant) Procedure TOrder.SetComment(const Value: Variant) Property Comment: Variant read FComment write SetComment Property Number: Variant read FNumber write SetNumber Procedure SetNumber(const Value: Variant) Procedure SetComment(const Value: Variant) Here is a n example of object I can access anycodings_json via DataSnap : type In such cases, if you're sure of the type a variant contains, you're better off explicitly typecasting it to that type in order to speed up the operation.I have DataSnap Server and I have some anycodings_json server method to Set and Get object with anycodings_json variant fields When multiple variants are used in an expression, there can be much more behind-the-scenes code logic attached to these implicit type coercions. The following code would work just as well: These rules are defined in detail in the Delphi Language Guide.īy the way, in the preceding example, it isn't necessary to typecast the variant to another data type to make the assignment. These results are dictated by certain type-conversion rules applicable to Variant types. I is rounded to the nearest Integer value, in this case: 2.ī := Boolean(V) // B contains True, since V is not equal to 0 D := Double(V) // D contains the value 1.6 S := string(V) // S will contain the string '1.6' Where V is a variable of type Variant, the following expressions will have the following results shown: You can also typecast a variant to that of a simple data type.

Results in a Variant type whose type code corresponds to the result of the expression X, which must be an integer, floating point, currency, string, character, date/time, class, or Boolean type. You can explicitly typecast expressions to type Variant.
