//------------------------------------------------------------------------ // Generate Binary LScript code by Bob Hood // // This script will take a disc file and create properly formatted code // so it can be embedded in an LScript. If the 'target' file exists, // then the generated LScript code will be appended to the end of it // (allowing binary data to be appended directly onto an existing script). // @version 2.2 @warnings generic { reqbegin("Generate Binary LScript"); c1 = ctlfilename("Source file","*.*"); c2 = ctlfilename("Target file","*.*"); c3 = ctlstring("Data id","myData"); return if !reqpost(); source = getvalue(c1); target = getvalue(c2); dataid = getvalue(c3); (,,,s,,,) = filestat(source); input = File(source,"rb") || error("Cannot access source file!"); output = File(target,fileexists(target) ? "a" : "w"); output || error("Cannot access target file!"); output.writeln("@data ",dataid," ",(s + 100) - (s % 100)); col = 0; while(!input.eof()) { c = input.readByte(); output.write(" ") if col; output.write(c.asStr(3,true)); if(col) col += 4; else col += 3; if(col > 76) { col = 0; output.nl(); } } output.nl() if col; output.writeln("@end"); input.close(); output.close(); info("Data generated successfully"); }