As I understand, making a Var object persist implies it will be available after a fresh Opus start.
For a script, I am using:
// Cache the query's command and its collection name.
DOpus.Vars.Set(safe_coll_name, find_cmd);
// Make it persist.
DOpus.Vars(safe_coll_name).persist = true;
The named variables are strings.
This topic seems to confirm that I have the right idea about this topic, yet my variables don't persist. Any suggestions of solutions to try?
I also tried Script.Vars instead of DOpus.Vars. Same result. Do both support persistence?
I have another related but different question. The documentation says:
You can store any type of variable in a Var object, although not all types can be saved to disk. If you want your variable to be persistent you should only use bool, int, string, date, currency or a Vector of those types.
Does the persist functionality support a Vector with 'Vectors with strings'?
Directory Opus Pro 12.7.2 (Beta) Build 6615 x64
OS 10.0 (B:16299 P:2 T:1) SP 0.0
The code in your post looks correct, so the problem is probably in some of the code you aren't showing us. My guess is that safe_coll_name or find_cmd are not strings or not the correct strings for what you're doing.
Here is a simple, standalone example:
var varName = "MyVariableName";
if (DOpus.Vars.Exists(varName)) {
var varValue1 = DOpus.Vars.Get(varName);
DOpus.Output(varName + " = " + varValue1);
}
else {
DOpus.Output(varName + " does not exist yet.");
}
var varValue2 = "My Variable Value";
DOpus.Vars.Set(varName, varValue2);
DOpus.Vars(varName).persist = true;
The first time you run that, it will say the variable does not exist. Run it again and it should report the variable has value "My Variable Value". Exit and restart Opus and it should do the same.
@andersonnnunes I plugged a very slightly modified version of your code into a simple user command wrapper then ran it twice and the output looks okay...