Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Will anyone help me with my project?
#21
I updated everything. Meg thanks for all your help....
Also: That dim shared thing doesn't work so i didn't use it
Here is the update

DECLARE SUB editvid ()
DECLARE SUB addvid ()
DECLARE SUB delvid ()
DECLARE SUB listvid ()
DECLARE SUB searchvid ()
DECLARE SUB LEAVE ()
DECLARE SUB mainmenu ()
TYPE videotype
id AS INTEGER
vidname AS STRING * 50
vidgenre AS STRING * 50
vidactor AS STRING * 50
vidratin AS STRING * 50
END TYPE
DIM vid AS videotype




CLS
mainmenu

SUB addvid

DIM vid AS videotype
OPEN "vid.dat" FOR RANDOM AS #1 LEN = LEN(vid)
DO UNTIL response$ = "n"
INPUT "please enter video's barcode number", id
vid.id = id

INPUT "enter name of video", vid.vidname

INPUT "enter main actor of film", vid.vidactor

INPUT "enter rating of video ?/10 ", vid.vidratin

INPUT "enter genre of the movie being borrowed", vid.vidgenre


PRINT "you added a new video"
PUT #1, id, vid


INPUT "do you want to add any another videos? y-Yes, n-No ", response$
LOOP
CLOSE #1

END SUB

SUB delvid
DIM vids AS videotype

END SUB

SUB editvid
END SUB

SUB LEAVE
PRINT "Goodbye user!!!!!"
END SUB

SUB listvid
END SUB

SUB mainmenu
COLOR 10
20 PRINT "WELCOME TO VIDEOTRONICS DATABASE"
30 PRINT "Please Select an Option from below"
40 PRINT "1 - To add a new video"
50 PRINT "2 - Delete a video"
60 PRINT "3 - List all videos"
70 PRINT "4 - search a video"
80 PRINT "5 - Edit video details"
90 PRINT "6 - EXIT DATABASE "
100 INPUT C
SELECT CASE C
CASE IS = 1
addvid
CASE IS = 2
delvid
CASE IS = 3
listvid
CASE IS = 4
searchvid
CASE IS = 5
editvid
CASE IS = 6
LEAVE
CASE ELSE
PRINT "You inserted an invalid option"
GOTO 100
260 END SELECT


END SUB

SUB searchvid
DIM vid AS videotype
CLS
DO UNTIL response$ = "n"
INPUT "please enter video's bar code number", id
vid.id = id


OPEN "vid.dat" FOR RANDOM AS #1
GET #1, id, vid




PRINT "This is the video's name", vid.vidname
PRINT "this is the video's genre", vid.vidgenre
PRINT " this is the video's main actor", vid.vidactor
PRINT "this is the video's rating", vid.vidratin
INPUT " Do you wish to search for another record?", response$
LOOP
CLOSE #1

END SUB



Meg could you also give me a tip on what i should do for the delete sub and the list sub. I wanna make sure that my idea is precise.

PS: I was just looking at the marking scheme for this project, it goes for 30% of part of our final exams. And guess what, this program is like 5 marks only. But without it we won't be able to do the rest.
ill Gates time is almost up.... i am taking over
Reply
#22
What happened? Just a few minutes ago i started getting an eroor int he open statement. PERMISSION DENIED? HOW

SUB addvid

DIM vid AS videotype
OPEN "vid.dat" FOR RANDOM AS #1 LEN = LEN(vid)
DO UNTIL response$ = "n"
INPUT "please enter video's barcode number", number
vid.id = number

INPUT "enter name of video", vid.vidname

INPUT "enter main actor of film", vid.vidactor

INPUT "enter rating of video ?/10 ", vid.vidratin

INPUT "enter genre of the movie being borrowed", vid.vidgenre


PRINT "you added a new video"
PUT #1, id, vid


INPUT "do you want to add any another videos? y-Yes, n-No ", response$
LOOP
CLOSE #1

END SUB

Could you see if you spot any error? I not seeing any. How can it go from running smoothly to errors?
ill Gates time is almost up.... i am taking over
Reply
#23
alright, i'm not sure why the DIM SHARED won't work for you.

in your addvid you are INPUTting "number" but PUTting to slot "id".. pick one and be consistent with it. if you input "number", then

PUT #1, number, vid

in your searchvid you OPEN the file *inside* your loop, without CLOSEing (the CLOSE command is outside the loop). This means if you search more than once, the program will try to OPEN a file that's already OPEN. Move the OPEN statement outside the DO/LOOP.

*peace*

Meg.
Reply
#24
I have some remarks why the DIM SHARED doesn't work:

#1. Remove all normal DIMs from the SUBs as these are not necessary anymore, and to reset it don't re-dim it but just set some values.

#2. In the sub searchvid add a LEN = LEN(vid) to the OPEN command

For the rest it seems to work fine for me.
Reply
#25
WHAT IN GODS NAME:

TEH THING WORKED!!! IT WORKED!!!! IT WORKED!!! MY ADD AND SEARCH WORKED!!!!!!!!! YIPPE KI YA.

(RUNS AND KISSES MEG)

DUDE!!!!! IT WORKED!!!!

CHECK IT:


DECLARE SUB editvid ()
DECLARE SUB addvid ()
DECLARE SUB delvid ()
DECLARE SUB listvid ()
DECLARE SUB searchvid ()
DECLARE SUB LEAVE ()
DECLARE SUB mainmenu ()
TYPE videotype
id AS INTEGER
vidname AS STRING * 50
vidgenre AS STRING * 50
vidactor AS STRING * 50
vidratin AS STRING * 50
END TYPE
DIM vid AS videotype





CLS
mainmenu

SUB addvid

DIM vid AS videotype

OPEN "vid.id" FOR RANDOM AS #1 LEN = LEN(vid)



DO UNTIL response$ = "n"
INPUT "please enter video's barcode number", number
vid.id = number

INPUT "enter name of video", vid.vidname

INPUT "enter main actor of film", vid.vidactor

INPUT "enter rating of video ?/10 ", vid.vidratin

INPUT "enter genre of the movie being borrowed", vid.vidgenre


PRINT "you added a new video"
PUT #1, vid.id, vid


INPUT "do you want to add any another videos? y-Yes, n-No ", response$
LOOP
CLOSE #1

END SUB

SUB delvid
DIM vid AS videotype

END SUB

SUB editvid
END SUB

SUB LEAVE
COLOR 9
PRINT "Goodbye user!!!!!"
PRINT "Come Back Soon"

END SUB

SUB listvid
END SUB

SUB mainmenu
COLOR 10
20 PRINT "WELCOME TO VIDEOTRONICS DATABASE"
30 PRINT "Please Select an Option from below"
40 PRINT "1 - To add a new video"
50 PRINT "2 - Delete a video"
60 PRINT "3 - List all videos"
70 PRINT "4 - search a video"
80 PRINT "5 - Edit video details"
90 PRINT "6 - EXIT DATABASE "
100 INPUT C
SELECT CASE C
CASE IS = 1
addvid
CASE IS = 2
delvid
CASE IS = 3
listvid
CASE IS = 4
searchvid
CASE IS = 5
editvid
CASE IS = 6
LEAVE
CASE ELSE
PRINT "You inserted an invalid option"
GOTO 100
260 END SELECT


END SUB

SUB searchvid
DIM vid AS videotype
CLS
DO UNTIL response$ = "n"
INPUT "please enter video's bar code number", number
vid.id = number

OPEN "vid.id" FOR RANDOM AS #1 LEN = LEN(vid)
GET #1, vid.id, vid
CLOSE #1





PRINT "This is the video's name", vid.vidname
PRINT "this is the video's genre", vid.vidgenre
PRINT " this is the video's main actor", vid.vidactor
PRINT "this is the video's rating", vid.vidratin
INPUT " Do you wish to search for another record?", response$
LOOP
CLOSE #1

END SUB

CAN YOU BELIEVE IT???

HEY COULD YOU GIVE ME AN IDEA ON HOW I SHOULD GO ABOUT THE DELETEVID???
ill Gates time is almost up.... i am taking over
Reply
#26
you can set record elements blank, then PUT to file?

if you remove the DIM statements from inside your SUBS, and change the DIM that's right underneath your TYPE block to a DIM SHARED, it should work.
Reply
#27
Thanks but the add and search is working. I got till monday guys so hurry and tell me/teach me how i gotta go about deleting? Do i gotta close#1 or sumtin?
ill Gates time is almost up.... i am taking over
Reply
#28
Smile If you want to delete a file, say "File.TXT" then you..

Code:
KILL "File.TXT"

That deletes,. :wink:
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#29
Okay but wouldn't that close my entire program?

You see it is a video store. Say i wanna delete information on say Bourne Identity, how can i delete it without deleting all my files?
ill Gates time is almost up.... i am taking over
Reply
#30
Think about it like this: erasing a record in your file is the same thing as adding a BLANK record to that id slot in the file. So set all your record elements to empty strings and zeros, and PUT it into the file, overwriting the existing video. Savvy?

Meg.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)