Qbasicnews.com

Full Version: database record types
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hey, 1st, why do i get an error when i run this? and how can i not use numbers as records but instead names. better yet haw can i save things in catagories and display whole catagories at one time? how would i implement an erasing a frequency tool in there, its a database program to store my millitary HF frequencies.
edit : sorry on the spelling^^ :bounce:

Code:
' DEVELOPED AND CREATED BY HAMFREAK2002

TYPE freq
     fq AS LONG
     nm AS STRING * 60
     dis AS STRING * 80
END TYPE

DIM channel AS freq

mm:

PRINT "1) Add a record"
PRINT "2) View a record"
PRINT "3) Quit"
INPUT "What would you like to do "; mmchc$
         IF mmchc$ = "1" THEN GOTO addrec
         IF mmchc$ = "2" THEN GOTO viewrec
         IF mmchc$ = "3" THEN END
addrec:
OPEN "freqprog,dat" FOR RANDOM AS #1
INPUT "Record"; record
INPUT "Frequencey"; channel.fq
INPUT "Name of station"; channel.nm
INPUT "Other Notes"; channel.dis
PUT 1, record, channel

CLOSE #1
GOTO mm

viewrec:
CLS
INPUT "what record to view"; record
GET 1, record, channel
PRINT " "
PRINT "Record: "; record
PRINT "Frequency: "; channel.fq
PRINT "Name of station: "; channel.nm
PRINT "Notes: "; channel.dis
SLEEP
GOTO mm
hy, if you can help plz do so....
Code:
' DEVELOPED AND CREATED BY HAMFREAK2002

TYPE freq
     fq AS LONG
     nm AS STRING * 60
     dis AS STRING * 80
END TYPE

DIM channel AS freq

mm:

PRINT "1) Add a record"
PRINT "2) View a record"
PRINT "3) Quit"
INPUT "What would you like to do "; mmchc%
         IF mmchc% = 1 THEN GOTO addrec
         IF mmchc% = 2 THEN GOTO viewrec
         IF mmchc% = 3 THEN END
addrec:

OPEN "freqprog,dat" FOR RANDOM AS #1
INPUT "Record"; record
INPUT "Frequencey"; channel.fq
INPUT "Name of station"; channel.nm
INPUT "Other Notes"; channel.dis
PUT #1, record, channel

CLOSE #1
GOTO mm

viewrec:
CLS
INPUT "what record to view"; record
GET 1, record, channel
PRINT " "
PRINT "Record: "; record
PRINT " Frequency: "; channel.fq
PRINT " Name of station: "; channel.nm
PRINT " Notes: "; channel.dis
SLEEP
GOTO mm

I think that should work...

Oz~
thx but how would i use words instead of numbers as "records" and how would i make catagpories and list them. if you know PLZ help im struggling on this one for some reason.
Assume that i% is the number of records...

Code:
' DEVELOPED AND CREATED BY HAMFREAK2002

TYPE freq
     fq AS LONG
     nm AS STRING * 60
     dis AS STRING * 80
END TYPE

DIM channel AS freq
REDIM  RecordStr(1 to 1) AS STRING
REDIM  TempRcrdStr(1 to 1) AS STRING
DIM RecNum AS INTEGER

RecNum = 0

mm:

Record = -1      'This is just to show it hasn't been used yet...

PRINT "1) Add a record"
PRINT "2) View a record"
PRINT "3) Quit"
INPUT "What would you like to do "; mmchc%
         IF mmchc% = 1 THEN GOTO addrec
         IF mmchc% = 2 THEN GOTO viewrec
         IF mmchc% = 3 THEN END
addrec:

'Update the Record Name Array
RecNum = RecNum + 1
GOSUB Update

OPEN "freqprog,dat" FOR RANDOM AS #1
INPUT "Record"; record
INPUT "Record Name"; RecordStr(RecNum)
INPUT "Frequencey"; channel.fq
INPUT "Name of station"; channel.nm
INPUT "Other Notes"; channel.dis
PUT #1, record, channel

CLOSE #1
GOTO mm

viewrec:
CLS

INPUT "Name/Record Number:", request$
IF LEN(request$) > 3 THEN
  FOR i% = LBOUND(RecordStr) TO UBOUND(RecordStr)
    IF LCASE$(RecordStr(i%)) = LCASE$(request$) THEN record = i%
  NEXT i%
ELSE
  record = VAL(request$)
END IF

IF record = -1 THEN
PRINT "Invalid record string or number!"
SLEEP 1
GOTO mm
END IF

GET 1, record, channel
PRINT " "
PRINT "Record: "; record
PRINT " Frequency: "; channel.fq
PRINT " Name of station: "; channel.nm
PRINT " Notes: "; channel.dis
SLEEP
GOTO mm

Update:

'Since REDIMing a cariable resets all values, we have to swap it
'around with a temporary variable


REDIM TempRcrdStr(1 to RecNum)
  FOR i% = 1 TO (RecNum - 1)
    TempRcrdStr(i%) = RecordStr(i%)
  NEXT

REDIM RecordStr(1 to RecNum)
  FOR i% = 1 TO (RecNum - 1)
    RecordStr(i%) = TempRcrdStr(i%)
  NEXT

RETURN

I think that should do it

:bounce:

Oz~
thanks oz, ill put it on disk, runn it over to my laptop and start looking it over the figure out all the tips and tricks Smile
btw, shouldnt
Code:
"freqprog,dat"
be

Code:
"freqprog.dat"

?
ya i figured that out after i posted this trheadm, dummie me took 10 minutes to find an error like that :rotfl: