The "internal item number" is normally gotten from a "find" command, like
:local edip [ /ip address get [/ip address find interface=$edinterface ] address ]
or
:local str [/file find name="EveryDNS.$eddomain"];
I use a ":put" command to debug, but it only works when the script is run from the command line. It won't work with the scheduler. Try adding a couple lines like this:
I would put one of these immediately after each of those two statements and run it. See where it displays the "internal item number" error in relation to "made it here".