Posted: Tue Feb 15, 2022 6:04 pm Post subject: Is there a global storage where I can save large Strings?
I wrote a Lua block in a code injection script which parses a JSON file ( contains some configuration) from Disk and then it does update values, depending on some pointer data and the config.
It's working great but I dislike its loading the file each time the code is triggered. So I wondered if there is a way to store the JSON string somehow and only load the file, if the JSON string is not stored yet.
I noticed there is a method
[code]
writeStringLocal
[/code]
But I didn't quite understand if this is meant for my use case? Can I use this method for storing big strings?
Also I did not understand how this address thing works. Is it safe to write to any address like [code]writeStringLocal("00400500", JsonString)[/code] or could this memory address be in use already?
Joined: 25 Jan 2006 Posts: 8581 Location: 127.0.0.1
Posted: Tue Feb 15, 2022 8:31 pm Post subject:
Just read the file into a local variable and check that variable if it's got any data anytime you need to use the information. If not, then reload, if yes, then use what's already loaded. _________________
Just read the file into a local variable and check that variable if it's got any data anytime you need to use the information. If not, then reload, if yes, then use what's already loaded.
You're right...
I didn't knew non-local variables are surviving when defined in a Lua code block.
I thought they'd reset after the code Injection returned.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum