Notifications
Clear all

[Closed] Variable selection count in labels

Hello.
I’m trying to create label with dynamic value of selected objects.

Here is the scirpt:

[i]try(destroydialog Attacher)catch()
(–Rollout
rollout Attacher “Vk tools”
(
group “Selection count” – selection counter
(
label labe1 “value:” across:2
label label2 “button” across:2
)
–function
fn func1 obj =
(
label2.text = selection.count as string
)
on Attacher close do callbacks.removescripts #selectionSetChanged id:#cb1
on Attacher open do
(
callbacks.addScript #selectionSetChanged “Attacher.func1 $” id:#cb1
label2.text = (selection).count as string
)
)
createdialog Attacher
)

[/i]But it prints me error about fn is indefined.
How can i fix this problem or how to create proper function with dynamic count label?
Tnx.

6 Replies

Your rollout definition is enclosed in local scope (which also means that the try(destroydialog Attacher)catch() line will never destroy the dialog), remove the brackets/make it global.

Ok…
If i’ll make a macroscript in this case?
Look like a:

macroScript Attacher category:”#Test
(
try(destroydialog Attacher)catch()
–Rollout
rollout Attacher “Vk tools”
(
group “Selection count” – selection counter
(
label labe1 “value:” across:2
label label2 “button” across:2
)
–function
fn func1 obj =
(
label2.text = selection.count as string
)
on Attacher close do callbacks.removescripts #selectionSetChanged id:#cb1
on Attacher open do
(
callbacks.addScript #selectionSetChanged “Attacher.func1 $” id:#cb1
label2.text = (selection).count as string
)
)
createdialog Attacher
)

It still not working propper.Removing brackets won’t do anything good.
I readed somewhere, what i need to make a global fn, but i don’t know how.

make your rollout global


...
global Attacher
try(destroydialog ::Attacher)catch()
...

It works fine without macroscript line.
But how to create script with global in macro brackets?


Спасибо.
Без строчки макро работает, но как поместить скрипт в макро с глобальным параметром?

Works fine for me with and without macro line.

It works!
Tnx a lot.

Спасибо, заработало.