Somewhat inspired by DB User 2006+'s Console DLL, I've created a series of functions that create a similar kind of console, only inside the DBP program.
The Functions:
console_types - first part of console setup.
console_initiate - second part of console setup.
console_write - adds a new message to the console stack.
console_read - reads an existing message from the console stack.
console_shift_left - shifts the console stack data left.
console_draw - draws the console in either full or min modes.
console_text - subfunction of console_draw; displays console text.
console_interact - controls basic interactions (scroll/change mode).
console_erase - erases an existing message from the console stack.
console_empty - erases all data from the console.
console_unload - unloads the console for program termination.
console_position - repositions the console for both modes.
fill_string - like space$(); creates a string of a certain number of identical characters.
The Functions' Code:
console_types:
type console_type
mess as string
color as integer
endtype
return
function console_initiate( logsize as integer, saveflag as boolean, filename as string, showflag as boolean, filenumber as integer )
global console_array_size as integer : console_array_size = logsize
global console_array_top as integer : console_array_top = -1
global console_visible as boolean : console_visible = showflag
global console_full_x1 as integer : console_full_x1 = 0
global console_full_y1 as integer : console_full_y1 = 0
global console_full_x2 as integer : console_full_x2 = screen width()/2.6
global console_full_y2 as integer : console_full_y2 = screen height()
global console_min_x as integer : console_min_x = screen width()-30
global console_min_y as integer : console_min_y = 30
global console_scroll as integer : console_scroll = 0
global console_save_flag as boolean : console_save_flag = saveflag
global console_save_fileno as integer : console_save_fileno = filenumber
global console_save_filename as string : console_save_filename = filename
dim console_array(console_array_size) as console_type
if console_save_flag = 1 and console_save_fileno > 0 and console_save_filename <> "" then open to write console_save_fileno,console_save_filename
endfunction
function console_write( message as string, color as integer, saveflag as integer )
if console_array_top = console_array_size then console_shift_left( 0 )
console_array_top = console_array_top + 1
console_array(console_array_top).mess = message
console_array(console_array_top).color = color
console_scroll = console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 )
if console_scroll < 0 then console_scroll = 0
if saveflag = 1 and console_save_flag = 1 and file open ( console_save_fileno ) then write string console_save_fileno, message
endfunction
function console_read( position )
return$ = ""
if console_array_top - position > 0
return$ = console_array( console_array_top - position ).mess
endif
endfunction return$
function console_shift_left( leftstart )
for n = leftstart to console_array_size - 1
console_array(n).mess = console_array(n+1).mess
console_array(n).color = console_array(n+1).color
next n
console_array(console_array_size).mess = ""
console_array(console_array_size).color = 0
console_array_top = console_array_top - 1
endfunction
function console_draw()
lock pixels
if console_visible = 1
ink rgb(64,64,64),0 : box console_full_x1, console_full_y1, console_full_x2, console_full_y2
if console_scroll > console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 ) then console_scroll = console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 )
if console_scroll < 0 then console_scroll = 0
temp = ( ( console_full_y2 - console_full_y1 ) / 15 ) + console_scroll
if temp > console_array_size then temp = console_array_size
for n = console_scroll to temp
ink console_array(n).color, 0
console_text( console_full_x1 + 2, console_full_y1 - ( console_scroll * 15 ) + ( n * 15 ), console_full_x2, console_array(n).mess)
next n
ink rgb(255,255,255),0
line console_full_x1, console_full_y1, console_full_x1, console_full_y2 - 1
line console_full_x2, console_full_y1, console_full_x2, console_full_y2 - 1
line console_full_x1, console_full_y1, console_full_x2, console_full_y1
line console_full_x1, console_full_y2 - 1, console_full_x2, console_full_y2 - 1
box console_full_x2 - 20, console_full_y1 + 2, console_full_x2 - 2, console_full_y1 + 20
box console_full_x2 - 20, console_full_y2 - 20, console_full_x2 - 2, console_full_y2 - 2
box console_full_x2 - 20, console_full_y2 - 40, console_full_x2 - 2, console_full_y2 - 22
ink rgb(192,192,192),0
box console_full_x2 - 18, console_full_y1 + 10, console_full_x2 - 4, console_full_y1 + 18
box console_full_x2 - 14, console_full_y1 + 4, console_full_x2 - 8, console_full_y1 + 10
box console_full_x2 - 14, console_full_y2 - 10, console_full_x2 - 8, console_full_y2 - 4
box console_full_x2 - 18, console_full_y2 - 18, console_full_x2 - 4, console_full_y2 - 10
box console_full_x2 - 18, console_full_y2 - 38, console_full_x2 - 10, console_full_y2 - 30
box console_full_x2 - 16, console_full_y2 - 34, console_full_x2 - 4, console_full_y2 - 24
else
ink rgb(64,64,64),0
box console_min_x - 20, console_min_y - 20, console_min_x + 20, console_min_y + 20
ink rgb(255,255,255),0
line console_min_x - 20, console_min_y - 20, console_min_x - 20, console_min_y + 20 - 1
line console_min_x + 20, console_min_y - 20, console_min_x + 20, console_min_y + 20 - 1
line console_min_x - 20, console_min_y - 20, console_min_x + 20, console_min_y - 20
line console_min_x - 20, console_min_y + 20 - 1, console_min_x + 20, console_min_y + 20 - 1
box console_min_x - 12, console_min_y - 12, console_min_x + 12, console_min_y + 12
endif
unlock pixels
endfunction
function console_text( x1 as integer, y as integer, x2 as integer, mess as string)
if y + text height( mess ) > console_full_y2 then exitfunction
if len( mess ) = 0 then exitfunction
n = 1
x = x1
repeat
temp$ = mid$( mess, n )
text x, y, temp$
x = x + text width( temp$ )
if n < len( mess )
if x + text width( mid$( mess, n + 1 ) ) > x2 then exit
endif
n=n+1
until n - 1 = len( mess )
endfunction
function console_interact( mou_x, mou_y )
if console_visible = 1
if mou_x => console_full_x2 - 20 and mou_y => console_full_y1 + 2 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y1 + 20
if console_scroll > 0 then console_scroll = console_scroll - 1
endif
if mou_x => console_full_x2 - 20 and mou_y => console_full_y2 - 20 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y2 - 2
if console_scroll < console_array_size then console_scroll = console_scroll + 1
endif
if mou_x => console_full_x2 - 20 and mou_y => console_full_y2 - 40 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y2 - 22
console_visible = 0
endif
else
if mou_x => console_min_x - 20 and mou_y => console_min_y - 20 and mou_x =< console_min_x + 20 and mou_y =< console_min_y + 20
console_visible = 1
endif
endif
endfunction
function console_erase( position )
if console_array_top - position > 0
console_array( console_array_top - position ).mess = ""
console_array( console_array_top - position ).color = 0
endif
console_shift_left( console_array_top - position )
console_array_top = console_array_top - 1
endfunction
function console_empty()
for n = 0 to console_array_size
console_array(n).mess = ""
console_array(n).color = 0
next n
console_array_top= - 1
endfunction
function console_unload()
if file open( console_save_fileno ) then close file console_save_fileno
undim console_array()
endfunction
function console_position( x1, y1, x2, y2, x, y )
console_full_x1 = x1
console_full_y1 = y1
console_full_x2 = x2
console_full_y2 = y2
console_min_x = x
console_min_y = y
endfunction
function fill_string(temp,temp$)
return$=""
for n=1 to temp
return$=return$+temp$
next n
endfunction return$
Note - console_types is not a function because types don't work in functions.
The console can save the files to a log by providing a filename, a file number, and a saveflag of 1 when calling console_initiate. You can create filenames for the logs like so:
n=1
repeat
if file exist("log"+fill_string(3-len(str$(n)),"0")+str$(n)+".txt")=0 then exit
n=n+1
until n=999
temp$="log"+fill_string(3-len(str$(n)),"0")+str$(n)+".txt"
gosub console_types
console_initiate(100,1,temp$,1,1)
The following is a very simple example of how to use the console. Each change in the frame rate is recorded on the control panel. What you type appears in the bottom right corner, and is logged when you press enter. Each logged item is saved in a log file (ie. "log001.txt").
Rem Project: Console
Rem Created: 20/02/2007 16:58:51
sync on
sync rate 100
disable escapekey
set display mode 960,720,16
n=1
repeat
if file exist("log"+fill_string(3-len(str$(n)),"0")+str$(n)+".txt")=0 then exit
n=n+1
until n=999
temp$="log"+fill_string(3-len(str$(n)),"0")+str$(n)+".txt"
gosub console_types
console_initiate(100,1,temp$,1,1)
console_write("Program Executed - "+get time$(),rgb(0,255,0),1)
console_write(get time$(),rgb(0,255,0),1)
global mx as integer : mx = 0
global my as integer : my = 0
global mc as boolean : mc = 0
global mh as boolean : mh = 0
global a as float : a = 0
global b as float : b = 0
do
mx=mousex()
my=mousey()
mc=mouseclick()
if mc=1
if mh=0
if console_visible=1
if mx=>console_full_x1 and my=>console_full_y1 and mx=<console_full_x2 and my=<console_full_y2 then console_interact(mx,my)
else
if mx=>console_min_x-20 and my=>console_min_y-20 and mx=<console_min_x+20 and my=<console_min_y+20 then console_interact(mx,my)
endif
endif
mh=1
else
mh=0
endif
if returnkey()=1 and entry$()<>""
temp$=lower$(left$(entry$(),len(entry$())-1))
if temp$="red"
console_write(entry$(),rgb(255,0,0),1)
else
if temp$="green"
console_write(entry$(),rgb(0,255,0),1)
else
if temp$="blue"
console_write(entry$(),rgb(0,0,255),1)
else
if temp$="black"
console_write(entry$(),rgb(0,0,0),1)
else
if temp$="pink"
console_write(entry$(),rgb(255,0,255),1)
else
console_write(entry$(),rgb(255,255,255),1)
endif
endif
endif
endif
endif
clear entry buffer
endif
if oldfps<>screen fps()
oldfps=screen fps()
console_write(str$(screen fps()),rgb(255,255,255),1)
endif
if spacekey()=1
a=wrapvalue(a+0.04)
b=wrapvalue(b+0.08)
console_position(20+cos(a)*20,20+(cos(a)*20),(screen width()/2.6)+50+(sin(b)*50),460+(cos(b)*20),screen width()-30,30)
endif
if controlkey()=1
console_position(0,0,screen width(),screen height(),screen width()-30,30)
endif
if time>0 then time=time-1
if shiftkey()=1 and time=0
time=200
console_write("Shift pressed",rgb(192,192,192),1)
console_write("Info:",rgb(192,192,192),1)
console_write(space$(2)+get date$(),rgb(192,192,192),1)
console_write(space$(2)+get time$(),rgb(192,192,192),1)
endif
console_draw()
ink rgb(255,255,255),0
text screen width()-text width(entry$()),screen height()-15,entry$()
if escapekey()=1
console_write("Program Terminated - "+get time$(),rgb(255,255,255),1)
console_unload()
end
endif
sync
cls rgb(192,192,192)
loop
function fill_string(temp,temp$)
return$=""
for n=1 to temp
return$=return$+temp$
next n
endfunction return$
console_types:
type console_type
mess as string
color as integer
endtype
return
function console_initiate( logsize as integer, saveflag as boolean, filename as string, showflag as boolean, filenumber as integer )
global console_array_size as integer : console_array_size = logsize
global console_array_top as integer : console_array_top = -1
global console_visible as boolean : console_visible = showflag
global console_full_x1 as integer : console_full_x1 = 0
global console_full_y1 as integer : console_full_y1 = 0
global console_full_x2 as integer : console_full_x2 = screen width()/2.6
global console_full_y2 as integer : console_full_y2 = screen height()
global console_min_x as integer : console_min_x = screen width()-30
global console_min_y as integer : console_min_y = 30
global console_scroll as integer : console_scroll = 0
global console_save_flag as boolean : console_save_flag = saveflag
global console_save_fileno as integer : console_save_fileno = filenumber
global console_save_filename as string : console_save_filename = filename
dim console_array(console_array_size) as console_type
if console_save_flag = 1 and console_save_fileno > 0 and console_save_filename <> "" then open to write console_save_fileno,console_save_filename
endfunction
function console_write( message as string, color as integer, saveflag as integer )
if console_array_top = console_array_size then console_shift_left( 0 )
console_array_top = console_array_top + 1
console_array(console_array_top).mess = message
console_array(console_array_top).color = color
console_scroll = console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 )
if console_scroll < 0 then console_scroll = 0
if saveflag = 1 and console_save_flag = 1 and file open ( console_save_fileno ) then write string console_save_fileno, message
endfunction
function console_read( position )
return$ = ""
if console_array_top - position > 0
return$ = console_array( console_array_top - position ).mess
endif
endfunction return$
function console_shift_left( leftstart )
for n = leftstart to console_array_size - 1
console_array(n).mess = console_array(n+1).mess
console_array(n).color = console_array(n+1).color
next n
console_array(console_array_size).mess = ""
console_array(console_array_size).color = 0
console_array_top = console_array_top - 1
endfunction
function console_draw()
lock pixels
if console_visible = 1
ink rgb(64,64,64),0 : box console_full_x1, console_full_y1, console_full_x2, console_full_y2
if console_scroll > console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 ) then console_scroll = console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 )
if console_scroll < 0 then console_scroll = 0
temp = ( ( console_full_y2 - console_full_y1 ) / 15 ) + console_scroll
if temp > console_array_size then temp = console_array_size
for n = console_scroll to temp
ink console_array(n).color, 0
console_text( console_full_x1 + 2, console_full_y1 - ( console_scroll * 15 ) + ( n * 15 ), console_full_x2, console_array(n).mess)
next n
ink rgb(255,255,255),0
line console_full_x1, console_full_y1, console_full_x1, console_full_y2 - 1
line console_full_x2, console_full_y1, console_full_x2, console_full_y2 - 1
line console_full_x1, console_full_y1, console_full_x2, console_full_y1
line console_full_x1, console_full_y2 - 1, console_full_x2, console_full_y2 - 1
box console_full_x2 - 20, console_full_y1 + 2, console_full_x2 - 2, console_full_y1 + 20
box console_full_x2 - 20, console_full_y2 - 20, console_full_x2 - 2, console_full_y2 - 2
box console_full_x2 - 20, console_full_y2 - 40, console_full_x2 - 2, console_full_y2 - 22
ink rgb(192,192,192),0
box console_full_x2 - 18, console_full_y1 + 10, console_full_x2 - 4, console_full_y1 + 18
box console_full_x2 - 14, console_full_y1 + 4, console_full_x2 - 8, console_full_y1 + 10
box console_full_x2 - 14, console_full_y2 - 10, console_full_x2 - 8, console_full_y2 - 4
box console_full_x2 - 18, console_full_y2 - 18, console_full_x2 - 4, console_full_y2 - 10
box console_full_x2 - 18, console_full_y2 - 38, console_full_x2 - 10, console_full_y2 - 30
box console_full_x2 - 16, console_full_y2 - 34, console_full_x2 - 4, console_full_y2 - 24
else
ink rgb(64,64,64),0
box console_min_x - 20, console_min_y - 20, console_min_x + 20, console_min_y + 20
ink rgb(255,255,255),0
line console_min_x - 20, console_min_y - 20, console_min_x - 20, console_min_y + 20 - 1
line console_min_x + 20, console_min_y - 20, console_min_x + 20, console_min_y + 20 - 1
line console_min_x - 20, console_min_y - 20, console_min_x + 20, console_min_y - 20
line console_min_x - 20, console_min_y + 20 - 1, console_min_x + 20, console_min_y + 20 - 1
box console_min_x - 12, console_min_y - 12, console_min_x + 12, console_min_y + 12
endif
unlock pixels
endfunction
function console_text( x1 as integer, y as integer, x2 as integer, mess as string)
if y + text height( mess ) > console_full_y2 then exitfunction
if len( mess ) = 0 then exitfunction
n = 1
x = x1
repeat
temp$ = mid$( mess, n )
text x, y, temp$
x = x + text width( temp$ )
if n < len( mess )
if x + text width( mid$( mess, n + 1 ) ) > x2 then exit
endif
n=n+1
until n - 1 = len( mess )
endfunction
function console_erase( position )
if console_array_top - position > 0
console_array( console_array_top - position ).mess = ""
console_array( console_array_top - position ).color = 0
endif
console_shift_left( console_array_top - position )
console_array_top = console_array_top - 1
endfunction
function console_empty()
for n = 0 to console_array_size
console_array(n).mess = ""
console_array(n).color = 0
next n
console_array_top= - 1
endfunction
function console_unload()
if file open( console_save_fileno ) then close file console_save_fileno
undim console_array()
endfunction
function console_interact( mou_x, mou_y )
if console_visible = 1
if mou_x => console_full_x2 - 20 and mou_y => console_full_y1 + 2 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y1 + 20
if console_scroll > 0 then console_scroll = console_scroll - 1
endif
if mou_x => console_full_x2 - 20 and mou_y => console_full_y2 - 20 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y2 - 2
if console_scroll < console_array_size then console_scroll = console_scroll + 1
endif
if mou_x => console_full_x2 - 20 and mou_y => console_full_y2 - 40 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y2 - 22
console_visible = 0
endif
else
if mou_x => console_min_x - 20 and mou_y => console_min_y - 20 and mou_x =< console_min_x + 20 and mou_y =< console_min_y + 20
console_visible = 1
endif
endif
endfunction
function console_position( x1, y1, x2, y2, x, y )
console_full_x1 = x1
console_full_y1 = y1
console_full_x2 = x2
console_full_y2 = y2
console_min_x = x
console_min_y = y
endfunction
Update: Here's a second example. Try pressing shift, control, enter and space to add messages. Also click the text buttons for messages.
Rem Project: ConsoleExample2
Rem Created: 23/02/2007 17:55:51
sync on
sync rate 100
disable escapekey
set display mode 960,720,16
n=1
repeat
if file exist("log"+fill_string(3-len(str$(n)),"0")+str$(n)+".txt")=0 then exit
n=n+1
until n=999
temp$="log"+fill_string(3-len(str$(n)),"0")+str$(n)+".txt"
gosub console_types
console_initiate(100,1,temp$,1,1)
console_position(0,0,960,260,480,130)
console_write("Program Executed - "+get time$(),rgb(0,255,0),1)
console_write(get time$(),rgb(0,255,0),1)
global mx as integer : mx = 0
global my as integer : my = 0
global mc as boolean : mc = 0
global mh as boolean : mh = 0
global shift as boolean : shift = 0
global shifth as boolean : shifth = 0
global space as boolean : space = 0
global spaceh as boolean : spaceh = 0
global control as boolean : control = 0
global controlh as boolean : controlh = 0
global enter as boolean : enter = 0
global enterh as boolean : enterh = 0
a#=0
b#=0
do
mx=mousex()
my=mousey()
mc=mouseclick()
shift=shiftkey()
space=spacekey()
control=controlkey()
enter=returnkey()
if mc=1
if mh=0
if console_visible=1
if mx=>console_full_x1 and my=>console_full_y1 and mx=<console_full_x2 and my=<console_full_y2 then console_interact(mx,my)
else
if mx=>console_min_x-20 and my=>console_min_y-20 and mx=<console_min_x+20 and my=<console_min_y+20 then console_interact(mx,my)
endif
if mx=>200 and my=>620 and mx=<200+text width("time") and my=<635 then console_write(get time$(),rgb(255,150,200),1)
if mx=>480 and my=>620 and mx=<480+text width("Sphere") and my=<635 and object exist(1)=0
console_write("Making sphere...",rgb(255,50,255),1) : console_draw() : sync
ink rgb(0,128,0),0
box 0,0,255,255
for n=1 to 500
ink rgb(255,100+rnd(155),255),0
dot rnd(255),rnd(255)
next n
get image 1,0,0,255,255,0
make object sphere 1,10,180,180
texture object 1,1
set sphere mapping on 1,1
backdrop on
color backdrop rgb(192,192,192)
set ambient light 10
make light 1
console_write("Sphere made.",rgb(50,255,50),1)
endif
if mx=>760 and my=>620 and mx=<760+text width("date") and my=<635 then console_write(get date$(),rgb(255,150,200),1)
endif
mh=1
else
mh=0
endif
if shift=1
if shifth=0 then console_write("Shift Pressed",rgb(128,128,180),1)
shifth=1
else
shifth=0
endif
if space=1
if spaceh=0 then console_write("Space Pressed",rgb(128,128,205),1)
spaceh=1
else
spaceh=0
endif
if control=1
if controlh=0 then console_write("Control Pressed",rgb(128,128,230),1)
controlh=1
else
controlh=0
endif
if enter=1
if enterh=0 then console_write("Enter Pressed",rgb(128,128,255),1)
enterh=1
else
enterh=0
endif
console_draw()
ink rgb(255,255,255),0 : set text opaque
text 200,620,"Time"
text 480,620,"Sphere"
text 760,620,"Date"
set text transparent
if object exist(1)=1
rotate object 1,wrapvalue(object angle x(1)+0.4),wrapvalue(object angle y(1)+0.6),wrapvalue(object angle z(1)+1)
position light 1,cos(b#)*20,sin(b#)*20,cos(b#)*20
set light range 1,20+(cos(a#*3)*20)
position camera cos(a#*3)*20,0,cos(a#*2)*20
point camera cos(a#*3)*20,0,0
set camera fov 90+(cos(a#)*20)
a#=wrapvalue(a#+0.6)
b#=wrapvalue(b#+1.4)
endif
if escapekey()=1
console_write("Program Terminated - "+get time$(),rgb(255,255,255),1)
console_unload()
end
endif
sync
if object exist(1)=0 then cls rgb(192,192,192)
loop
function fill_string(temp,temp$)
return$=""
for n=1 to temp
return$=return$+temp$
next n
endfunction return$
console_types:
type console_type
mess as string
color as integer
endtype
return
function console_initiate( logsize as integer, saveflag as boolean, filename as string, showflag as boolean, filenumber as integer )
global console_array_size as integer : console_array_size = logsize
global console_array_top as integer : console_array_top = -1
global console_visible as boolean : console_visible = showflag
global console_full_x1 as integer : console_full_x1 = 0
global console_full_y1 as integer : console_full_y1 = 0
global console_full_x2 as integer : console_full_x2 = screen width()/2.6
global console_full_y2 as integer : console_full_y2 = screen height()
global console_min_x as integer : console_min_x = screen width()-30
global console_min_y as integer : console_min_y = 30
global console_scroll as integer : console_scroll = 0
global console_save_flag as boolean : console_save_flag = saveflag
global console_save_fileno as integer : console_save_fileno = filenumber
global console_save_filename as string : console_save_filename = filename
dim console_array(console_array_size) as console_type
if console_save_flag = 1 and console_save_fileno > 0 and console_save_filename <> "" then open to write console_save_fileno,console_save_filename
endfunction
function console_write( message as string, color as integer, saveflag as integer )
if console_array_top = console_array_size then console_shift_left( 0 )
console_array_top = console_array_top + 1
console_array(console_array_top).mess = message
console_array(console_array_top).color = color
console_scroll = console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 )
if console_scroll < 0 then console_scroll = 0
if saveflag = 1 and console_save_flag = 1 and file open ( console_save_fileno ) then write string console_save_fileno, message
endfunction
function console_read( position )
return$ = ""
if console_array_top - position > 0
return$ = console_array( console_array_top - position ).mess
endif
endfunction return$
function console_shift_left( leftstart )
for n = leftstart to console_array_size - 1
console_array(n).mess = console_array(n+1).mess
console_array(n).color = console_array(n+1).color
next n
console_array(console_array_size).mess = ""
console_array(console_array_size).color = 0
console_array_top = console_array_top - 1
endfunction
function console_draw()
lock pixels
if console_visible = 1
ink rgb(64,64,64),0 : box console_full_x1, console_full_y1, console_full_x2, console_full_y2
if console_scroll > console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 ) then console_scroll = console_array_top - ( ( console_full_y2 - console_full_y1 ) / 15 )
if console_scroll < 0 then console_scroll = 0
temp = ( ( console_full_y2 - console_full_y1 ) / 15 ) + console_scroll
if temp > console_array_size then temp = console_array_size
for n = console_scroll to temp
ink console_array(n).color, 0
console_text( console_full_x1 + 2, console_full_y1 - ( console_scroll * 15 ) + ( n * 15 ), console_full_x2, console_array(n).mess)
next n
ink rgb(255,255,255),0
line console_full_x1, console_full_y1, console_full_x1, console_full_y2 - 1
line console_full_x2, console_full_y1, console_full_x2, console_full_y2 - 1
line console_full_x1, console_full_y1, console_full_x2, console_full_y1
line console_full_x1, console_full_y2 - 1, console_full_x2, console_full_y2 - 1
box console_full_x2 - 20, console_full_y1 + 2, console_full_x2 - 2, console_full_y1 + 20
box console_full_x2 - 20, console_full_y2 - 20, console_full_x2 - 2, console_full_y2 - 2
box console_full_x2 - 20, console_full_y2 - 40, console_full_x2 - 2, console_full_y2 - 22
ink rgb(192,192,192),0
box console_full_x2 - 18, console_full_y1 + 10, console_full_x2 - 4, console_full_y1 + 18
box console_full_x2 - 14, console_full_y1 + 4, console_full_x2 - 8, console_full_y1 + 10
box console_full_x2 - 14, console_full_y2 - 10, console_full_x2 - 8, console_full_y2 - 4
box console_full_x2 - 18, console_full_y2 - 18, console_full_x2 - 4, console_full_y2 - 10
box console_full_x2 - 18, console_full_y2 - 38, console_full_x2 - 10, console_full_y2 - 30
box console_full_x2 - 16, console_full_y2 - 34, console_full_x2 - 4, console_full_y2 - 24
else
ink rgb(64,64,64),0
box console_min_x - 20, console_min_y - 20, console_min_x + 20, console_min_y + 20
ink rgb(255,255,255),0
line console_min_x - 20, console_min_y - 20, console_min_x - 20, console_min_y + 20 - 1
line console_min_x + 20, console_min_y - 20, console_min_x + 20, console_min_y + 20 - 1
line console_min_x - 20, console_min_y - 20, console_min_x + 20, console_min_y - 20
line console_min_x - 20, console_min_y + 20 - 1, console_min_x + 20, console_min_y + 20 - 1
box console_min_x - 12, console_min_y - 12, console_min_x + 12, console_min_y + 12
endif
unlock pixels
endfunction
function console_text( x1 as integer, y as integer, x2 as integer, mess as string)
if y + text height( mess ) > console_full_y2 then exitfunction
if len( mess ) = 0 then exitfunction
n = 1
x = x1
repeat
temp$ = mid$( mess, n )
text x, y, temp$
x = x + text width( temp$ )
if n < len( mess )
if x + text width( mid$( mess, n + 1 ) ) > x2 then exit
endif
n=n+1
until n - 1 = len( mess )
endfunction
function console_erase( position )
if console_array_top - position > 0
console_array( console_array_top - position ).mess = ""
console_array( console_array_top - position ).color = 0
endif
console_shift_left( console_array_top - position )
console_array_top = console_array_top - 1
endfunction
function console_empty()
for n = 0 to console_array_size
console_array(n).mess = ""
console_array(n).color = 0
next n
console_array_top= - 1
endfunction
function console_unload()
if file open( console_save_fileno ) then close file console_save_fileno
undim console_array()
endfunction
function console_interact( mou_x, mou_y )
if console_visible = 1
if mou_x => console_full_x2 - 20 and mou_y => console_full_y1 + 2 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y1 + 20
if console_scroll > 0 then console_scroll = console_scroll - 1
endif
if mou_x => console_full_x2 - 20 and mou_y => console_full_y2 - 20 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y2 - 2
if console_scroll < console_array_size then console_scroll = console_scroll + 1
endif
if mou_x => console_full_x2 - 20 and mou_y => console_full_y2 - 40 and mou_x =< console_full_x2 - 2 and mou_y =< console_full_y2 - 22
console_visible = 0
endif
else
if mou_x => console_min_x - 20 and mou_y => console_min_y - 20 and mou_x =< console_min_x + 20 and mou_y =< console_min_y + 20
console_visible = 1
endif
endif
endfunction
function console_position( x1, y1, x2, y2, x, y )
console_full_x1 = x1
console_full_y1 = y1
console_full_x2 = x2
console_full_y2 = y2
console_min_x = x
console_min_y = y
endfunction
This code runs on DBP 6.4.
Enjoy.
Uber Tails fan. monocoder.spaces.live.com http://MonoCoder.bebo.com