I'm currently working on this to try an easy program, but I'm having troubles. I'm still relatively new to qbasic, and I was wondering if anyone could help me debug this
DECLARE SUB edit ()
DECLARE SUB delete ()
DECLARE SUB putrecord ()
DECLARE SUB getrecord ()
DECLARE SUB showall ()
DECLARE SUB setscreen ()
COMMON SHARED nmbrrcrds%
COMMON SHARED FLAG
REM **Put or Get Records, invent.cat File**
SCREEN 12
CLS
REM **Define structure of invent.cat file**
TYPE filestructure
item AS STRING * 20
price AS SINGLE
quantity AS SINGLE
END TYPE
REM **Declare a record variable of above type**
DIM invent AS filestructure
REM **Open the file**
OPEN "invent.cat" FOR RANDOM AS #1 LEN = LEN(invent)
REM **Put or Get records, or quit (ESC)**
DO
'find out what to do
CLS : setscreen: LOCATE 24, 7: PRINT "put or get individual records, invent.cat file."
nmbrrcrds% = LOF(1) \ LEN(invent)
LOCATE 25, 7: PRINT "invent.cat has"; nmbrrcrds%; "records"
LOCATE 26, 7: PRINT "(D)elete, (E)dit, (G)et, (P)ut, (S)how all, (ESC)ape";
LOCATE 27, 7: PRINT "Selected command:"
DO
kbd$ = UCASE$(INPUT$(1))
LOOP UNTIL kbd$ = "P" OR kbd$ = "G" OR kbd$ = CHR$(27) OR kbd$ = "S" OR kbd$ = "D" OR kbd$ = "E"
'Perform requested operation, PUT (P) or GET (G) or ESC
SELECT CASE PorGorSorEsc$
CASE CHR$(27)
EXIT DO
CASE "P"
CALL putrecord
CASE "G"
CALL getrecord
CASE "S"
CALL showall
CASE "D"
CALL delete
CASE "E"
CALL edit
END SELECT
LOOP
REM **End of program stuff**
CLOSE #1
LOCATE 28, 35: : PRINT "The invent.cat file is closed"
END
SUB delete
REM **Declare invent as record defined in main program**
DIM invent AS filestructure
'DIM invent2 AS newfile
REM **Assign correct record number and check for errors**
LOCATE 28, 20: INPUT "Record number to delete?"; rcrdnmbr
IF rcrdnmbr < 1 THEN
LOCATE 15, 35: PRINT "Sorry, but you must pick:"
LOCATE 16, 25: PRINT "a record number that is within"
LOCATE 17, 25: PRINT "the range."
LOCATE 18, 25: PRINT "Press a ket to continue", continue$
EXIT SUB
ELSE
rcrdnmbr = rcrnmbr - 1
END IF
REM **Open a temporary file**
OPEN "invent2.tmp" FOR RANDOM AS #2 LEN = LEN(invent2)
REM **PUt record from 1 up to record to delete into temp file 2**
FOR rcrdnmbr = 1 TO rcrdnmbr
GET #1, rcrdnmbr, invent
invent2.item = invent.item
invent2.price = invent.price
invent2.quantity = invent.quantity
PUT #2, rdcrdnmbr, invent2
NEXT rcrdnmbr
REM **End of one**
REM **Put records from from record to delete to eof into temp file 2
IF rcrdnmbr > nmbrrcrds% THEN
LOCATE 15, 35: PRINT "Sorry, but you must pick"
LOCATE 16, 35: PRINT "a record number that's within"
LOCATE 17, 35: PRINT "the range."
LOCATE 18, 35: PRINT "Press a key to continue", continue$
EXIT SUB
ELSE
rdrdnmbr = rcrdnmbr + 1
END IF
FOR rcrdnmbr = rcrdnmbr TO nmbrrcrds%
GET #1, rcrdnmbr, invent
invent2.item = invent.item
invent2.price = invent.price
invent2.quantity = invent.quantity
PUT #2, rcrdnmbr - 1, invent2
NEXT rcrdnmbr
REM **Close off files**
CLOSE
REM **Delete original record**
KILL "invent.cat"
REM **Rename temp files as new file
NAME "invent2.tmp" AS "invent.cat"
LOCATE 18, 35: PRINT "Press a key to continue"
kbd$ = INPUT$(1)
REM **Reopen original file**
OPEN "Invent.cat" FOR RANDOM AS #1 LEN = LEN(invent)
END SUB
SUB edit
'Declare invent as record define in main program
DIM invent AS filestructure
LOCATE 28, 20: INPUT "Record number"; rcrdnmbr
GET #1, rcrdnmbr, invent
REM **Change item name**
LOCATE 12, 20: : PRINT "Change Item Name?"; invent.item
LOCATE 12, 50: : INPUT "(Y)es/(N)o ", answ$
IF UCASE$(answ$) = "Y" THEN
LOCATE 13, 20: LINE INPUT "Name of Item?"; invent.item
REM **Change item price**
LOCATE 14, 20: : PRINT "Change Item Price?"; invent.price
LOCATE 14, 50: : INPUT "(Y)es/(N)o ", answ$
IF UCASE$(answ$) = "Y" THEN
LOCATE 15, 20: LINE INPUT "New Price?"; invent.price
REM **Change item name**
LOCATE 16, 20: : PRINT "Change Item Quantity?"; invent.quantity
LOCATE 16, 50: : INPUT "(Y)es/(N)o ", answ$
IF UCASE$(answ$) = "Y" THEN
LOCATE 17, 20: LINE INPUT "New Quantity?"; invent.quantity
END IF
PUT #1, rcrdnmbr, invent
LOCATE 20, 35: : PRINT "Press a key to continue"
kbd$ = INPUT$(1)
END SUB
SUB getrecord
'Declare Invent as record defined in main program
DIM invent AS filestructure
LOCATE 28, 20: INPUT "record number"; rcrdnmbr
GET #1, rdrdnmbr, invent
LOCATE 12, 20: PRINT "Name of Item"; invent.item
LOCATE 14, 20: PRINT "Price of Item;"; USING "$$###,###,###,###"; invent.price
LOCATE 16, 20: PRINT "Quantity left"; invent.quantity
LOCATE 18.35: PRINT "Press a key to continue"
kbd$ = INPUT$(1)
END SUB
SUB putrecord
'Declare Invent as record defined in main program
DIM invent AS filestructure
LOCATE 28, 20: INPUT "record number"; rcrdnmbr
LOCATE 12, 20: PRINT "Name of Item?"; invent.item
LOCATE 14, 20: PRINT "Price of Item?"; invent.price
LOCATE 16, 20: PRINT "Quantity left"; invent.quantity
PUT #1, rcrdnmbr, invent
LOCATE 18.35: PRINT "Press a key to continue"
kbd$ = INPUT$(1)
END SUB
SUB setscreen
REM **Large screen box**
LINE (35, 10)-(569, 335), 8, BF'gray
LINE (25, 5)-(550, 325), 1, BF'blue
REM **Title box**
LINE (50, 25)-(484, 100), 8, BF'gray
LINE (55, 30)-(480, 90), 11, BF'tope??
LOCATE 4, 25: PRINT " Dustin's Fantaboular:"
LOCATE 4, 20: PRINT "Inventory Control Program"
REM **Stat box**
REM **menu box**
LINE (35, 255)-(560, 465), 8, BF'gray
LINE (25, 350)-(550, 455), 1, BF'blue
END SUB
SUB showall
DIM invent AS filestructure
format1$ = "$$###,###,###"
format2$ = ",#######,"
row = 10
FOR rcrdnmbr = 1 TO nmbrrcrds%
GET #1, rcrdnmbr, invent
LOCATE 9, 15: PRINT "Num#Item Item Price Quantities Remaining"
row = row + 1
LOCATE row, 15: PRINT rcrdnmbr; "."
LOCATE row, 20: PRINT invent.item;
LOCATE row, 28: PRINT USING "$$###,###,###.##"; invent.price
LOCATE row, 43: PRINT USING format2$; invent.quantity
LOCATE 18, 55: PRINT "Press a key": LOCATE 19, 55: PRINT "to continue."
sortec = sortec + 1
IF sortec = 10 THEN
sortec = 1
row = 10
LOCATE 18, 55: PRINT "Press a key": LOCATE 19, 55: INPUT "for more. ", more
REM **Large screen box**
LINE (35, 10)-(550, 335), 8, BF'gray
LINE (25, 5)-(550, 325), 1, BF'tope
REM **Title Box**
LINE (50, 25)-(485, 100), 8, BF'gray
LINE (55, 30)-(480, 90), 11, BF'tope??
LOCATE 4, 25: PRINT "Dustin's Fantaboulus"
LOCATE 5, 20: PRINT "Inventory Control Program"
END IF
NEXT rcrdnmbr
kbd$ = INPUT$(1)
END SUB
Like I said i'm new and i'm not quite sure what I have to change.
DECLARE SUB edit ()
DECLARE SUB delete ()
DECLARE SUB putrecord ()
DECLARE SUB getrecord ()
DECLARE SUB showall ()
DECLARE SUB setscreen ()
COMMON SHARED nmbrrcrds%
COMMON SHARED FLAG
REM **Put or Get Records, invent.cat File**
SCREEN 12
CLS
REM **Define structure of invent.cat file**
TYPE filestructure
item AS STRING * 20
price AS SINGLE
quantity AS SINGLE
END TYPE
REM **Declare a record variable of above type**
DIM invent AS filestructure
REM **Open the file**
OPEN "invent.cat" FOR RANDOM AS #1 LEN = LEN(invent)
REM **Put or Get records, or quit (ESC)**
DO
'find out what to do
CLS : setscreen: LOCATE 24, 7: PRINT "put or get individual records, invent.cat file."
nmbrrcrds% = LOF(1) \ LEN(invent)
LOCATE 25, 7: PRINT "invent.cat has"; nmbrrcrds%; "records"
LOCATE 26, 7: PRINT "(D)elete, (E)dit, (G)et, (P)ut, (S)how all, (ESC)ape";
LOCATE 27, 7: PRINT "Selected command:"
DO
kbd$ = UCASE$(INPUT$(1))
LOOP UNTIL kbd$ = "P" OR kbd$ = "G" OR kbd$ = CHR$(27) OR kbd$ = "S" OR kbd$ = "D" OR kbd$ = "E"
'Perform requested operation, PUT (P) or GET (G) or ESC
SELECT CASE PorGorSorEsc$
CASE CHR$(27)
EXIT DO
CASE "P"
CALL putrecord
CASE "G"
CALL getrecord
CASE "S"
CALL showall
CASE "D"
CALL delete
CASE "E"
CALL edit
END SELECT
LOOP
REM **End of program stuff**
CLOSE #1
LOCATE 28, 35: : PRINT "The invent.cat file is closed"
END
SUB delete
REM **Declare invent as record defined in main program**
DIM invent AS filestructure
'DIM invent2 AS newfile
REM **Assign correct record number and check for errors**
LOCATE 28, 20: INPUT "Record number to delete?"; rcrdnmbr
IF rcrdnmbr < 1 THEN
LOCATE 15, 35: PRINT "Sorry, but you must pick:"
LOCATE 16, 25: PRINT "a record number that is within"
LOCATE 17, 25: PRINT "the range."
LOCATE 18, 25: PRINT "Press a ket to continue", continue$
EXIT SUB
ELSE
rcrdnmbr = rcrnmbr - 1
END IF
REM **Open a temporary file**
OPEN "invent2.tmp" FOR RANDOM AS #2 LEN = LEN(invent2)
REM **PUt record from 1 up to record to delete into temp file 2**
FOR rcrdnmbr = 1 TO rcrdnmbr
GET #1, rcrdnmbr, invent
invent2.item = invent.item
invent2.price = invent.price
invent2.quantity = invent.quantity
PUT #2, rdcrdnmbr, invent2
NEXT rcrdnmbr
REM **End of one**
REM **Put records from from record to delete to eof into temp file 2
IF rcrdnmbr > nmbrrcrds% THEN
LOCATE 15, 35: PRINT "Sorry, but you must pick"
LOCATE 16, 35: PRINT "a record number that's within"
LOCATE 17, 35: PRINT "the range."
LOCATE 18, 35: PRINT "Press a key to continue", continue$
EXIT SUB
ELSE
rdrdnmbr = rcrdnmbr + 1
END IF
FOR rcrdnmbr = rcrdnmbr TO nmbrrcrds%
GET #1, rcrdnmbr, invent
invent2.item = invent.item
invent2.price = invent.price
invent2.quantity = invent.quantity
PUT #2, rcrdnmbr - 1, invent2
NEXT rcrdnmbr
REM **Close off files**
CLOSE
REM **Delete original record**
KILL "invent.cat"
REM **Rename temp files as new file
NAME "invent2.tmp" AS "invent.cat"
LOCATE 18, 35: PRINT "Press a key to continue"
kbd$ = INPUT$(1)
REM **Reopen original file**
OPEN "Invent.cat" FOR RANDOM AS #1 LEN = LEN(invent)
END SUB
SUB edit
'Declare invent as record define in main program
DIM invent AS filestructure
LOCATE 28, 20: INPUT "Record number"; rcrdnmbr
GET #1, rcrdnmbr, invent
REM **Change item name**
LOCATE 12, 20: : PRINT "Change Item Name?"; invent.item
LOCATE 12, 50: : INPUT "(Y)es/(N)o ", answ$
IF UCASE$(answ$) = "Y" THEN
LOCATE 13, 20: LINE INPUT "Name of Item?"; invent.item
REM **Change item price**
LOCATE 14, 20: : PRINT "Change Item Price?"; invent.price
LOCATE 14, 50: : INPUT "(Y)es/(N)o ", answ$
IF UCASE$(answ$) = "Y" THEN
LOCATE 15, 20: LINE INPUT "New Price?"; invent.price
REM **Change item name**
LOCATE 16, 20: : PRINT "Change Item Quantity?"; invent.quantity
LOCATE 16, 50: : INPUT "(Y)es/(N)o ", answ$
IF UCASE$(answ$) = "Y" THEN
LOCATE 17, 20: LINE INPUT "New Quantity?"; invent.quantity
END IF
PUT #1, rcrdnmbr, invent
LOCATE 20, 35: : PRINT "Press a key to continue"
kbd$ = INPUT$(1)
END SUB
SUB getrecord
'Declare Invent as record defined in main program
DIM invent AS filestructure
LOCATE 28, 20: INPUT "record number"; rcrdnmbr
GET #1, rdrdnmbr, invent
LOCATE 12, 20: PRINT "Name of Item"; invent.item
LOCATE 14, 20: PRINT "Price of Item;"; USING "$$###,###,###,###"; invent.price
LOCATE 16, 20: PRINT "Quantity left"; invent.quantity
LOCATE 18.35: PRINT "Press a key to continue"
kbd$ = INPUT$(1)
END SUB
SUB putrecord
'Declare Invent as record defined in main program
DIM invent AS filestructure
LOCATE 28, 20: INPUT "record number"; rcrdnmbr
LOCATE 12, 20: PRINT "Name of Item?"; invent.item
LOCATE 14, 20: PRINT "Price of Item?"; invent.price
LOCATE 16, 20: PRINT "Quantity left"; invent.quantity
PUT #1, rcrdnmbr, invent
LOCATE 18.35: PRINT "Press a key to continue"
kbd$ = INPUT$(1)
END SUB
SUB setscreen
REM **Large screen box**
LINE (35, 10)-(569, 335), 8, BF'gray
LINE (25, 5)-(550, 325), 1, BF'blue
REM **Title box**
LINE (50, 25)-(484, 100), 8, BF'gray
LINE (55, 30)-(480, 90), 11, BF'tope??
LOCATE 4, 25: PRINT " Dustin's Fantaboular:"
LOCATE 4, 20: PRINT "Inventory Control Program"
REM **Stat box**
REM **menu box**
LINE (35, 255)-(560, 465), 8, BF'gray
LINE (25, 350)-(550, 455), 1, BF'blue
END SUB
SUB showall
DIM invent AS filestructure
format1$ = "$$###,###,###"
format2$ = ",#######,"
row = 10
FOR rcrdnmbr = 1 TO nmbrrcrds%
GET #1, rcrdnmbr, invent
LOCATE 9, 15: PRINT "Num#Item Item Price Quantities Remaining"
row = row + 1
LOCATE row, 15: PRINT rcrdnmbr; "."
LOCATE row, 20: PRINT invent.item;
LOCATE row, 28: PRINT USING "$$###,###,###.##"; invent.price
LOCATE row, 43: PRINT USING format2$; invent.quantity
LOCATE 18, 55: PRINT "Press a key": LOCATE 19, 55: PRINT "to continue."
sortec = sortec + 1
IF sortec = 10 THEN
sortec = 1
row = 10
LOCATE 18, 55: PRINT "Press a key": LOCATE 19, 55: INPUT "for more. ", more
REM **Large screen box**
LINE (35, 10)-(550, 335), 8, BF'gray
LINE (25, 5)-(550, 325), 1, BF'tope
REM **Title Box**
LINE (50, 25)-(485, 100), 8, BF'gray
LINE (55, 30)-(480, 90), 11, BF'tope??
LOCATE 4, 25: PRINT "Dustin's Fantaboulus"
LOCATE 5, 20: PRINT "Inventory Control Program"
END IF
NEXT rcrdnmbr
kbd$ = INPUT$(1)
END SUB
Like I said i'm new and i'm not quite sure what I have to change.