You cannot get file into memory. And you need to compare your ip to something in order to know whether it has changed or not because you would be telling to your ddns service the same ip repeatedly so it will become banning you.
I am comparing the current address, from "/IP cloud current-address", with the last one set, but I'm determining the last one set using ":resolve $hostName" rather than storing it as a global variable. ":resolve" will return the address the dynamic DNS provider has without storing it in the router.
That seems like a more elegant solution to me, but I wonder if there is a reason not to execute a ":resolve" once a minute. Half the scripts determine the current IP by fetching a "what's my IP" type Web page, which would generate much more traffic, so I don't think that's the reason. I know that "/IP cloud" is relatively new, but the current address can still be read from the interface without hitting an external Web site.
As noted, using a global variable will cause the dynamic DNS provider to be hit unnecessarily every time the router is rebooted and the variable lost. This won't happen often, so I don't think it's a problem, but I won't happen if ":resolve" is used to determine the last address sent to them.
As for getting a file into memory, I am doing that with "/file get", but I was hoping there was a way to get the results of a fetch directly into a variable, rather than writing it to a file and then reading that file into a variable, but I don't think "fetch" can work that way; it either writes the results to a file or doesn't return them at all.