Keep in mind that the urltask( performs the download in the background, so the file won’t be available immediately.
In older versions of Panorama, functions like loadurl( were actually implemented using curl. But in Panorama X that is no longer true – it uses Apple’s network code. You could use curl if you really wanted to, but I would stick to Panorama’s functions unless you have some really specialized need that only curl can fullfill (doesn’t sound like that is the case in your application).
The field “Photo” contains an URL. The text funnel takes out the last part of the URL (the file name) from the last slash to the last character. Text funnels are well documented in the Pan X Help.
This specifies the folder where you want the file to be saved, but it doesn’t specify the name that should be given to the file. If you want it to have the same name it had on the server, you could write it like this.
but if I use either the text funnel, or urlfilename( formula to name the file in that last example, no file is saved. There isn’t any error message. There just isn’t any result.
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):
local taskid
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.)