Help required, please.....

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
willo
Newbie
Posts: 2
Joined: Tue Oct 05, 2010 10:29 am

Help required, please.....

Post by willo »

Having last attempted basic programming about thirty years ago, I am in need of some assistance with a program I am trying to write.

After user input of a number, I want the program to create a file for it. (Easy, I can do that bit of it!) Then I want successive inputs to be entered into the file but, before doing so, if any data in the file is of less value then I want that data to be deleted. I also want the computer to let me know if any data in the stored file is of the same value as the current input before it is put into the file, and how many times it already exists there.

I'm not sure QB64 is capable of doing this, all I know is the more I try to work it out the more my head hurts!

Any help would be greatly appreciated.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Your best bet is to use arrays to work with the data. Load the file data and make your changes in the array data. When the program is done, use FOR OUTPUT AS #? to clear the file and write all of the data in the array to the file again.

Qbasic is limited in the amount of data it can work with. If you exceed the limits, you could lose everything so have a backup file too!

QB64 allows you to copy an array directly to a BINARY file in one PUT. In fact arrays can hold over 100 thousand values too! Simply PUT #1, , Array(). To restore the array when the program starts, just use one GET #1, , Array() and work from there.

It also allows you to increase the array size if needed by using REDIM _PRESERVE Array(UBOUND(Array) * 3 / 2). Just use the lowest index or another file to hold the array size so that the program knows the size of the array needed before the GET.

QB64 uses Qbasic keywords so it should be able to compile most programs and they can even be run on 64 bit PC's. The link is in my signature.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
willo
Newbie
Posts: 2
Joined: Tue Oct 05, 2010 10:29 am

Post by willo »

Thanks for your good advice, Ted. I think I need to do some more revision on the use of arrays.

Very grateful.

Brian
Anonymous

Post by Anonymous »

what are metacommands? give me some examples.
Is there any feature that'll allow the
program to not to display it's button on taskbar. do you have any?

how to treat depression
Theunis
Coder
Posts: 21
Joined: Sun Oct 17, 2010 5:41 am

Post by Theunis »

1.) Did You try a search for Metacommands.
The following result showed up: Valerie : PostPosted: Fri Aug 26, 2005 8:12 pm : The BC compiler options and metacommands are here:

http://qbcm.hybd.net/issues/1-9/#letters

Unfortunately I cannot publish the two pages of the QB4.5 manual here.

2. Button on task bar: This is a Windows feature. I don't know how to disable it.

3. Please remember we assist with programming problems. Your question is more in line with tutoring. Download Teds program, Check the tutorials on Pete's site etc.
Post Reply