//调用zlip压缩解压缩 

zlib = ..raw.loadDll($"\zlibwapi.dll") //静态编译DLL(发布后不需要原DLL文件)
compress = zlib.api("compress","int(string& dest,INT& destLen,string src,int srcLen)")
uncompress = zlib.api("uncompress","int(string& dest,INT& destLen,string src,int srcLen)")

//压缩
zip = function(str){
	bufferLen = #str *1.001 + 12 
	var ok,strOut,outLen = compress(bufferLen,bufferLen,str,#str)
	return !ok ? string.left(strOut,outLen);
}

//解压缩
unzip = function(str){
    var bufferLen = #str;
    var ok =  -5;
    var strOut,outLen;
    while(ok==-5){
    	bufferLen *= 2;
    	ok,strOut,outLen = uncompress(bufferLen,bufferLen ,str,#str)
    } 
	return !ok ? string.left(strOut,outLen);	
}

//测试压缩
strzip = zip( "求调用zlib1.dll 的简单例子。" ) 
//测试解压缩
str = unzip( strzip ) 

io.open()
io.print( str  )

 
execute("pause") //按任意键继续
io.close();//关闭控制台
