Why step function doesn't recognise local model initialisation inside a function?

Here is my function where I try to run ABM model inside a function. Now inside this function when I initialise model it works and also prints model but while using step!() it says model is not defined. Can someone shed light? why step!() not recognising model defined inside function ? @Datseris

### No global initialisation of model 

function runn(i)
    
    model =  random_model()              # model definition
    println(model)                                  # prints perfectly

    step!(model, step_point)   # I get error here ---- model not defined 

end


for i in 1:4

    runn(i)

end

Output:

ERROR: UndefVarError: `model` not defined

Please refer to my comment here:

1 Like

See Please read: make it easier to help you , especially the point about making a minimal working example. What’s random_model()?

p.s.: Please don’t tag me to your posts. I do not know you on a personal level and tagging someone happens on an individual level.

1 Like

ohh …sorry :sweat_smile: I didn’t know we can’t tag package developers. I will try to make a MWE and post here. :slight_smile: