I making a kind of bulletin board/mailling system for a futuristic RPG. Ok, first check out the picture then you'll understand what i'm talking about.
Inside the Mail window at the right you'll will see two light green boxes under delete. I want to be able to click on them to goto the next line and last line, simple.
Something like this:
+ Code SnippetRem ***** Main Source File *****
#constant ScWdth screen width()
#constant Schigt screen height()
set display mode 800,600,32
sync : sync rate 0
type txtline
txt as string
endtype
global lasttick as integer
set text size 14
set text font "Arial"
dim txt$(-1) as txtline
maxline = 17 `It 0-17, so maxline = 18
nextline = 0
linecount = 99 `It 0-99, so linecount = 100
txtSiz = text size()
n = 1
temp$ = "Line: "
for x = 0 to linecount
array insert at bottom txt$()
x = array count(txt$(0))
txt$(x).txt = temp$+str$(n)
inc n
next x
color1 = RGB(255,255,128)
color2 = RGB(0,128,255)
boxX1 = ScWdth/2 + 66
boxY1 = Schigt/2 -64
boxX2 = boxX1 + 24
boxY2 = boxY1 + 24
do : cls
decbox = ActionBox(boxX1,boxY1,boxX2,boxY2,RGB(0,128,255),RGB(0,0,255))
incbox = ActionBox(boxX1,boxY1+128,boxX2,boxY2+128,RGB(0,128,255),RGB(0,0,255))
if decbox > 0
if mouseclick()=1 and timer()>lasttick
if nextline > 0
dec nextline,1
endif
lasttick=timer()+50
endif
endif
if incbox > 0
if mouseclick()=1 and timer()>lasttick
if maxline - 1 + nextline < array count(txt$(0))
inc nextline,1
endif
lasttick=timer()+50
endif
endif
if maxline - 1 + nextline < array count(txt$(0))
endvalue = maxline-1+nextline
else
endvalue = array count(txt$(0))
endif
for x = 0+nextline to endvalue
x1 = ScWdth/2
y1 = ( Schigt/2 - txtSiz*maxline/2) + ( txtSiz* x-(txtSiz*nextline))
ink RGB(255,255,255),0
center text x1,y1,txt$(x).txt
next x
if mouseclick() = 0 then r = 0
sync
loop
function ActionBox(x1,y1,x2,y2,color1,color2)
if mousex() > x1 and mousex() < x2 and mousey() > y1 and mousey() < y2
ink color1,0
action = 1
else
ink color2,0
action = 0
endif
box x1,y1,x2,y2
endfunction action
function CreateBox(x1,y1,x2,y2,color1,color2)
ink color1,0
box x1,y1,x2,y2
ink color2,0
line x1,y1,x2,y1
line x1,y1,x1,y2
line x1,y2,x2,y2
line x2,y1,x2,y2
endfunction
The problem is adding the mail text to an array that allows me to do this.
I've tried this:
+ Code Snippetfunction Add_Mail_Text(file$)
open to read 1,file$
for x = 1 to 10000 `line count
Read String 1,T$: txt$=T$
`At the end of the txt i put this "}" to stop add empty lines
if txt$="}" then exitfunction
Itm_Add_String(txt$)
next x
close file 1
endfunction
function Itm_Add_String(txt$)
array insert at bottom Mail$()
LineCount = array count(Mail$())
Mail$(LineCount).txt = txt$
endfunction
That works great for one file, but I need it to work for multiple files.
This is what i'm using to get the subject and name of sender of each file:
+ Code Snippet find first
while get file type()>-1
file$=get file name$()
array insert at bottom filelist$()
filelist$()=file$
find next
endwhile
for x = 3 to array count(filelist$())
open to read x,filelist$(x)
Read String x,T$: sub$=right$(T$,len(T$)-9)
Read String x,T$: name$=right$(T$,len(T$)-6)
Read String x,T$: `Ignore
Itm_Add_Mail(sub$,name$)
close file x
next x
Somehow, I need to merge these together but i'm stuck. I thought of using multi-arrays, but haven't tried that yet. Any idea?