1. More Procedure
All,
Here is a snipette of code from a program what I would
like to know is if anyone has written a procedure or function to
display a sequence with a --MORE-- type filter?
-- Begin Code Snipette --
procedure Read_File(sequence FName)
sequence buffer
object data
integer handle
handle = open( FName, "r" )
if handle = -1 then
puts(1,"Error: " & FName & " not found! ")
abort(0)
end if
data = {}
buffer = {}
while 1 do
data = get(handle)
data = data[2]
if atom(data) then
exit
end if
-- replace { ... 10 } with { ... 13, 10 }
data = data[1..length(data)-1] & 13 & 10
buffer = buffer & data
end while
close( handle )
puts(1,buffer)
end procedure
-- End Code Snippette --
If the buffer is very long, it scrolls off the screen this way
what I would like is for it to pause with a --MORE-- type prompt if the
screen fills, and allow the user to press a key to continue. I was
going to write a putsmore() procedure, but decided to see if someone
else may have already done so, and would save me the time and effort, I
am still kind of NEW to euphoria, but am catching on fast.
TIA,
Later:
+ + + Rev. Ferlin Scarborough - Centreville, Alabama - USA
2. More Procedure
- Posted by Ad Rienks <Ad_Rienks at COMPUSERVE.COM>
Jan 07, 1999
-
Last edited Jan 08, 1999
-- waitpage.e
include graphics.e
procedure wait_page()
object junk
sequence pos
pos =3D get_position()
if pos[1] =3D 24 then
position(25, 1)
cursor(NO_CURSOR)
puts(1, "<ENTER> for the next page")
junk =3D getc(0)
clear_screen()
cursor(UNDERLINE_CURSOR)
end if =
end procedure -- wait_page
-------------------------------------------------------------------------=
--
--
-- test
for i =3D 1 to 100 do
puts(1, sprintf("%3d", i) & '\n')
wait_page()
end for
Ad Rienks
kwibus at dolfijn.nl
3. Re: More Procedure
Ad Rienks wrote:
>
> -- waitpage.e
> include graphics.e
>
> procedure wait_page()
> object junk
> sequence pos
> pos = get_position()
> if pos[1] = 24 then
> position(25, 1)
> cursor(NO_CURSOR)
> puts(1, "<ENTER> for the next page")
> junk = getc(0)
> clear_screen()
> cursor(UNDERLINE_CURSOR)
> end if
> end procedure -- wait_page
>
Ad,
I appreciate the wait_page, although it was not exactly
what I had in mind, it did give me a direction in which to proceed.
I actually need a More Procedure that I can pass a sequence which has
already been built after reading an entire file into it, I wrote a
quick more procedure by slicing the sequence, although this did not
work properly, I did not get much of a chance to work on it for long
just a few minutes, after mulling it over, I believe my problem lies in
the fact that the elements of the sequence are of varying sizes, if I
pad elements to make them all come out to say 80 characters, I can then
slice the sequence to a portion just big enough to place on the screen,
then increment my slice until the length of the sequence is reached.
Any suggestions in this direction anyone, or perhaps a better way of
handling this particular need.
Later and TIA.
+ + + Rev. Ferlin Scarborough - Centreville, Alabama - USA
email:ferlin at sandw.net
email:ferlin at email.com
4. Re: More Procedure
Ferlin,
I hope the routine below is reasonably close to what you really want.
It is probably quite slow, because it pokes each character of the input
sequence separately into the video memory. I am sure there is a better,
more elegant way of doing it, but I enjoyed writing it anyway. jiri
-- file : more.ex
-- author: jiri babor
-- email : jbabor at paradise.net.nz
-- date : 99-01-15
-------------------------------------------------------------------------
-- simple 'more' routine, assuming color adaptor and 25x80 text mode --
-------------------------------------------------------------------------
include graphics.e
procedure more(integer foreground,integer background,sequence text)
sequence pos
integer a,c,tp
pos=get_position()
tp=#B8000+160*(pos[1]-1)+2*(pos[2]-1)
a=16*background+foreground -- color attribute
for i=1 to length(text) do
c=text[i]
if c=10 then -- newline
tp=160*(floor((tp-#B8000)/160)+1)+#B8000
else
poke(tp,{text[i],a})
tp=tp+2
end if
if tp>=#B8F00 then
poke(#B8F00,{'-',a,'m',a,'o',a,'r',a,'e',a,'-',a})
position(25,7)
while get_key()=-1 do end while
clear_screen()
tp=#B8000
end if
end for
-- restore cursor at right place
position(floor((tp-#B8000)/160)+1,remainder(tp-#B8000,160)/2+1)
end procedure
-- test ------------------------------------------------------------------------
position(21,1)
more(YELLOW,RED,"This is just a test.\nbohemian\nThis is just a test.\n"&
"bohemian\nThis is just a test.\nbohemian\nThis is just a test.\nbohemian")
while get_key()=-1 do end while
5. Re: More Procedure
-- file : more2.ex
-- author: jiri babor
-- email : jbabor at paradise.net.nz
-- date : 99-01-15
----------------------------------------------------------
-- simpler 'more' routine, assuming 25 line text mode --
----------------------------------------------------------
include graphics.e
procedure more(sequence text)
sequence pos
for i=1 to length(text) do
pos=get_position()
if pos[1]>=25 then
position(25,1)
puts(1,"--more--")
while get_key()=-1 do end while
clear_screen()
position(1,1)
end if
puts(1,{text[i]})
end for
end procedure
6. Re: More Procedure
Jiri Babor wrote:
>
> -- file : more2.ex
> -- author: jiri babor
> -- email : jbabor at paradise.net.nz
> -- date : 99-01-15
>
> ----------------------------------------------------------
> -- simpler 'more' routine, assuming 25 line text mode --
> ----------------------------------------------------------
>
> include graphics.e
>
> procedure more(sequence text)
> sequence pos
> for i=1 to length(text) do
> pos=get_position()
> if pos[1]>=25 then
> position(25,1)
> puts(1,"--more--")
> while get_key()=-1 do end while
> clear_screen()
> position(1,1)
> end if
> puts(1,{text[i]})
> end for
> end procedure
THANKS! More2 was just what I needed, works like a charm.
--
+ + + Rev. Ferlin Scarborough - Centreville, Alabama - USA
email:ferlin at sandw.net
email:ferlin at email.com