Re: Trouble reading bytes

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Fri, 1 Aug 2003 17:14:41 +1000, Derek Parnell
<ddparnell at bigpond.com> wrote:

<snip>
>puts() ONLY WRITES BYTES!=20
>
>Try this...
>
>  puts(fn, {400,500,600,700})
>
>You should get written out to 'fn' 4 BYTES - not a Sequence containing 4=
 bytes. The four bytes are #90, #F4, #58, #BC.
And try this:
sequence d
d=3D{97,353,609,1121,2145,4193}
puts(1,d)		-- "aaaaaa" !

The moral is never use puts() to store anything other than character
data. Numbers get clobbered (as documented, but worth repeating).

I forget the original poster, but I'd recommend using database.e. The
following is a little starter:

include database.e	-- see C:\EUPHORIA\HTML\DATABASE.HTM
sequence data
data =3D {{0,0,0,0,0},
		{1,1,1,1,1},
		{2,2,2,2,2},
		{3,3,3,3,3}}=20

integer recordnumber

if db_open("data.edb",DB_LOCK_NO)=3DDB_OPEN_FAIL then
	if db_create("data.edb",DB_LOCK_NO)!=3DDB_OK then
		puts(1,"error creating database")
		abort(0)
	end if
end if
if db_select_table("data")!=3DDB_OK then
	if db_create_table("data")!=3DDB_OK then
		puts(1,"error creating data table")
		abort(0)
	end if
end if

recordnumber=3Ddb_find_key(1)
if recordnumber<0 then
	if db_insert(1,data)!=3DDB_OK then
		puts(1,"error writing data")
		abort(0)
	end if
else
	db_replace_data(recordnumber,data)
end if

?data
?db_record_data(db_find_key(1))

db_close()

if getc(0) then end if

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu