Posted: 7th May 2007 0:53
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 Snippet
Rem ***** 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 Snippet
function 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?
Posted: 7th May 2007 12:00
This is what i've got so far:
+ Code Snippet
Rem ***** Main Source File *****
set display mode 1024,768,32
sync : sync rate 0

set text font "Arial"

MaxFiles = 128
MaxLines = 1024

dim MyArray$(MaxFiles,MaxLines)
Add_Mail("Mail")

do : cls

   for x = 0 to 5
       x1 = 12
       y1 = 12 + (12 * x)
       ink RGB(255,255,255),0
       text x1,y1,""+MyArray$(0,x)
   next x

   sync
loop

function Add_Mail(dir$)
   set dir dir$
   dim filelist$(0)

   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)
         for y = 0 to 1024
            Read String x,T$ : txt$=T$
            if txt$="}" then exitfunction
            MyArray$(x-3,y)=txt$
         next y
      close file x
   next x

   dir
   set dir ".."
endfunction


It only works for the first file and how can I get an array count for the lines of a the file(MyArray$(file,lines)).
Posted: 7th May 2007 13:39
When dealing with multiple files Array Count will return your Dimension1 * Dimension2 and return the total amount of cells, I'm also not totally sure if you can insert into an array either, because it'd have to insert a whole new row. Your best bet would be to manually store the array dimension, eg. Files = 5 , Messages = 10 and every time the array needs to be changed just call Dim and redeclare the array, this will work very similar to the inserting method only you can insert multiple lines or remove them without loss of the main array data.
Posted: 7th May 2007 13:45
Or you could perform a check for the number of lines in a file like this (Maxlines would need to be global):

+ Code Snippet
function Line_Count(file)
     total_count=0

     for line = 1 to MaxLines
          if MyArray$(file,line)<>"" rem <<<--- "" is what an empty line would have.

                INC Total_Count,1

          ENDIF

     next line
ENDFUNCTION Total_Count
Posted: 7th May 2007 14:26
Or, use a 'While NOT File End(1)' loop which will terminate when you reach the EOF.
Posted: 10th May 2007 11:03
Here a little demo of what I've got. If you click on any of the subjects a mail box will appear. To close the mail box just click anywhere around it. If you click on the last subject, you can scroll down the text using the "-" and "+" symbols. Tell me what you think.

All I need is some kind of indication of how big the text file is and some sort of filling system that rename the files to put them into a chose order.

*Forgot to add, it only runs in 1024x768 at the moment.
Posted: 15th May 2007 16:01
If anyone could try the demo on the last post and tell me what you think, that would be great.

Ok, new problem. Example first:
+ Code Snippet
item(x).id = apple
item(x).name = "Apple"
item(x).weight = 0.3
item(x).cost = 2


If I got the id of the item how would I get the rest of the info for that item.
Posted: 15th May 2007 20:33
I tried this but i'd rather have id as a word, anyone got a solution.

+ Code Snippet
type items
   id as string
   name as string
   weight as float
   cost as integer
endtype

dim item(-1) as items

add_item("itm_apple","Apple",0.3,2)
add_item("itm_orange","Orange",0.2,3)


do : cls

   `Get item name using id
   slot = get_item_info( "itm_orange" )
   text 0,0,"Name: "+item(slot).name
   text 0,12,"Weight: "+str$(item(slot).weight,2)
   text 0,24,"Cost: "+str$(item(slot).cost)

loop

function add_item( id as string ,name$,weight#,cost)
   array insert at bottom item(0)
   itemslot = array count(item(0))
   item(itemslot).id = id
   item(itemslot).name = name$
   item(itemslot).weight = weight#
   item(itemslot).cost = cost
endfunction

function get_item_info( id as string )
   for itemslot = 0 to array count(item(0))
      if item(itemslot).id = id then exitfunction itemslot
   next itemslot
endfunction itemslot
Posted: 24th Jul 2007 13:21
Sorry to bring this up again but if anyone could try the demo three posts up and tell me what you think, that would be great.
Posted: 24th Jul 2007 15:41
You intend to want a database.
A relational database.
It is the Max number of data, Max size(Mbyte) of the data that it is necessary first.
It is decided whether you choose a database of which kind in this.

Referentially
http://forum.thegamecreators.com/?m=forum_view&t=110011&b=1
Posted: 24th Jul 2007 17:32
How did I miss that thread, it's quite good. Cheers pcRaider

One more thing, did you test the demo?
Posted: 24th Jul 2007 19:23
MailingSystem.exe
This is well-done very much.
The one where character set is bigger is easy to read.
When a mouse wheel is usable for scroll, it is still good.

TheRoadtoApocalypse(2005-2143). txt
I read very interestingly.
I am a pleasure as an SF - RPG.

I like "James P. Hogan".
I love "Inherit The Stars".
http://en.wikipedia.org/wiki/Giants_series

database
If it is brief contents, I will be possible only in DarkBasic.
Posted: 24th Jul 2007 20:03
Cheers pcRaider. You can add your own mail if you want, just make a text file in the mail directory and write this in the text file.

+ Code Snippet
date: "<your date here>"
to: "none" (hasn't been implemented yet)
from: "<from your choice>"
subject: "<name of the subject>"
text
{
<your mail>
}


Currently you can have up to 17 files of mail witch can include up to one thousand lines in your message. I will edit these, so you can have up to a 5 MB of mail space and can contain up to 10000 lines of text and I'll add video mail at some point. There’s no option to create/ delete or sort yet, but this is all simple stuff.

If you want to read the rest of the Neocron Evolution 2.2 history check out the link:
http://ng.neocron.com/index.php?id=34
Posted: 25th Jul 2007 0:36
Is there anyone else willing to try the demo out 7 posts up. Just want to get some opinions on it. There maybe something that is vital to a mailling system I'm missing. I know I need some kind of indication of if theres more lines further down the message box and word count, but there might be other stuff I've looked over.
Posted: 25th Jul 2007 1:04
Very nice smooth interface, two main comments:

Have an X button to close messages rather than having to click off the message maybe?
Also, you have scroll arrows, but no click/drag scroll button like most windowed based systems have.

Just some thoughts
Posted: 25th Jul 2007 1:23
Cheers for the comments malcom2073. I thought about having an X button but never put one in. Click/drag, I never even thought about that, cheers for reminding me.

Anyone else? need more ideas.