Hi there, The quick: I'm trying to write out binary files, i.e. just a whole bunch of numbers, what's the best way of doing this. The slightly longer: I'm trying to write out a binary file, that can contains the value 0, and it doesn't seem possible (in any simple, fast way). Here's the background. I'm trying to read in and write out .wbmp graphic files. I can read in a file with the following snippit... <!--- Read in the binary file, as though it were text ---> <cffile action="read" file="c:\temp\myFile.wbmp" variable="inputFile"> <!--- // now loop through the file outputting the results. For us to be able to // see anything meaningful, I'm using asc(), to give me the ASCII value of // the "byte" we just read in, and the formatBaseN to give me the hex value, // just like old skool debugging tools :) ---> <cfoutput> <cfloop index="thisPos" from="1" to "#len(inputFile)#"> #asc(mid(inputFile,thisPos,1))# - #ucase(formatBaseN(asc(mid(inputFile,thisPos,1)),16)# - #mid(inputFile,thisPos,1)# <br> </cfloop> </cfoutput> which may give me the results: 0 - 0 - 0 - 0 - 92 - 5C - \ 65 - 41 - A 0 - 0 - 77 - 4D - M 116 - 74 - t 0 - 0 - 0 - 0 - ----------- Now I want to write these results back to a file, normally I'd do something like (which I'm sure is a very wrong way of doing it)... <cfset outputFile = ''> <cfset outputValues = '0,0,92,65,0,77,116,0,0'> <cfloop index="thisValue" from="1" to="#listLen(outputValues)#"> <cfset outputfile = '#outputfile##chr(listGetAt(outputValues,thisValue)#'> </cfloop> <cffile action="write" file="c:\temp\newFile.wbmp" output=#outputFile# addnewline="No"> However reading that back in just gives me; 92 - 5C - \ 65 - 41 - A 77 - 4D - M 116 - 74 - t It's lost the 0's .... chr(0) = null, which may explain the problem. ----------- I *can* do it with the following... <!--- here's the binary data I want to send out ---> <cfset outputValues = '0,0,92,65,0,77,116,0,0'> <!--- read in a file, where I know the first value is 0 ---> <cffile action="read" file="c:\temp\myFile.wbmp" variable="inputFile"> <!--- create a new file, into which I'm going to put my data ---> <cffile action="write" file="c:\temp\newFile.wbmp" output='' addnewline="No"> <!--- loop through the list of values, in the hope we are going to write the value out ---> <cfloop index="thisPos" from="1" to="#listLen(outputValues)#"> <!--- if my value is 0, then I'm going to have to use cunning methods to write a value of 0 out to the file ---> <cfif listGetAt(outputValues,thisPos) EQ 0> <cffile action="append" file="c:\temp\newFile.wbmp" output=#mid(inputFile,1,1)# addnewline="No"> <cfelse> <cffile action="append" file="c:\temp\newFile.wbmp" output=#chr(listGetAt(outputValues,thisPos))# addnewline="No"> </cfif> </cfloop> The above give me what I want, but with loads of disk accessing, basically I just want to speed it all up! Thanks for any help, Dan. This message is intended only for the use of the person(s) ("the intended recipient(s)") to whom it is addressed. It may contain information which is privileged and confidential within the meaning of the applicable law. If you are not the intended recipient, please contact the sender as soon as possible. The views expressed in this communication may not necessarily be the views held by Live Information Systems Limited. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists