Title: Ask Reuben 29 - Read/Write Variables From/To A File Post by: Reuben B. on May 22, 2020, 08:37:13 am Occasionally you have a requirement to read or write a complex variable from or to a file. This could be during debugging, you want to read a complex variable or perhaps compare it to an earlier value to find the difference. This could be during QA where you want to populate some variables with some known values or again compare the difference with an earlier saved result.
There is a handy little technique you can use that involves JSON and the TEXT datatype to read/write any given variable from/to a file. Use the util.JSON.stringify method to turn a complex variable into a JSON string and write this to file. Going the other way read a file that is a JSON string and parse that into a complex 4gl variable. Read more at https://4js.com/ask-reuben/ig-29/ |