Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,399 Programmers. There are 1,472 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

error message "type not defined"

 
Reply to this topicStart new topic

error message "type not defined", it is defined... or so i thought

tootintorrey
post 22 Apr, 2008 - 02:23 PM
Post #1


New D.I.C Head

*
Joined: 24 Mar, 2008
Posts: 13



some more basic fun. i needed to write 2 programs one using a random access file for a library to calculate fines and another to display them. im putting the two together just because its really not that hard but i keep getting an error saying "type not defined" in my sub function.
sub addfines (library as libraryfines) blink.gif

anyways heres what i got if anyone can point out where it needs to be defined.

[code]
CLS

TYPE libraryfine
person AS STRING * 25
title AS STRING * 25
book AS INTEGER
days AS INTEGER
END TYPE
DIM library AS libraryfine

OPEN "LIBRARY.DAT" FOR RANDOM AS #1 LEN = LEN(library)
'***** is this not where its defined? whatsthat.gif^*****

DO UNTIL choice = 3
CLS
PRINT "School Library Fine Database"
PRINT
PRINT "1. Enter new fines."
PRINT "2. Display student fines."
PRINT "3. Finished "
PRINT

INPUT "Enter choice (1-3)", choice

SELECT CASE choice
CASE 1
CASE 2
CALL displayfines(library)
CASE 3
CLOSE #1
PRINT "Thank you"
CASE ELSE
PRINT
PRINT "Answer must be 1, 2 or 3."
END SELECT
LOOP
CLOSE #1





SUB addfines (library AS libraryfines)

CLS
INPUT "Enter Student's Name: ", library.person
INPUT "Enter Book's Title: ", library.title
INPUT "Enter Type of Book (1 or 2): ", library.book
INPUT "Enter Days Overdue: ", library.days

PUT #1, 1, person
PUT #1, 2, title
PUT #1, 3, book
PUT #1, 4, days


END SUB



SUB displayfine (library AS libraryfine)

INPUT "Enter Student's name: ", person
GET #1, 1, person
GET #1, 2, title
GET #1, 3, book
GET #1, 4, days

IF book = 1 THEN
total = .25 * days
ELSE
total = .4 * days
END IF

PRINT "Name"; TAB(5); "Book Title"; TAB(5); "Book Type"; TAB(5); "Days Late"
PRINT fines.person; fines.title; fines.book; fines.days
PRINT
PRINT "Total Amount due: $"; total
PRINT

END SUB
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


jjsaw5
post 23 Apr, 2008 - 05:08 AM
Post #2


D.I.C Addict

Group Icon
Joined: 4 Jan, 2008
Posts: 541

Please use code tags next time.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

tootintorrey
post 24 Apr, 2008 - 12:07 PM
Post #3


New D.I.C Head

*
Joined: 24 Mar, 2008
Posts: 13

if you look i did use code tags i just didnt put the /code at the end.

and i decided to get rid of the subs but now i cant get the information to display lol im going to work on it some more but if i cant figure it out ill post my code again to see if someone can find the error
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

tootintorrey
post 28 Apr, 2008 - 04:24 PM
Post #4


New D.I.C Head

*
Joined: 24 Mar, 2008
Posts: 13

alrighty i got this working sort of. i can enter the information but i cannot get it to display (as in choice 2). any ideas?

CODE

TYPE libraryfine
        person AS STRING * 25
        title AS STRING * 25
        book AS INTEGER
        days AS INTEGER
        recnum AS INTEGER
END TYPE


DIM library AS libraryfine

OPEN "LIBRARY.DAT" FOR RANDOM AS #1 LEN = LEN(library)


DO UNTIL choice = 3
        CLS
        PRINT "School Library Fine Database"
        PRINT
        PRINT "1. Enter new fines."
        PRINT "2. Display student fines."
        PRINT "3. Finished "
        PRINT

        INPUT "Enter choice (1-3)", choice

SELECT CASE choice
        CASE 1
        CLS
        INPUT "Enter Student Record Number: ", library.recnum
        INPUT "Enter Student's Name: ", library.person
        INPUT "Enter Book's Title: ", library.title
        INPUT "Enter Type of Book (1 or 2): ", library.book
        INPUT "Enter Days Overdue: ", library.days

        PUT #1, recnum
        CASE 2
        INPUT "Enter student's record number: ", recnum
        GET #1, recnum
        PRINT library.person
        PRINT library.title
        PRINT library.days

IF book = 1 THEN
total = .25 * days
ELSE
total = .4 * days
END IF

PRINT "Name"; TAB(5); "Book Title"; TAB(5); "Book Type"; TAB(5); "Days Late"
PRINT fines.person; fines.title; fines.book; fines.days
PRINT
PRINT "Total Amount due: $"; total
PRINT


        CASE 3
                CLOSE #1
                CLS
                PRINT "Thank you"

END SELECT
LOOP
CLOSE #1







This post has been edited by tootintorrey: 28 Apr, 2008 - 04:24 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 06:19AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month