[Closed] Nested Functions and Rollouts
I have a very similar problem to an earlier poster.
I have a structure that is something like this.
I have several subrollouts and in one subrollout a I have a few functions that I want to call. However, if I declare the function globally it tries to find UI items which aren’t created when I need to declare the function. It’s a sort of chicken/egg scenario though because they’re called in the rollouts which need to be declared before the function.
So if I put the function above the rollout the function complains the rollout doesn’t exist.
If I put the rollout above the function the rollout complains the function doesn’t exist.
I can duplicate the functions into several rollouts and execute them locally but that’s kind of sloppy. What’s the solution?
Hi,
hard to tell without seeing the code.
do you mean you rollouts are defined in a stuct ?
you might want to enclose all your code in a local scope,
and declare fns and/or rollouts as local at the start:
( – Start of script
local fn1, fn2, rol1, rol2
fn fn1 =()
rollout rol1 “” ()
fn fn2 =()
rollout rol2 “” ()
) – End of Script
[color=white]A script is worth a million words:
[/color]
Global stuff = #("There is a Variety 1234","There is a lack of Virtuosity 1234", "Captain Picard says \"Make it so\"!", "Test Data", "123456789", "Search your feelings Luke!", "Engage")
insertitem "" stuff 1
fn searchbox input =
(
if searchboxroll.data.text.count > 0 then
(
list = #()
list[1] = input
temp = input
temp = (input+"*") as string
for i = 1 to stuff.count do
(
test = (matchpattern stuff[i] pattern:temp) as string
if test == "true" then (append list stuff[i])
)
sort list
searchboxroll.stuffbox.items = list
searchboxroll.stuffbox.selection = 1
)
else
(
searchboxroll.stuffbox.items = stuff
)
)
rollout searchboxroll "Search and be Amazed!" height:160 width:250
(
edittext data width:210 pos:[6,33]
combobox stuffbox "Things:" items:stuff height:8 pos:[9,15]
on data changed true do
(
searchbox data.text
)
)
createdialog searchboxroll