GETTING VARIABLE AWAY FROM EXPRESSION

Maybe this is laughable question however I can't handle with this one.
How to get variable "lInst" outside this code so I could use it in different place of code or diffrent script. Now when I check value of "lInst" inside this expression is different then outside. I tried with return as function and still nothing.
This is my code which search for missing plugins:
(
local t = stringstream ""
apropos "*missing*" to:t
t = t as string
local l = filterstring t "\n "
local lMissingClasses = #()
for t in l do
(
if matchpattern t pattern:"missing*" then
(
local cls = execute t
if matchpattern (cls as string) pattern:"missing*" then
(
global lInst = getclassinstances cls
----->VARIABLE I WANT TO GET VALUE FROM HERE IS: lInst
)
)
)
)

----->I WANT HAVE VALUE OF VARIABLE lInst HERE(outside expression above)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kredka's picture

still nothing, won't work

still nothing, won't work

miauu's picture

.

(
	(
		local t = stringstream ""
		global lInst
		apropos "*missing*" to:t
		t = t as string
		local l = filterstring t "\n "
		local lMissingClasses = #()
		for t in l do
		(
			if matchpattern t pattern:"missing*" then
			(
				local cls = execute t
				if matchpattern (cls as string) pattern:"missing*" then
				(
					lInst = getclassinstances cls
 
				----->VARIABLE I WANT TO GET VALUE FROM HERE IS: lInst
				)
			)
		)
	)
	format "lInst: % \n" lInst

Execute the code. The value of lInst will be printed in the listener. Then open maxscript listener, type lInst and press the numpad Enter.
I don't have missing plugins, so the value is always an epmty array.

barigazy's picture

...

U already declared your variable as global.
Maybe is better to put it above

(
global llnst = #()
local t = stringstream ""
--. . . rest of the code
)

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.