1. New Project Questions
Hey, all...
I'm starting a new project and have a question (or two): 1) I think I'll
need to use a lo-res (640x480 at least) graphics mode, so is there a
library out there that's well tested and has button functions? I don't
think I'll need windows right now, just text placement and buttons.
Also, what's the fastest way to read in a plain text file, delimited
with paragraph marks (or carriage returns)? Ralf, doesn't your EDOM
handle something like this? I'll check on it, but I'd like answers from
all in the know. I'll need to read text files as well as using the
standard EUPHORIC "get(s)".
RE: Gotos - Couldn't innermost loops be turned into functions or
something? That would be a little more cumbersome, but readability
wouldn't suffer, would it?
NOW:
for x = a to z
for y = b to w
...
end for
end for
NEW:
function func(...)
for y = b to w
...
end for
return success
end func
for x = a to z
if func() then --if func() returns a "bad" value, exit loop now
end if
end for
And if "for y" had additional loops, you would have to further break
them out. Just a quick thought. Could be developed...? What's yer take
on it?
Thanks!
ck
2. New Project Questions
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM>
Sep 29, 1998
-
Last edited Sep 30, 1998
>Also, what's the fastest way to read in a plain text file
This may not be the fastest, but is exact. This function returns the fil=
e
as a sequence
use as:
include readfile.e
sequence myfile
myfile =3D readfile("c:\\autoexec.bat")
--readfile.e
include file.e
global function filesize(integer file_num)
integer seek_success, file_length, orig_position
orig_position =3D where(file_num)
seek_success =3D seek(file_num,-1)
file_length =3D where(file_num)
seek_success =3D seek(file_num,orig_position)
return file_length
end function
global function readfile(sequence filename)
sequence file
integer file_length, seek_success, file_num
file_num =3D open(filename, "rb")
file_length =3D filesize(file_num)
file =3D repeat(0,file_length)
seek_success =3D seek(file_num,0)
for i =3D 1 to file_length do
file[i] =3D getc(file_num)
end for
close(file_num)
return file
end function
--end readfile.e
=
3. Re: New Project Questions
You would expect this one to be the fastest:
function get_eof (integer fh)
-- Reads all I/O until an EOF is found
sequence ret
ret = gets (fh)
while ret[length(ret)] != -1 do
ret = ret & gets (fh)
end while
return ret[1..length(ret)-1]
end function
But this one could also be fast:
constant DOZEN = 250 -- or something, just try..
function get_eof (integer fh)
-- Reads all I/O until an EOF is found
sequence ret
integer char
ret = gets (fh)
while ret[length(ret)] != -1 do
for 1 to DOZEN do
ret = append(ret, getc(fh))
end for
end while
for index = length(ret) to length(ret) - DOZEN by -1 do
if ret[index] != -1 then
return ret[1..index]
end if
end for
end function
4. Re: New Project Questions
Thanks Alan and Ralf... I'll try these code snippets today and letcha
know.
Ralf Nieuwenhuijsen wrote:
> You would expect this one to be the fastest:
>
> function get_eof (integer fh)
> -- Reads all I/O until an EOF is found
>
> sequence ret
>
> ret = gets (fh)
> while ret[length(ret)] != -1 do
> ret = ret & gets (fh)
> end while
>
> return ret[1..length(ret)-1]
> end function
>
> But this one could also be fast:
>
> constant DOZEN = 250 -- or something, just try..
>
> function get_eof (integer fh)
> -- Reads all I/O until an EOF is found
>
> sequence ret
> integer char
>
> ret = gets (fh)
> while ret[length(ret)] != -1 do
> for 1 to DOZEN do
> ret = append(ret, getc(fh))
> end for
> end while
>
> for index = length(ret) to length(ret) - DOZEN by -1 do
> if ret[index] != -1 then
> return ret[1..index]
> end if
> end for
>
> end function
5. Re: New Project Questions
i have my own function for getting how many bytes are in a file(it's
gotta be open first):
include file.e
global function lof(integer filenumber)
integer pointer
integer retval
pointer=where(filenumber)
if seek(filenumber,-1) then
end if
retval=where(filenumber)
if seek(filenumber,pointer) then
end if
return retval
end function
___________________________
When it comes to programming languages, Euphoria is a cut above -
matt1278 at juno.com and matt1421 at juno.com(and soon to be
irisnmatt at prodigy.net. Then again, maybe not) Euphoria programmer
Web users: <A HREF=mailto:"matt1421 at juno.com">matt1421 at juno.com</A> or <A
___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]