client
verb
compress(code as message)
src<<browse(html_encode(Compress(code)),"window=compress")
proc/Compress(code,indentation="\t")
var/tablevel=1
var/compressed
var/h="h" //Tried
if(findtext(code,"\t[h]"))
world<<"found"
code=SwapText(code,"\t[h]","\t\ h") //to fix.
var/list/lines=SeparateLines(code)
lines+="\n"
for(var/v in lines)
var/tabs=1
for(tabs,copytext(v,tabs,tabs+length(indentation))==indentation,tabs++)
v=copytext(v,tabs)
if(tabs==tablevel)
if(v!=lines[1])
v=";[v]"
while(tabs<tablevel)
v="}[v]"
tablevel--
while(tabs>tablevel)
v="{[v]"
tablevel++
compressed+=v
sleep()
return compressed
proc/SeparateLines(txt)
var/list/L=new
while(findtext(txt,"\n"))
if(copytext(txt,1,findtext(txt,"\n"))) //"\t\th" appears to get lost here.
L+=copytext(txt,1,findtext(txt,"\n"))
txt=copytext(txt,findtext(txt,"\n")+1)
if(txt) L+=txt
return L
If the indentation is off, it's a mistake I made when converting the tabs to spaces for the forum(I don't like horizontal scolling). Any help would be appreciated.
-YMIStillNotGettingThis