ID:169875
 
Something that has stumped me for a while, how do you get the length of a filename if you pull it in as an icon.

Say:

var/icon/I = input("Get the icon") as icon|null


You can get the name of the file by just using << "[I]" and using length gives you the length of file. name also isn't a varible.

Thanks for the help in advance.
OK, I havn't tested this or anything, but try...
length("[I.icon]")

/icon happens to have an 'icon' variable.
In response to Yota (#1)
Thanks, I'll try it when I get home and post an update.

Heh, nope.

runtime error: Cannot read 'H2.dmi'.icon

(makes sense)
from

mob/verb/Test()
var/icon/I = input("Insert the icon") as icon|null
usr << length("[I.icon]")
In response to Yota (#1)
Yota wrote:
OK, I havn't tested this or anything, but try...
length("[I.icon]")

/icon happens to have an 'icon' variable.

But he was asking about an icon file, not an /icon datum. As it is, /icon.icon will not give you a file length because it's an internal structure.

However, if the icon was selected as a file, length(iconfile) should work. If not, then try length(file("[iconfile]")), which should convert everything to the proper format.

Lummox JR
In response to Lummox JR (#3)
I tried those ways and ended up getting the size of the data. I think I didn't say what I needed clearly enough, sorry.

If someone selects a file called "Guy.dmi" I want it to show the length of the file name, being 7.
In response to SSJ2GohanDBGT (#2)
mob/verb
File_Size(F as file)
usr << "[F] is [length(F)] bytes"

Here is your code. this will let you pick the file on your computer and then tell you the size of it in bytes.
In response to Odine (#5)
ID: 345681
In response to Odine (#5)
No it won't
In response to SSJ2GohanDBGT (#6)
SSJ2GohanDBGT wrote:
ID: 345682

Lets all link to the post right about the one you are posting! It's cool! </laughter?>

[link]

-Ryan
In response to Ryne Rekab (#8)
Whoops =)

Fixed.
Doing length("[I]") should work.
In response to Odine (#5)
ok so your wanting the length of the name right? not the file size
In response to Odine (#11)
Yes, exactly.
In response to SSJ2GohanDBGT (#12)
Im trying everything i can think of off the bat. nothin is working
In response to SSJ2GohanDBGT (#4)
SSJ2GohanDBGT wrote:
I tried those ways and ended up getting the size of the data. I think I didn't say what I needed clearly enough, sorry.

If someone selects a file called "Guy.dmi" I want it to show the length of the file name, being 7.

Oh yeah, that's easy.

length("[iconfile]")


Note this will only work for an actual file, not an /icon.

Lummox JR