I figured out the problem here. The urltask( function has a parameter for code to be executed after the download is complete. However, you didn’t need any code, so you didn’t specify any code. Unfortunately, this resulted in an error. You can fix this by adding an empty code parameter, like this (be sure to scroll to the right to see the empty CODE parameter):
taskid = urltask("http://cdip.ucsd.edu/recent/model_images/sb_channel.png","file","~/Desktop/testimage.png","CODE","")
This works perfectly.
I have fixed the bug, so in the next version it will work correctly even if the code parameter is omitted.
I think this is because you were referencing the local variable. The code inside the “CODE” parameter cannot access local variables in this procedure – the code is running later, after the file is downloaded (it could be 30 seconds later if it is a big image), and the original procedure is no longer hanging around. You could, however, use the local variable to generate part of the code.
But in this case, don’t do that, use the “FILE” parameter. Local variables are ok in the “FILE” parameter, because those are evaluated immediately, before the image is downloaded. (To make sure, I just tested, and a local variable does work.)