Re: Writing numbers to files
- Posted by irvm at ellijay.com Jul 01, 2001
- 385 views
From: <dstanger at belco.bc.ca> > I hope that someone can help me with this DOS program: > I am obtaining the color numbers of a bitmap on the screen using > get_pixel() and then writing them to a file. When I use puts() to > write them to the file > it saves the color numbers as characters which I don't want. If I use print > to write them it does so as numbers but puts them in a lump that is useless > to me. Eventually, I want to be able to read the numbers out of the file and > convert them back to colors on screen using pixel() but until I can save > them in a way that I can read them again I am stuck. First of all, are you using get_pixel ({x,y}) -- one point at a time, or get_pixel({x,y,n}) -- getting a series of 'n' points? The first one returns a small integer, the second an 'array' of integers. Since these are integers, seeing or saving them as characters won't be good. Integers often go higher than 256. What's wrong with just using print(fn,s) ? That will print the numbers out in this form: {254,464,5457,675,2353,5435,346,1,4}....and so on. Reading them back in is just s = get(fn) if s[1] = GET_SUCCESS then s = s[2] else -- error routine goes here Print() and it's partner get() can write and read ANY Euphoria sequence, no matter how complex. If you need the numbers formatted to be more human readable, use a loop with printf() If you do that, you can load them into a text editor. The problem will come when you want to load them back into a Euphoria program, you'll have to do some parsing. More work. Regards, Irv