Page 1 of 1
Using Global Arrays
Posted: 30 Apr 2025, 16:05
by woodslanding
I am having a problem with global arrays. The most recent such array I used is not being recognized after restarting the app and loading the wkp.
Before filing a bug report, I want to make sure there isn't something I'm forgetting about.
Should the following situation be possible?? Can you create a GA and name it, and have it not show up in the GA list?
Let me know, thanks.
I am using the October version of Usine, until such time as I have a reason to buy a new license. If this is a known issue that has been fixed, let me know.
Re: Using Global Arrays
Posted: 30 Apr 2025, 16:16
by woodslanding
I may be in a catch-22 here. If I try to remove or rename the non-functioning GA, I get this error:
[1408] Error :
PROC:globalArrayRemoveClient
ERROR:Access violation at address 0000000000523CEB in module 'Usine.exe'. Read of address
FFFFFFFFFFFFFFFF
Maybe this prevents the wkp from saving correctly?
This GA is referenced in multiple scripts, so every time I start up, it creates Access violation errors, because the array is not found. Maybe that is why it doesn't save correctly. I'll search and see if there is a test for the existence of a global array that I can put in the scripts. Maybe then the wkp can save correctly.
EDIT: if there is a test for the existence of a GA, it is not in the docs....
Re: Using Global Arrays
Posted: 30 Apr 2025, 16:22
by woodslanding
Okay, removing the lines referring to the GA from the scripts cured the problem.
So an actual patching question:
How can I let the script know when the GA is actually operational so I can read and write to it?
Re: Using Global Arrays
Posted: 30 Apr 2025, 17:03
by woodslanding
Okay, if I mis-name the GA, it is properly created! Usine doesn't have a problem with the script trying to access a non-existent array. (Although it does throw an error, it is not an access violation). But if I try to access an existing array too early, it causes an access violation.
I solved this by creating an initializedIN tparameter in the script that references the array, and attaching it to an ON INIT module. I don't run any callbacks until I get the trigger from INIT. Now everything loads and starts up without errors.
Seems like scripts should wait for their patch to be initialized before running callbacks, but I guess they do not.
Hopefully this thread is helpful to someone else.
cheers,
-e
Re: Using Global Arrays
Posted: 30 Apr 2025, 17:46
by oli_lab
Hi,
there could be only one instance of Global array creation, maybe you create the same array in different scripts ?
cheers
Olivar
Re: Using Global Arrays
Posted: 01 May 2025, 10:19
by SylvainT
Hi,
Global Arrays are working really fine. It is one of the strongest features in Usine from these last years to have fast and strong access to data everywhere and communicate with shared Usines.
Only one Global Array definition can exist since it is accessible from everywhere in the workspace.
Global Arrays can have a variable length. You can create a GA with a size of 0 but still enter values. But, if you want to access it with script, you need to define a size at creation.
To access it with script, the GA should have a name written with alt-click on the module itself. Can be the same name, but this is its reference name for scripting.
When loading the wkp, Usine starts with rack 1 until the last one. Everytime a rack is loaded, it is immediately initialized. That means, GA declaration must be loaded before a script that used it to avoid errors.
Best
Sylvain
Re: Using Global Arrays
Posted: 24 May 2025, 18:33
by woodslanding
Thanks that is very helpful. All my GA's are in track 1, but so are most of the scripts!