Recipe handling with mod_dat

Hi @Torsten_K ,

thanks to @Samuel I found the libary now :wink:
I can’t check the source or functionality since the origin project on the library base is an AS2.5.x project, and I don’t have a suitable installation available right now.

But from what I see in the documentation (pls. see screenshot below), it doesn’t seems that a functionality to ā€œserialize the data directly into a stringā€ is implemented.
So I think, the best approach to follow could be:

  • check if the recipe file data size is suitable to be stored inside a string variable (like described by @michael.bertsch )
  • if yes, you could try to
    • 1.) use the dat_mod library as intended by creating a file export
    • 2.) use FileIO functions ā€œFileOpen, FileRead, FileCloseā€ to read the exported file content into the string variable
    • 3.) delete the export file via dat_mod functions to keep the database up-to-date

Last but not least here’s a ā€œsmall life hackā€ about string sizes, that I used here and there:

if you declare an array of strings, the whole array size is on block inside the memory.
So if you memcpy() string data to the first string element, where data is longer then one array element size, because of the overflow of the first string element the rest of the string data will be copied into the 2nd element, and so on…

… of course this is no ā€œnice programmingā€, and you still have to take care that the data size is not greater then the complete array memory to avoid page paults or other issues.
But sometimes using such overflow can be even useful: for example I used string arrays to make my whole string data available via Automation Studio Watch.
As the size of string data in the watch is limited to 80 characters, using a string array of element size 80 and memcpying the longer string to this string array makes it possible to watch more string content :wink:

Best regards!