Re: Saving sequences

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

This is what I use to load and save binary files.

It could be a complicated sequence,text or anything.

include bget.e 
------------------the binary way -------------------- 
global function get_file(sequence file_name)--binary file 
  integer fn 
  object database 
  fn=exist(file_name) 
  if fn=0 then --does not exist 
   fn=open(file_name,"wb") 
  end if 
   fn = open(file_name, "rb") 
    if fn=-1 then  
   puts(1,"Can't open file:"& file_name) 
    end if 
   database = bget(fn) 
   close(fn) 
  if length(database)<2 then 
  return {} 
 else 
  return database[2] 
 end if 
end function 
 
global procedure save_file(sequence db,sequence file_name) 
 integer fn 
 fn = open(file_name, "wb") 
  bprint(fn,db) 
 close(fn) 
end procedure 
 
Don Cole
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu