Qbasicnews.com
December 04, 2020, 05:29:44 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: database record types  (Read 2065 times)
hamfreak2002
Member
*
Posts: 42



« on: June 27, 2004, 06:16:06 PM »

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
Logged

unning a panasonic toughbook, cf-25 Smiley
hamfreak2002
Member
*
Posts: 42



« Reply #1 on: June 28, 2004, 06:42:06 PM »

hy, if you can help plz do so....
Logged

unning a panasonic toughbook, cf-25 Smiley
Oz
I hold this place together
*****
Posts: 923



« Reply #2 on: June 28, 2004, 06:50:25 PM »

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~
Logged
hamfreak2002
Member
*
Posts: 42



« Reply #3 on: June 28, 2004, 07:12:53 PM »

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.
Logged

unning a panasonic toughbook, cf-25 Smiley
Oz
I hold this place together
*****
Posts: 923



« Reply #4 on: June 29, 2004, 08:41:54 AM »

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~
Logged
hamfreak2002
Member
*
Posts: 42



« Reply #5 on: June 29, 2004, 11:40:25 AM »

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 Smiley
Logged

unning a panasonic toughbook, cf-25 Smiley
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #6 on: June 29, 2004, 02:49:39 PM »

btw, shouldnt
Code:
"freqprog,dat"

be

Code:
"freqprog.dat"


?
Logged
hamfreak2002
Member
*
Posts: 42



« Reply #7 on: June 30, 2004, 12:35:32 AM »

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

unning a panasonic toughbook, cf-25 Smiley
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!