AllExperts > Experts 
Search      

Qbasic, Quickbasic

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Qbasic, Quickbasic Answers
Question Library

Ask a question about Qbasic, Quickbasic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Alex Barry
Expertise
I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, c/c++, python, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

Experience
Hobby programming since 2000

I no longer belong to any community programming groups, but do have knowledge of *basic dialect and C/C++
 
   

You are here:  Experts > Computing/Technology > Basic > Qbasic, Quickbasic > Sequential file manpulation

Topic: Qbasic, Quickbasic



Expert: Alex Barry
Date: 4/4/2008
Subject: Sequential file manpulation

Question
I want to develope a small module , which can Add , modifiy , find and delete records in a small database.  
<code> <description1>  <description 2>

I want to use  sequential file  manipulation . Please could you help

Answer
Hi, arpit,

I won't write a program for you, but I can give you some snippets of code and some hints on how to proceed.

First, you'll want to use TYPEs (UDTs) to store your data.

it should look something like this:

TYPE DB_Entry
 code  as string * 255
 desc1 as string * 150
 desc2 as string * 150
END TYPE

This will allow you to throw one variable into a file with all the information you need.  To be able to put the information into and out of the file, you'll want to use BINARY files.

DIM size AS INTEGER
DIM file AS INTEGER

size = LEN( DB_Entry )
file = FREEFILE

OPEN "yourdatabase.ext" FOR BINARY AS #file LEN=size

REM - Do your database stuff here...

CLOSE #file

To put data into your file, and to take it out, you'll need to use GET and PUT

DIM entry as DB_Entry

entry.code = "Some sort of code"
entry.desc1 = "First description"
entry.desc2 = "Second description"

PUT #file, , entry

REM - and to retrieve stuff

GET #file, [record%], entry

REM - The record% variable isn't required, but good if you don't want to get the variable in the last place the file pointer was.

That should be all you need to know for this sort of thing.  If you have any specific problems, you can always post again and I'll clearify whatever you don't understand.

Take care,
Alex

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.