Solved SalXMLDeserializeUDVFromString issue

Discussion forum about all things Gupta, OpenText and the community.
klaushaidinger
Austria
Posts: 120
Joined: 13 Dec 2017, 06:08
Location: Austria

SalXMLDeserializeUDVFromString issue

Post by klaushaidinger » 05 Aug 2023, 16:24

I am observing a very strange behavior with the SalXMLDeserializeUDVFromString (and the same with SalXMLDeserializeUDV) function.

Short explanation: I read a XML string with settings from a central database and deserialize it into a UDV already filled with local settings (e.g. printer). Before I do that, I have to save some values from the already filled UDV and after deserialization I have to fill them again with these values, because they only work on this workstation (as already mentioned e.g. printer).

1) So, first save the (local) printer settings from the UDV:
Set sSave = settings.sPrinterName -> e.g. HP OfficeJet

2.) Then deserialize into the same UDV.
Call SalXMLDeserializeUDVFromString( 'settings', lsSettings)
In my case the sPrinterName (in the XML string) contains the value "no Printer".

After deserializing - and here it comes: sSave also contains the value "no Printer" and no longer the previously saved value.

Does anyone have an idea what this could be due to or offer a workaround for this?
Thanks for your help!
Klaus

thomas.uttendorfer
Site Admin
Site Admin
Germany
Posts: 295
Joined: 05 Mar 2017, 17:19
Location: Munich Germany

Re: SalXMLDeserializeUDVFromString issue

Post by thomas.uttendorfer » 07 Aug 2023, 12:12

Hi Klaus,
when setting

Code: Select all

sSave = settings.sPrinterName
TD does not copy the string.
sSave and settings.sPrinterName point to the same string.
This is normal behaviour. It's somewhere documented and helps saving memory.
When you afterwards set

Code: Select all

settings.sPrinterName = ''
then usually TD makes a dereferentiation. settings.sPrinterName gets a new pointer with fresh memory.

So there seems to be a bug in TDs SalXMLDeserializeUDVFromString(..) because they ignore the dereferentiation.
I think you can workaround this issue if you do it this way:

Code: Select all

Set sSave = settings.sPrinterName ! e.g. HP OfficeJet
Set settings.sPrinterName = ''
Call SalXMLDeserializeUDVFromString(..)
(not tested but I think should work).
Regards Thomas
Thomas Uttendorfer
[ frevel & fey ] Software-System GmbH
https://thomasuttendorfer.wordpress.com/

klaushaidinger
Austria
Posts: 120
Joined: 13 Dec 2017, 06:08
Location: Austria

Re: SalXMLDeserializeUDVFromString issue

Post by klaushaidinger » 07 Aug 2023, 13:55

Thank you Thomas, you made my day!
Your workaround works :-)
Kind regards, Klaus!

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests