GenerateCSicon(var/icon/I, var/Iname)
icon/CSicon = new("[Iname]")
CSicon.Insert(I, "CS", SOUTH, 1, 0, null)

That is what I'm trying right now, but it doesn't create a new .dmi.
I'm wanting it to create a new icon with the name "[Iname]", then insert an icon_state.
I want to be able to access this icon later in Dream Maker.

I know I can use ftp() to send it to myself and save it manually, but its tedious with 124 icons to do this to.

Edit: I didn't consider this a code problem considering I'm not even sure if this is how to do it. That is my question: How to dynamically create and save a .dmi file.
You can always try fcopy() which won't prompt you to save it manually.
In response to tenkuu
GenerateCSicon(var/icon/I, var/iname)
icon/CSicon = new("[iname]")
CSicon.Insert(I, "CS", SOUTH, 1, 0, null)
fcopy(CSicon, "CS/[iname]")

Thanks a lot, this works =D.
I can't believe how easy that was after searching the forums, asking on chatters, and looking through the ref. Guess I didn't know where to look in the ref lol.
In response to KetchupKid
If XxDohxX's Paint were still being worked on, would this be incorporable then? To dynamically create an icon out of your painted creation?
In response to CauTi0N
Yes, it would be possible, and not particularly difficult. You can even stick .png on the end of the file name.
In response to DarkCampainger
Well, yes, essentially because .dmi and .png are nearly identical. Oh I have an idea :)