'call' function inside a 'loop for' statement in FISH

I’m trying to run a ‘call’ function to call a different data file inside of a ‘loop for’ statement using FISH. However, when running the function an error that says: “unrecognized word. You cannot create a new symbol except as part of a direct assignment” shows up

The code looks like this:

fish define example_function
    loop for (local i = 1, i < 5, i +=1)
        call 'example.dat'
    endloop
end

It appears FISH is assuming ‘call’ is a variable and not a function. Any advice? Can you not call a ‘.dat’ file with a fish function?

CALL is a command and not a function. So you need to do it like this:

fish define example_function
loop for (local i = 1, i < 5, i +=1)
command
call ‘example.dat’
endcommand
endloop
end

Note that if your file ‘example.dat’ contains a MODEL NEW command, this won’t work, because when you give a NEW command, your fish function will be erased from memory. If you want to do this, you need to use Python.