1. Re: Nexus Radio Final Released (should be get.e)
- Posted by CChris <christian.cuvier at agriculture.gouv?fr> Jul 06, 2007
- 498 views
- Last edited Jul 07, 2007
<snipped/> > > Could you post the first line(s) of the file you are trying to read from, as > > they appear in Notepad for instance? > > get() reads a valid Euphoria object string representation (the kind sprint() > > returns), otherwise it fails. > > So if the first line is, say "include dll.e", the string "include" is not an > > object representation and get() returns {GET_FAIL,whatever}. > > If you want the first line of the file returned, use gets() instead. > > Otherwise, > > I am not sure of what you want to achieve. > > > > CChris > > Thank you CChris, > > What I want to achieve is to read the whole file in one fell swoop. > > If I use gets() all the way through it works but takes longer. > > The first few lines of the .ew file are: > }}} <eucode> > > global constant ARWENVERSION = { > "ARWEN Win32 library", -- name > 0, -- major verion > 93.2} -- minor version (Positive compatible) > > -- DISCLAIMER > -- ========== > -- The software and documentation are provided "as is", without any express or > -- implied warranty for any use whatsoever. No warranty is provided that any > -- part of the software and/or documentation is error free. The Author will > not in > -- any event be liable for any direct, indirect, special, incidental, > consequential > -- or other imaginable damages related to any use, reproduction, modification, > or > -- distribution of the software and/or documentation. > > --without warning > > -- getParentHwnd(): need update? > > -- destroy() -- fonts now? > -- accelerators? > > -- font dialogs.. > > -- selectDirectory doesn't properly relase some allocator thingie, what to do? > Ask Derek? WIn32lib misses this one too.. > > > Don Cole Well, I'm not too surprised that get() fails... Do you need the logical distinction between lines? If not, just open it in binary mode, seek() to end, call where() to get the size, seek to start and perform get_bytes(size_returned). You can even make it simpler:
include file.e include get.e constant my_file = "texfile.txt" -- or whatever integer fh fh = open(my_file,"a") integer size size=where(fh) -- opening in append mode puts pointer at EOF close(fh) fh=open(my_file,"rb") sequence the_text the_text = get_bytes(fh,size) close(fh)
Otherwise... gets() is probably the simplest. The faster might be (not tested) to read in binary mode as above, then call match_from() repeatedly to locate the CR+LF pairs and rebuild the line structure. If match_from() is still buggy, then match(), take th tail slice and match() again, as usual. CChris You can do it even faster under DOS using machine code on a transfer area you set using Causeway's API... depending on how much effort and speed you want.