Notifications
Clear all

[Closed] Script not loading correctly

Hi there

I have a script that adds functions to the global namespace. Very shortened and in pseudo code style it looks like this:

fn fc1 param1 param2 =
(


if param1 = true
(
– Next line causes error since fc2: undefined at the time of this call
call fc2 s p
)
)

fn fc2 param1 param2 =
(


if param2 = true
(
call fc1
)
)

I have described the error inline in the fc1.

How do I get around this one…? (It is a no-go to change place of the two functions, since sometimes I call fc2 first, sometimes fc1)

3 Replies

HI

Try declaring both functions before you define them with:
(
local fc1, fc2

fn fc1 p1 p2 = (…)
fn fc2 p1 p2 = (…)

– then do the real call to the functions
fc1 true true
)

That did it, thanks.

another way would be to put them in a struct and always call them as member functions of the struct (struct.fn())

i think this may be better for organization anyway