TGC Codebase Backup



AGS Address Database by AGS

12th Apr 2004 13:39
Summary

This is a program which stores your address's, phone numbers etc and allows you to search and onpen files you have made with it.



Description

This program allows you to enter peoples information. Address, postcode, phone numbers etc then saves them as txt files in a folder it creates. You can then use it to search for files you have created and it dispays them for you. Instructions are on the tab menus Main Menu option.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    remstart ***************************************************
************************************************************
************** AGS : Address Program ***********************
************************************************************
******************Aaron Gibson *****************************
************************************************************
remend *****************************************************


IF FILE EXIST("AGS/") = 1
goto abc
else
Make directory "AGS"
endif

ABC:
set window on
set window title "AGS: Address Database.v2"
set window size 580,284
set window layout 0,1,1
set window position 240,250
hide mouse

load image "2logosmall.bmp",4
load image "2box.bmp",3
load image "1logo.bmp",1
load image "1logo2.bmp",2
paste image 3,20,90
paste image 1,22,98

set cursor 240, 310
print "Todays Date: "; GetDate("long")

set cursor 160,290

`display the delay message

PRINT "Loading";
wait 1000
`delay for 2 seconds
SLEEP 500
PRINT ".";
SLEEP 500
PRINT ".";
SLEEP 500
PRINT ".";
SLEEP 500
PRINT ".";
PRINT

wait 1000

date:
rem DATE

DATA "January","February","March","April","May","June"
DATA "July","August","September","October","November","December"
DIM Months$(12)

REM Fill the Months array
FOR N = 1 TO 12
    READ Months$(N)
NEXT N

goto mini
end

FUNCTION GetDate(format$)
    REM Initialize variables
    Date$ = ""
    Year$ = ""
    Month = 0
    Day = 0

    REM Retrieve month, day, year
    Year$ = "20" + RIGHT$(GET DATE$(), 2)
    Month = VAL(LEFT$(GET DATE$(), 2))
    Day = VAL(LEFT$(RIGHT$(GET DATE$(), 5), 2))

    REM Return long date
    IF format$ = "long"
        Date$ = Months$(Month) + " " + STR$(Day)
        Date$ = Date$ + ", " + Year$
    ENDIF
ENDFUNCTION Date$


mini:

set window on
set window title "AGS: Address Database.v2"
set window layout 0,1,1
clear camera view 1
load image "5blue.bmp",5
paste image 5,190,20
load image "6black.bmp",6
paste image 6,230,125
set window size 200,280
load image "2logosmall.bmp",4
paste image 4,220,108
set cursor 253,210
ink rgb(255,255,255),0
print "DATABASE SYSTEM"

set window position 300,50

yes1_menu$="Add Address"
no11_menu$="Main Page"
yes11_menu$="Search System"
yes12_menu$="Close AGS Database"

x1=270
y1=300

x2=245
y2=250

x3=270
y3=280

x4=255
y4=340

h4=text height(yes12_menu$)
w4=text width(yes12_menu$)

h3=text height(yes1_menu$)
w3=text width(yes1_menu$)

h2=text height(no11_menu$)
w2=text width(no11_menu$)

h1=text height(yes11_menu$)
w1=text width(yes11_menu$)


` Text on Menu
do
if shiftkey()=1
GOTO small
endif

` If Yes is Clicked
if mousex()>=x1 and mousex()<=x1+w1 and mousey()>=y1 and mousey()<=y1+h1
      ink rgb(0,232,0),0
      rollover=2
      if mouseclick()=1 then goto 4
   else
  ink rgb(255,255,255),0
      rollover=1
   endif
   text x1,y1,yes11_menu$


` If Yes is Clicked
if mousex()>=x3 and mousex()<=x3+w3 and mousey()>=y3 and mousey()<=y3+h3
      ink rgb(0,232,0),0
      rollover=2
      if mouseclick()=1 then goto 2
   else
  ink rgb(255,255,255),0
      rollover=1
   endif
   text x3,y3,yes1_menu$

` If Yes is Clicked
if mousex()>=x4 and mousex()<=x4+w4 and mousey()>=y4 and mousey()<=y4+h4
      ink rgb(200,0,0),0
      rollover=2
      if mouseclick()=1 then end
   else
  ink rgb(100,0,0),0
      rollover=1
   endif
   text x4,y4,yes12_menu$


` If No is Clicked
if mousex()>=x2 and mousex()<=x2+w2 and mousey()>=y2 and mousey()<=y2+h2
      ink rgb(0,232,0),0
      rollover=2
      if mouseclick()=1 then goto big_page
   else
  ink rgb(255,255,255),0
      rollover=1
   endif
   text x2,y2,no11_menu$
loop
end


small:


set window size 178,60
set window layout 0,0,1
paste image 4,220,192
set window position 800,600
wait key
goto mini


2:

set window on 
set window title "New Address"
set window layout 0,1,1
ink rgb(255,255,255),0
clear camera view 1

set window size 300,250
set window position 100,100
load image "10logosmall.bmp",10
paste image 10,220,130
set cursor 200,250
Print "NEW USER LOG"
print
set cursor 200,290
input "Continue? Y/N : ";go$
if go$ = "yes"
goto ml
endif
goto mini

ML:
set window on 
set window title "New Address"
set window layout 0,1,1
ink rgb(255,255,255),0
clear camera view 1

load image "7logo.bmp",7
paste image 7,120,10
set window position 100,100
set cursor 250,200
Print "ADDRESS DETAILS"
print
input "          Name: ";uname$


IF FILE EXIST("AGS/"+uname$+".txt") = 1
print 
print "User name already authenicated"
wait 1000
print "Booting system.."
wait 2000
print
input "Replace user?  Y/N : ";replace$
if replace$ = "yes"
    DELETE FILE "AGS/"+uname$+".txt"
goto passwords
endif
endif

passwords:
clear camera view 1
set cursor 0,200
load image "7logo.bmp",7
paste image 7,120,10


input "          Age: ";a$
print
print "          ADDRESS"
input "          Line 1: ";dlevel$
input "          Line 2: ";dlevel2$
input "          Line 3: ";s$
input "          Town  : ";town$
input "          County: ";county$
input "          Postcode: ";pcode$
print
print "          Contact Numbers"
input "          Home Number: ";wness$
input "          Work Number: ";workn$
print
input "          Mobile Number: ";strong$

clear camera view 1
paste image 3, 310,-50
set cursor 0,100
OPEN TO WRITE 1, "AGS/"+ uname$ +".txt"

WRITE STRING 1,uname$
WRITE STRING 1,a$
WRITE STRING 1,dlevel$
WRITE STRING 1,dlevel2$
WRITE STRING 1,s$
WRITE STRING 1,Town$
WRITE STRING 1,county$
WRITE STRING 1,pcode$
WRITE STRING 1,wness$
WRITE STRING 1,workn$
WRITE STRING 1,strong$

CLOSE FILE 1
PRINT "         Creating the file."
wait 1000
PRINT "         Now clearing the Variables"
uname$ = uname$
pword$ = ""
PRINT
PRINT "         Variables are cleared!"
PRINT "         Now reading the data from the file."
OPEN TO READ 1,"AGS/"+uname$+".txt"
READ STRING 1, uname$
READ STRING 1, a$
READ STRING 1, dlevel$
READ STRING 1, dlevel2$
READ STRING 1, s$
READ STRING 1, Town$
READ STRING 1, County$
READ STRING 1, pcode$
READ STRING 1, wness$
READ STRING 1, workn$
READ STRING 1, strong$

print
print "          DETAILS:"
print
PRINT "             New user: "+ uname$
Print 
print
print "             ADDRESS"
print 
print "            "+dlevel$
print "            "+dlevel2$
print "            "+s$
print "            "+Town$
print "            "+County$
print "            "+Pcode$
print
print "            "+wness$
print "            "+workn$
print "            "+strong$

close file 1
wait key
goto mini
end


big_page:

ink rgb(255,255,255),0
clear camera view 1
set window off
load image "8fire.bmp",8
paste image 8,20,260
load image "7logo.bmp",7
paste image 7,-1,0
ink rgb(255,255,255),0
set text size 30
center text 180,200, "Instructions"
set text size 10
set cursor 0,250
print "AGS: ADDRESS DATABASE"
print
print "This database stores all information in"
print "text documents outside the program in"
print "folder "AGS" for easy access"
print
print "Use the links to input and display data"
print "from the database"
print
print "To start using the database, follow the"
print "link back to tab menu"
 
load image "9menu.bmp",9
paste image 9,370,195
wait key

ink rgb(255,255,255),0
clear camera view 1
load image "8fire.bmp",8
paste image 8,20,260
load image "7logo.bmp",7
paste image 7,-1,0
ink rgb(255,255,255),0
set text size 30
center text 180,200, "Instructions"
set text size 10
load image "9menu.bmp",9
paste image 9,370,195
set cursor 0,250
print "AGS: ADDRESS DATABASE"
print
print "The tab menu controls the whole system"
print
print "When the program is not in use you can"
print "minamize it to a small rectangle in the""
print "corner of the screen by pressing the"
print "shift key"
print
print "To start using the database, follow the"
print "link back to tab menu"


menu$="Tab Menu"

x2=160
y2=450
h2=text height(menu$)
w2=text width(menu$)

do
` If No is Clicked
if mousex()>=x2 and mousex()<=x2+w2 and mousey()>=y2 and mousey()<=y2+h2
      ink rgb(0,232,0),0
      rollover=2
      if mouseclick()=1 then goto mini
   else
  ink rgb(255,255,255),0
      rollover=1
   endif
   text x2,y2,menu$
loop
end


ccd:
close file 1

4:

ink rgb(255,255,255),0
clear camera view 1
SET window on
set window title "Address Search"
set window layout 0,1,1
load image "7logo.bmp",7
paste image 7,200,10
set window position 100,100
set cursor 0,200
print " ADDRESS LOG SEARCH"
PRINT
print
PRINT
PRINT "   INSTRUCTIONS"
print
print "         To use this part of the program you have to"
print "         enter a name."
print
print "         If the name is in the log files then their"
print "         details will be displayed."
print "         If the name is not in the log files then" 
Print "         you will have the option to add them"
print
find:
input "  Search name: " ; putin$
print
print "  Searching......"
wait 1000


IF FILE EXIST("AGS/"+putin$+".txt") = 1
open to read 1, "AGS/"+putin$+".txt"
goto ab
else 
print
set cursor 350,300
print "Name does'nt exit"
print
nm:
set cursor 350,340
input "Create user  Y/N?: ";ans$
if ans$ = "yes"
goto ML
endif
goto 4
endif

ab:

READ STRING 1,name1$
READ STRING 1,age1$
read STRING 1,add1$
read STRING 1,add2$
read STRING 1,add3$
read STRING 1,town$
read STRING 1,county$
read string 1,pcode$
read STRING 1,number$
read string 1,workn$
read STRING 1,mobile$

clear camera view 1
load image "7logo.bmp",7
paste image 7,200,100
set cursor 0,30

print "  LOG FOUND"
print
print "  Details:"
print
print 
print "  Name: " + name1$
print "  Age: " + age1$
print 
print "  ADDRESS"
print
print "    "+add1$
print "    "+add2$
print "    "+add3$
print "    "+town$
print "    "+county$
print "    "+pcode$
print
print "  CONTACT NUMBERS"
print
print "  Home Number: " + number$
print "  Work Number: " + workn$
print "  Mobile: " + mobile$
print
print
print
close file 1

yes1_menu$="Search again"
no11_menu$="Tab Menu"

x2=200
y2=420

w2=text width(no11_menu$)
h2=text height(no11_menu$)

x3=350
y3=420

w3=text width(yes1_menu$)
h3=text height(yes1_menu$)


` Text on Menu
do

` If Yes is Clicked
if mousex()>=x3 and mousex()<=x3+w3 and mousey()>=y3 and mousey()<=y3+h3
      ink rgb(0,232,0),0
      rollover=2
      if mouseclick()=1 then goto 4
   else
  ink rgb(255,255,255),0
      rollover=1
   endif
   text x3,y3,yes1_menu$

` If No is Clicked
if mousex()>=x2 and mousex()<=x2+w2 and mousey()>=y2 and mousey()<=y2+h2
      ink rgb(0,232,0),0
      rollover=2
      if mouseclick()=1 then goto mini
   else
  ink rgb(255,255,255),0
      rollover=1
   endif
   text x2,y2,no11_menu$
loop
end

wait key