1. mysterious bug...
- Posted by Matt Z Nunyabidness <matt1278 at JUNO.COM>
Oct 23, 1998
-
Last edited Oct 24, 1998
i have this mysterious bug in my openit 2.5 code. OK, suppose you open
foo.bar, then you use the o command do open foobar.txt, then you close
foobar.txt and open foo.txt. When you try to load foo.txt, openit 2.5
will stop and say:
An error was detected during execution of your program.
Your program exceeds 300 statements in size, so this
Public Domain Edition of Euphoria cannot provide run-time error
diagnostics. If you purchase the Complete Edition of Euphoria you will
get full diagnostic support for any size of program. See register.doc.
Meanwhile, you can locate your problem using print statements and the
Euphoria trace facility.
This also happens when you just type ex open25, and hit o to open a file.
Could anybody with the complete edition tell me what the code says?
Here's open25.ex:
with trace
trace(1)
-- Welcome to OpenIt! v2.5 for Euphoria
-- This was originally a program for opening help texts, but i guess it
turned
-- in to the latest version of OpenIt!.
-- Started: October 20th, 1998
-- Finished: October 20th, 1998
include graphics.e
include user.e
include open25.ini
include wildcard.e
SaveScrn()
clear_screen()
object cl, stuf, file, fn, getit, vc,
pos,last,lst,srch,flag,obj,psn,help,env
integer fl,ps2
flag=0
last=0
vc = video_config()
stuf = -1
cl = command_line()
titlebar("OpenIt! v2.5", 7, 0)
statline("OpenIt! v2.5 (C) 1998 SoftCo", 7, 0)
position(2, 1)
if length(cl) < 3 then
puts(1, "Nothing loaded. Hit x to exit")
while stuf != 'x' do
stuf = get_key()
if stuf=315 then
statline("Loading help...",f,b)
stuf=-1
if atom(getenv("EUDIR")) then
statline("EUDIR not set. Run Euphoria setup",f,b)
beep()
delay(1)
flag=-1
exit
end if
env=getenv("EUDIR")
help=env&"\\bin\\open25.hlp"
if atom(dir(help)) then
statline("Help not found",f,b)
beep()
delay(1)
exit
end if
obj=save_text_image({1,1},{vc[3],vc[4]})
psn=get_position()
system("ex open25 "&help,2)
display_text_image({1,1},obj)
position(psn[1],psn[2])
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
----
end if
if stuf='o' then
psn=get_position()
obj=save_text_image({1,1},{vc[3],vc[4]})
statline("File to open: ",15,3)
position(vc[3],15)
srch=input()
srch="ex open25 \""&file&'\"'
system(srch,2)
position(psn[1],psn[2])
display_text_image({1,1},obj)
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
end if
end while
clear_screen()
DispScrn()
abort(0)
else
file = cl[3]
end if
if not match(".", file) then
file = file & ".txt"
end if
procedure view()
clear_screen()
position(2, 1)
fn = open(file, "rb")
if fn = -1 then
titlebar("OpenIt! v2.5", 7, 0)
statline("OpenIt! v2.5 (C) 1998 SoftCo", 7, 0)
puts(1, file&" not found. Hit x to exit")
while stuf != 'x' do
stuf = get_key()
if stuf=315 then
statline("Loading help...",f,b)
stuf=-1
if atom(getenv("EUDIR")) then
statline("EUDIR not set. Run Euphoria setup",f,b)
beep()
delay(1)
flag=-1
exit
end if
env=getenv("EUDIR")
help=env&"\\bin\\open25.hlp"
if atom(dir(help)) then
statline("Help not found",f,b)
beep()
delay(1)
exit
end if
obj=save_text_image({1,1},{vc[3],vc[4]})
psn=get_position()
system("ex open25 "&help,2)
display_text_image({1,1},obj)
position(psn[1],psn[2])
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
end if
end while
clear_screen()
DispScrn()
abort(0)
end if
if seek(fn, 0) then
end if
clear_screen()
position(2, 1)
if not match("OPEN25.HLP",upper(file)) then
if length(cl)>=4 then
titlebar(cl[4], f, b)
else
titlebar("OpenIt! v2.5 - "&file, f, b)
end if
else
titlebar("OpenIt! v2.5 - Help",f,b)
end if
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
while 1 do
getit = gets(fn)
last=where(fn)
if atom(getit) then
statline("End-of-file",f,b)
exit
end if
pos = get_position()
psn=0
if pos[1] = vc[3] then
while stuf != 337 do
stuf = wait_key()
ps2=psn-80
psn=where(fn)
if stuf=328 then
scroll(-1,2,24)
if seek(fn,ps2) then
end if
getit=gets(fn)
position(2,1)
puts(1,getit)
end if
if stuf='e' then
statline("OK. Opening "&file&" for editing...",f,b)
pos=where(fn)
obj=save_text_image({1,1},{vc[3],vc[4]})
close(fn)
system("edit \""&file&'\"',2)
fn=open(file,"rb")
if seek(fn,pos) then
end if
display_text_image({1,1},obj)
statline("OpenIt! v2.5 (C) 1998 SoftCo", 7, 0)
end if
if stuf=317 then
statline("Searching for "&srch&"...",f,b)
pos=where(fn)
while 1 do
getit=gets(fn)
if atom(getit) then
statline('\"'&srch&"\" not found.",f,b)
beep()
delay(1)
if seek(fn,pos) then
end if
exit
end if
if match(upper(srch),upper(getit)) then
statline('\"'&srch&"\" found!",f,b)
beep()
delay(1)
flag=-1
exit
end if
end while
end if
if stuf='p' then
system("print /d:lpt1 "&file,2)
end if
if stuf='l' then
fl=lof(fn)
statf("%s is %d bytes large.",{file,fl},f,b)
end if
if stuf='h' or stuf=315 then
statline("Loading help...",f,b)
stuf=-1
if atom(getenv("EUDIR")) then
statline("EUDIR not set. Run Euphoria setup",f,b)
beep()
delay(1)
flag=-1
exit
end if
env=getenv("EUDIR")
help=env&"\\bin\\open25.hlp"
if atom(dir(help)) then
statline("Help not found",f,b)
beep()
delay(1)
exit
end if
obj=save_text_image({1,1},{vc[3],vc[4]})
psn=get_position()
system("ex open25 "&help,2)
display_text_image({1,1},obj)
position(psn[1],psn[2])
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
end if
if stuf='d' then
stuf=-1
statline("DOS Command: ",15,3)
position(vc[3],14)
srch=input()
obj=save_text_image({1,1},{vc[3],vc[4]})
psn=get_position()
system("cls",2)
system("echo Working...",2)
system(srch,1)
display_text_image({1,1},obj)
position(psn[1],psn[2])
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
--exit
end if
if stuf=336 then
stuf=-1
scroll(+1,2,vc[3]-1)
getit=gets(fn)
position(vc[3]-1,1)
puts(1,getit)
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
--exit
end if
if stuf=329 then
if seek(fn,lst) then
end if
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
--exit
end if
if stuf='b' then
getit=""
if seek(fn,0) then
end if
exit
end if
if stuf='o' then
psn=get_position()
obj=save_text_image({1,1},{vc[3],vc[4]})
statline("File to open: ",15,3)
position(vc[3],15)
srch=input()
system("ex "&cl[2]&' '&srch,2)
position(psn[1],psn[2])
display_text_image({1,1},obj)
statline("OpenIt! v2.5 (C) 1998 SoftCo", f, b)
end if
if stuf='f' then
statline("String to search for: ", 15,3)
last=where(fn)
position(vc[3],23)
srch=input()
statline("Searching...",f,b)
while 1 do
getit=gets(fn)
if atom(getit) then
position(vc[3],1)
statline('\"'&srch&"\" not found.",f,b)
beep()
delay(1)
statline("OpenIt! v2.5 (C) 1998 SoftCo", f,
b)
if seek(fn,last) then
end if
exit
end if
if match(upper(srch),upper(getit)) then
position(vc[3],1)
statline('\"'&srch&"\" found!",f,b)
beep()
delay(1)
statline("OpenIt! v2.5 (C) 1998 SoftCo", f,
b)
flag=1
exit
end if
end while
end if
if flag=1 then
stuf=-1
flag=0
exit
end if
if stuf=363 then
DispScrn()
abort(0)
end if
if stuf=329 then
if seek(fn,lst) then
end if
exit
end if
--stuf=-1
end while
stuf=-1
clear_screen()
position(2, 1)
pos = get_position()
pos[1]=2
statline("OpenIt! v2.5 (C) 1998 SoftCo Inc.", f, b)
if not match("OPEN25.HLP",upper(file)) then
if length(cl)>=4 then
titlebar(cl[4], f, b)
else
titlebar("OpenIt! v2.5 - "&file, f, b)
end if
else
titlebar("OpenIt! v2.5 - Help",f,b)
end if
end if
puts(1, getit)
end while
statline("Done. Hit x to exit, or r to restart", f, b)
while stuf != 'x' do
stuf = get_key()
if stuf = 'r' then
close(fn)
view()
end if
if stuf=315 then
statline("Loading help...",f,b)
stuf=-1
if atom(getenv("EUDIR")) then
statline("EUDIR not set. Run Euphoria setup",f,b)
beep()
delay(1)
flag=-1
exit
end if
env=getenv("EUDIR")
help=env&"\\bin\\open25.hlp"
if atom(dir(help)) then
statline("Help not found",f,b)
beep()
delay(1)
stuf=-1
exit
end if
obj=save_text_image({1,1},{vc[3],vc[4]})
psn=get_position()
system("ex open25 "&help,2)
display_text_image({1,1},obj)
position(psn[1],psn[2])
statline("Done. Hit x to exit, or r to restart", f, b)
end if
if stuf='e' then
statline("OK. Opening "&file&" for editing...",f,b)
pos=where(fn)
close(fn)
obj=save_text_image({1,1},{vc[3],vc[4]})
system("edit \""&file&'\"',2)
fn=open(file,"rb")
if seek(fn,pos) then
end if
display_text_image({1,1},obj)
statline("Done. Hit x to exit, or r to restart", f, b)
end if
if stuf='o' then
psn=get_position()
obj=save_text_image({1,1},{vc[3],vc[4]})
statline("File to open: ",15,3)
position(vc[3],15)
srch=input()
system("ex "&cl[2]&' '&srch,2)
position(psn[1],psn[2])
display_text_image({1,1},obj)
statline("Done. Hit x to exit, or r to restart", f, b)
end if
end while
end procedure
view()
DispScrn()
abort(0)
and open25.ini:
global object f,b
f=WHITE
b=BLACK
fore=BRIGHT_WHITE
back=CYAN
bfore=BLACK
bback=WHITE
_________________
"When it comes to programming languages, Eu™ by RDS is a cut above" -
Matt1278 and SoftPrez
Webbers: <A HREF="mailto:softprez at juno.com">softprez at juno.com</A>,
president of SoftCo.® Uh, no slogan at the moment™
Seeya next week!