Help with a database program
Author |
Message |
JR
|
Posted: Wed Mar 10, 2004 9:46 am Post subject: Help with a database program |
|
|
hey, this is a program i made and it stores some book names ect, but when i try to output it i get some bugs and some other stuff. Can u help me fix it? thx and is there an easier way to put all those lines? instead of alot of lines like less.
code: |
var num : int
var x : int
var ch : string (1)
var key : string (1)
var data : string
var bookname : array 1 .. 50 of string
var author : array 1 .. 50 of string
var YOP : array 1 .. 50 of string
var category : array 1 .. 50 of string
proc getKey
getch (ch)
end getKey
proc menu
cls
drawfillbox (230, 390, 320, 440, 50)
var font1 : int
font1 := Font.New ("Impact:24")
Font.Draw ("Menu", 250, 400, font1, blue)
font1 := Font.New ("Impact:14")
Font.Draw ("Choice 1: Enter Data", 220, 350, font1, black)
Font.Draw ("Choice 2: View Data", 220, 300, font1, black)
Font.Draw ("Choice 3: Save Data", 220, 250, font1, black)
Font.Draw ("Choice 8: Exit", 220, 200, font1, black)
put ""
end menu
menu
open : x, "H://A5/x.txt", put, get
loop
locate (15, 1)
put "What is your choice ?"
getch (key)
menu
locate (20, 1)
for i : 1 .. 50
exit when index ("8", key) > 0
if index ("1", key) > 0 then
put "Enter the book name: "
get bookname (i) : *
put "Enter book author: "
get author (i) : *
put "Enter year of publish: "
get YOP (i) : *
put "Enter category: "
get category (i) : *
locate (25, 1)
%press q twice to return to menu, if you wont press q you will just repat the process
%all over agian
getKey
exit when ch = "q"
elsif index ("2", key) > 0 then
put "Here is the book data"
put "BookName: ", bookname (i)
put "Author: ", author (i)
put "Year of publish: ", YOP (i)
put "Category ", category (i)
elsif index ("3", key) > 0 then
var persent, progress : int := 0
setscreen ("graphics:650;420")
locate (9, 37)
loop
for b : 1 .. 1
drawfillbox (80 + progress, 185, 85 + progress, 225, 32)
delay (30)
progress += 5
end for
for a : 1 .. 1
persent += 1
delay (10)
locate (10, 40)
put " "
locate (10, 40)
put "Saving... ", persent, " %"
end for
exit when persent = 100
drawbox (75, 180, 585, 230, black)
end loop
cls
put : x, data
put " Your data has been saved"
end if
end for
end loop
close : x
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Paul
|
Posted: Wed Mar 10, 2004 11:58 am Post subject: (No subject) |
|
|
The locate thingy doesn't work well on the school resolution
and here
code: |
put "BookName: ", bookname (i)
put "Author: ", author (i)
put "Year of publish: ", YOP (i)
put "Category ", category (i)
|
this runs 50 times, during the for loop I think, and if the user only enters one list of stuff, bookname (49) or whatever won't have any values. And so it won't output it.
so if you do this:
code: |
for a: 1..50
bookname (a):=""
author(a):=""
YOP(a):=""
category(a):=""
end for
|
it will actually show everything, including the blank info, but that sux, so you need to have an if statement going something like this:
code: |
if bookname(a) not = "" then
put bookname(a)
put author(a)
end if
|
and so on, also fix your formatting. |
|
|
|
|
|
JR
|
Posted: Thu Mar 11, 2004 9:37 am Post subject: (No subject) |
|
|
where do i exactly put those lines? |
|
|
|
|
|
Paul
|
Posted: Thu Mar 11, 2004 4:43 pm Post subject: (No subject) |
|
|
The first one you can put after your variables if you like, the second one is used to check if there is info in your variables, and if there is, it outputs it. So when a user goes to "View Data" or something, you put it there to output the data, so it won't output spaces. |
|
|
|
|
|
JR
|
Posted: Thu Mar 11, 2004 6:01 pm Post subject: (No subject) |
|
|
ok i put it like that and it still doesnt work.
code: | var num : int
var x : int
var answer : string
var key : string (1)
var data : string
var bookname : array 1 .. 50 of string
var author : array 1 .. 50 of string
var YOP : array 1 .. 50 of string
var category : array 1 .. 50 of string
proc menu
cls
drawfillbox (230, 390, 320, 440, 50)
var font1 : int
font1 := Font.New ("Impact:24")
Font.Draw ("Menu", 250, 400, font1, blue)
font1 := Font.New ("Impact:14")
Font.Draw ("Choice 1: Enter Data", 220, 350, font1, black)
Font.Draw ("Choice 2: View Data", 220, 300, font1, black)
Font.Draw ("Choice 3: Save Data", 220, 250, font1, black)
Font.Draw ("Choice 8: Exit", 220, 200, font1, black)
put ""
end menu
menu
open : x, "H://A5/x.txt", put, get
loop
locate (15, 1)
put "What is your choice ?"
getch (key)
menu
locate (20, 1)
for i : 1 .. 50
exit when index ("8", key) > 0
if index ("1", key) > 0 then
put "Enter the book name: "
get bookname (i) : *
put "Enter book author: "
get author (i) : *
put "Enter year of publish: "
get YOP (i) : *
put "Enter category: "
get category (i) : *
locate (25, 1)
put " do you want to add another book? "
get answer
if answer = "yes" then
put " "
elsif answer = "no" then
cls
menu
exit
end if
elsif index ("2", key) > 0 then
for a : 1 .. 50
bookname (a) := ""
author (a) := ""
YOP (a) := ""
category (a) := ""
if bookname (a) not= "" then
put bookname (a)
put author (a)
put "BookName: ", bookname (i)
put "Author: ", author (i)
put "Year of publish: ", YOP (i)
put "Category ", category (i)
end if
end for
elsif index ("3", key) > 0 then
var persent, progress : int := 0
setscreen ("graphics:650;420")
locate (9, 37)
loop
for b : 1 .. 1
drawfillbox (80 + progress, 185, 85 + progress, 225, 32)
delay (30)
progress += 5
end for
for a : 1 .. 1
persent += 1
delay (10)
locate (10, 40)
put " "
locate (10, 40)
put "Saving... ", persent, " %"
end for
exit when persent = 100
drawbox (75, 180, 585, 230, black)
end loop
cls
put : x, data
put " Your data has been saved"
end if
end for
end loop
close : x
|
|
|
|
|
|
|
Thuged_Out_G
|
Posted: Thu Mar 18, 2004 12:47 am Post subject: (No subject) |
|
|
well you see...with this code you have here
code: |
for a : 1 .. 50
bookname (a) := ""
author (a) := ""
YOP (a) := ""
category (a) := ""
if bookname (a) not= "" then
put bookname (a)
put author (a)
|
your setting the array equal to nothing...and then saying, if blah isnt equal blank then put the info...but you are already setting it to be blank, so it will always be blank lol |
|
|
|
|
|
JR
|
Posted: Thu Mar 18, 2004 3:27 pm Post subject: (No subject) |
|
|
so how do i fix it? |
|
|
|
|
|
Thuged_Out_G
|
Posted: Thu Mar 18, 2004 4:56 pm Post subject: (No subject) |
|
|
ugh...your code is messy...you should make everything a procedure |
|
|
|
|
|
Sponsor Sponsor
|
|
|
JR
|
Posted: Sun Mar 21, 2004 3:07 pm Post subject: (No subject) |
|
|
bah i cant figure it out, can u plz help me? |
|
|
|
|
|
|
|