I am helping someone learn QBASIC -- Used it a long time ago and here is the sample code that I found on the web and made a test program out of it...
CLS
GOSUB BEGIN
GOSUB PROCESS
GOSUB WRAPUP
END
BEGIN:
TYPE people
nm AS STRING * 40 'set the name as a 40-character string
age AS INTEGER 'set the age as an integer
address AS STRING * 60 'set address as a 60-character string
END TYPE
DIM person AS people
OPEN "address.dat" FOR RANDOM AS #1 LEN = LEN(person)
RETURN
PROCESS:
CLS
person.address = ""
INPUT "What record to add"; record
INPUT "Name"; person.nm
INPUT "Age"; person.age
INPUT "Address"; person.address
PUT #1, record, person
RETURN
WRAPUP:
CLOSE #1
LOCATE 16, 10: PRINT "ADDRESS.DAT IS CREATED"
LOCATE 18, 10: PRINT " PROGRAM COMPLETED"
RETURN
The program runs fine and creates tge .DAT file but there is alot of Junk data in it and it is sometimes as big as 300 KB and it is not the same junk everytime.. Looks like I am having some kind of a buffer problem.. Any help is appreciated.. WHY AM I NOT GETTING A TEXT FILE like a CSV file ... I AM CONFUSED... A novice
CLS
GOSUB BEGIN
GOSUB PROCESS
GOSUB WRAPUP
END
BEGIN:
TYPE people
nm AS STRING * 40 'set the name as a 40-character string
age AS INTEGER 'set the age as an integer
address AS STRING * 60 'set address as a 60-character string
END TYPE
DIM person AS people
OPEN "address.dat" FOR RANDOM AS #1 LEN = LEN(person)
RETURN
PROCESS:
CLS
person.address = ""
INPUT "What record to add"; record
INPUT "Name"; person.nm
INPUT "Age"; person.age
INPUT "Address"; person.address
PUT #1, record, person
RETURN
WRAPUP:
CLOSE #1
LOCATE 16, 10: PRINT "ADDRESS.DAT IS CREATED"
LOCATE 18, 10: PRINT " PROGRAM COMPLETED"
RETURN
The program runs fine and creates tge .DAT file but there is alot of Junk data in it and it is sometimes as big as 300 KB and it is not the same junk everytime.. Looks like I am having some kind of a buffer problem.. Any help is appreciated.. WHY AM I NOT GETTING A TEXT FILE like a CSV file ... I AM CONFUSED... A novice