ID:1071545
 
BYOND Version:498
Operating System:Windows 7 Pro 64-bit
Web Browser:Chrome 23.0.1271.95
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
The following code will never execute the commented line.

mob
Login()
..()
var/file = input("choose file") as null|icon
if(!file)
alert("file is null")
del(src)
var/icon/ic = icon(file)
//do stuff with ic, or nothing, doesn't matter
src << ftp(ic, "[file].dmi") //this line won't happen.
sleep(1)
del(src)


I would expect that ftp() doesn't actually return until finished, but it returns immediately and then del(src) is called 100 ms later and the FTP dialog is never shown.
I imagine that is because ftp() is output to its targets, allowing you to send a file to all players in the world if you wanted to. If it were blocking, it would have to block until each target finished downloading the file. There's also no return value that's necessary to wait for like input() or alert().

If it were blocking, I think most people would end up spawn()ing it anyways, which makes me question how valuable such a feature would be.
Any idea on how to realize its done? I guess you could while() until the file exists?
Well, you have no way of knowing where they save the file, so you can't test for its existence. I can't find any way to interact with the FTP dialog, so I don't think you can.

If this tool isn't meant to be hosted, you might be better off just saving the file in a "output" directory instead of ftp()ing it to them:
var/file = input("choose file") as null|icon
var/icon/I = icon(file)
I.Blend(rgb(255,0,0), ICON_MULTIPLY)
var/dest = "output/[file]"
fcopy(I, dest)
alert("File saved to [dest]")
del(src)


If they're processing a lot of icons, it might actually be faster (well, not if you kick them after each one)