JS local vars in _global functions are not global
|
08-18-2015 03:31 AM
|
Human being with feelings
|
|
JS local vars in _global functions are not global
local variables in _global functions should persist across calls from different plugin instances
With the following code, I would expect the test function to return a value equal to the number of plugin instances created but in each instance r is assigned a value of 1.
Code:
@init
function Test()
local(calls)
(
calls += 1;
);
r = _global.Test(); // r should equal the number of instances created
|
|
Issue Details
|
Project
Deprecated REAPER issue tracker
Category Arcana
Status Not a Reaper Bug
Priority 5 - Medium
Affected Version 4.78
Closed Version (none)
Yes votes
0
No votes
1
Assigned Users
(none)
Tags
(none)
|
|
08-18-2015 07:43 PM
|
|
Administrator
|
|
|
Try using instance(calls) rather than local(calls) -- local is a purely private variable.
|
08-19-2015 07:47 AM
|
Human being with feelings
|
|
|
Quote:
Originally Posted by Justin
Try using instance(calls) rather than local(calls) -- local is a purely private variable.
|
Okay, thanks for clarifying. I thought if a function was used with the _global namespace the the function local vars would be global too. I can't actually find a reference to the _global namespace in the docs so if it does get documented please add a note about this behaviour. :)
|
All times are GMT -7. The time now is 05:20 AM.