1

In a VCL application in Delphi 10.1.2, I use a TJvFormStorage component to persistently store and restore data.

So in JvFormStorage1 at design-time I have created a StoredValue to hold an Integer value:

enter image description here

Then at runtime, I try to assign an Integer value to this StoredValue:

JvFormStorage1.StoredValue['ToolbarLabelFontSize'].Value := 8;

This causes an Invalid variant operation error!

But as you can see from the screenshot above, the Value Type of the StoredValue is explicitly defined as Integer type!

So how can I assign an Integer value to this StoredValue?

user1580348
  • 5,721
  • 4
  • 43
  • 105
  • 1
    I don't use JEDI myself, so I can't test, but try the following. Since `JvFormStorage1.StoredValue['ToolbarLabelFontSize']` is a `variant` as such, remove the `.Value` you now have there. – Tom Brunberg Aug 07 '17 at 00:01

1 Answers1

2

The StoredValue[] property provides access to the variant values directly, so the correct way to set the value of one of these values would be:

JvFormStorage1.StoredValue['ToolbarLabelFontSize'] := 8;
Deltics
  • 22,162
  • 2
  • 42
  • 70
  • I followed your advice and now there is no more error message. But instead of **8** it stores the value of **71** in the XML file: `71`!! But when RESTORING it gets again **8** with `Integer(JvFormStorage1.StoredValue['ToolbarLabelFontSize']))`?? How are the values **8** and **71** transformed into each other? – user1580348 Aug 07 '17 at 06:01
  • To answer my previous comment, it seems that not the `Integer` value is stored in the XML file but the `Variant` value is stored in the XML file. – user1580348 Aug 07 '17 at 06:44