Run QBasic Code on Modern Systems: QB64 Post Code or Ask for Help: Post Code Homework Policy
Too much to Fit on the Screenby Jester (no login)
I have an Array; Array(1000)
Each Index is a random number between 1 - 10000
What I want to do is show these numbers on a screen, but not just in a list. So I used to Locate command like so;
FOR Row = 1 TO 22
FOR Column = 1 TO 70 STEP 5
LOCATE row, column
IF i < 999 THEN
i = i + 1
Unfortunately the screen isn't big enough to fit in all the numbers in the Array, and there is a limit to the rows and columns in the screen.
Is there any way for me to fit in all the indexes of the array whilst keeping that tabled look?
WIDTH 80,50by WIDTH statement (no login)
Put this line at the beginning of your program:
If that isn't enough, you'll need to write the data to a file.
PS. If you are using QB64, then you can set WIDTH to higher, custom values like WIDTH 150,80
*In SCREEN 12, you can do WIDTH 80,60 tooby WIDTH statement (no login)
You can use several screens to display your data.by Solitaire (Login Solitaire1)
Use MOD to repeat the screen display and pause before clearing the screen and showing the next screen.
For example, if you need to repeat your data 150 times to fill a screen, use a counter for each data item, and then you can include:
IF count MOD 150 THEN
INPUT "Press Enter to continue...", E$
Or just reinitialize the counter to 0 each time and if the count goes to 150 (or whatever), then pause and clear the screen to repeat with the next group of data.
Re: Too much to Fit on the Screenby Jester (no login)
Sorry, Didn't specify the entire problem well enough.
The program needs to create an array with 1000 indexes and each index needs a random value between 1 to 10000. Then the array needs to be sorted.
I have no problems so far. The problem begins when I have to display the arrays. The program needs to save these numbers as a text file. I just realised that even if I redefined the dimensions of the screen, I still won't be able to fit in all 3000 indexes. Is it possible for the program to just save the array's straight to a text file without printing to screen? Or is it easier to somehow print all 3000 indexes to screen and then saving.
For the person above, Is it possible to save the numbers on the screen, reset the screen and get the new numbers up and repeat that until all the numbers have been printed and saved?
Re: Too much to Fit on the Screenby AlGoreIthm (no login)
You don't need to print anything before you save it.
Printing to the screen and saving to a file are not related in any way.
You can clear a screen by using CLS and you will have a
clean slate to display your next group of numbers.
This means you'll probably have to learn to use the SLEEP command
in between each set of values you'll be printing to the screen.
Re: Too much to Fit on the Screenby Jester (no login)
I don't need to print to the scree, I just need to be able to print to a file but i would like the numbers structured in rows and columns. How can I print straight to a text file and not the screen.
This is my code so far,
btw, any and all help is appreciated. And thanks for such quick responses, you guys are amazing.
The "structure" is established by the program, not the file...by (Login qb432l)
You can write the information to your file in whatever order is appropriate, then when retrieving from the file, you structure the input when printing to the screen -- for example, using LOCATE, or TAB, or whatever method is convenient.
btw -- your link doesn't work, but this information would apply regardless of the content of your program.
to print to a file instead of the screen. For example:
open "file.txt" for output as 1
print #1, "Hello, from a file!"
By the way, you can open your QBASIC program in Notepad, then copy and paste it to the forum. That way, you don't have to post composite screen shots... :-)
RND questionby Fmr (no login)
I know this is a simple command to do but I have not been able to find a tutorial that would lead me to doing this, and my Qbasic knowledge is quite limited.
Basically, I would like to make a command that lists a random combination of animals. It will ask me how many animals I would like to choose from, lets say 3. And from a pre made list, it will print 3 random animals from that list. I know it's a simple process but for the life of me I cannot figure it out. Any help would be greatly appreciated
RND is a function that returns a number from 0.0 to 0.999999999999..., such as 0.6837472.
To use it, you do something like this:
INPUT "How many animals"; nanimals
x = FIX(RND * (nanimals + 1)) + 1
PRINT "Animal"; x; " was chosen at random."
The first line seeds the random number generator, so RND will actually return random values.
The second line naturally gets the number of animals.
The fourth line prints the result.
The third line uses RND to fetch a random number such as 0.6837472 and multiplies it by the number of animals requested, plus 1 because RND will never return 1.0. Supposing nanimals was 3, then it would be 0.6837472*4, which is 2.7349888. That result is used as the argument to the FIX function, which removes the part after the decimal point since you can't have a part of an animal, leaving only 2. Then you add 1, and voilà. You now have animal #3.
Of course, supposing it was 0.2837472*4 for example, it would then be 1.1349888. FIX would remove the part after the decimal point, leaving only 1, and 1 would be added to that result, yielding animal #2 in the end. Remember to use RANDOMIZE TIMER, and RND will work just fine as long as you remember how to use it.
Edit: See the QB64 wiki entry for the RANDOMIZE statement for another example.
rnd is good for when you must make your program roll dice and stuffby Ben (no login)
its for returning unpredictable numbers
Re: RND questionby (Login codeguy)
are ya allowed to pick the same animal more than once? if you are, it's not so bad to code that. if not, then it's a little bit but not much more complicated. ya might take a look at donald knuth's shuffle algo, which slightly modded is a pretty good candidate for this kind of project if an animal can only be chosen once per set of 3 picks.
this one uses a variant of knuth's shuffle to let ya pick 3 animals at random with no repeats in a set of picks, but because of the shuffle algorithm used alters the original list order. depending on the circumstances, this might or might not be alright. please check to make sure.
numanimals = 7
Numanimalstochoose = 3
REDIM anim$(numanimals - 1)
FOR n = 0 TO numanimals - 1
IF Numanimalstochoose > numanimals THEN
Numanimalstochoose = numanimals
FOR x = 0 TO Numanimalstochoose - 1
randomanimal = x + INT(RND * (numanimals - x))
SELECT CASE randomanimal
SWAP anim$(x), anim$(randomanimal)
LOOP UNTIL INKEY$ > ""
Printing via a usb portby (no login)
some (many) years ago I wrote a QB (4.0) program which prinhts out via LPT1 and I wish to up date it to print on modern printers via a USP port. Can I do this with the latest version of QB. if so how do I get the latest version how much?$ and what Basic command would I use? are my 4.0 manuals (by microsoft any use or can I get new ones/updates
go to the forum and find the download section.
LPRINT is a recent addition to QB64 that does work on newer systems. QBasic has not been updated in years, it is abandoned. Still we could use slave printers on USB ports with QB.
SHELL "cmd /c START /min Notepad /p mydoc.txt"
please write a program for an enrolement into a baptima classby (no login)
a simple program for an enrolment into a baptismal class
Sure - Anything else??by AlGoreIthm (no login)
*He said "baptima", a "batima" is a high colonic courtesy of the caped crusader.by (Login qb432l)
Someone posted a solution to the LESS THAN display problemby Solitaire (Login Solitaire1)
on this forum some time ago, but I can't find it now. Please post it again. It should also be placed in the FAQ or Tips subforum for future reference.
Here Tisby (Login MarineDon)
The greater than and less than symbols are:
(I am placing spaces between the characters, otherwise
the > < symbols themselves will appear)
Greater than: > is & g t ;
Less than: < is & l t ;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You can also use ASCII characters (0-255)
converted to HTML:
ASCII 060 Is: & # 0 0 6 0 ; < LESS-THAN SIGN
ASCII 062 Is: & # x 0 0 3 e; > GREATER-THAN SIGN
Here is a link to converting ASCII to HTML:
For best viewing use your text editor, like NOTEPAD,
to view the page.
Regards, Don Smith
Thank you, Don.by Solitaire (Login Solitaire1)
But it's very flaky and I had to try several times before it would display correctly. It looks like the "Enable formatted text" needs to be checked.
The Greater Than symbol displays without a problem, but Less Than needs a lot of tweaking.
The formatted text option allows one to post plain ol' HTML. However, being reasonably security-conscious and sane, a filter for specific HTML tags was created. This, however, is rather buggy by design. I wish they'd fix it!
On the other hand, you might get away with using <pre>[your code here]</pre>, though the font will appear to be rather large, not to mention the spacing between lines will be exorbitant! However, it has the bonus of keeping the leading spaces in your program. For example:
Edit: By the way, if you use < and > do beware that they'll be converted to their proper forms (< and > respectively), and they won't get converted back if you go back and edit your post or preview your post and choose "Edit" from the preview screen!
Whyby (Login MarineDon)
I do not like N54's at all. Why cannot we here
at the forum use something like <code> </code>
to place our code. If we are unhappy with N54,
then why not use another web hosting company?
I have read many gripes about N54, but when
are we going to do something about it?
Yeah, I think I remember that they are inexpensive
and that is the primary consideration for using
Oh well, one of these days, it'll get better,
bye the bye.
Regards friends, Don Smith
I just had to close an error box to post this message!
It keeps asking me if I want to DEBUG the forum!!!!!!!!
Those (_0_) have continued to make this place WORSE! They DON'T KNOW what they are doing. They are just barely hanging on at this point.
And DON'T BOTHER asking them for help, most of the "helpers" are JERKS!
- Pete edited in ASCII graphics in place of word/words we don't want used around here.
Hi Artelius, I've just released QB64 V0.927 for Linux with your _SNDRAW commands!by Galleon (no login)
I tested them in Linux and as you said, it worked like a charm. The latest version of QB64 has a few nice touches such as proper OS-linked copy/paste support. Try an unmanaged runtime error and a message should appear in a box. Any feedback welcome.
Has anyone done this yet?by Zack (no login)
Hi, I was gonna make a program that finds the amount of time beteen to moments. Like you would say 1 month and it will take current DATE$ and TIME$ and save it to a file. Now it will save the amount of time you inputted. Then when you run the program at a later date, it will open the file of when you started it and the file of how long the timer was for and get the current DAtE$ and TIME$ and see how much time is left.
I was just wondering if anyone has already done this or something like this. Because it seems like it would be a lot of code because the time you entered plus the current time might move on to the next month or year which would be confusing. Anyway, before i jump into this, if someone has already accomplished this, could they please post the code or give me some tips?
Thanks in advance!
Time intervalby Solitaire (Login Solitaire1)
I wrote this program several years ago. It doesn't save anything to a file, but has the user press Enter to start and again to stop. It will then display the interval in hours, minutes, and seconds.
DECLARE SUB clocktime ()
PRINT "Display time interval based on system timer."
PRINT "Press Enter to begin timing. Wait for a period of time. "
PRINT "Enter again to stop timing and display how much time has passed."
PRINT : INPUT "Press Enter to begin: ", B$
PRINT : PRINT "Timer is now: "; TIMER;
begin = INT(TIMER + .5)
PRINT " ="; begin; " rounded to nearest second."
PRINT : INPUT "Wait and then press Enter when ready to stop: ", S$
PRINT : PRINT "Timer is now: "; TIMER;
finish = INT(TIMER + .5)
IF begin > finish THEN 'if begin before midnight & finish after
finish = finish + 86400 'total number of seconds in 24 hours
PRINT " ="; finish; " rounded to nearest second."
interval = INT((finish - begin) + .5)
sec = finish - begin
min = 0
IF sec >= 60 THEN
min = min + 1
sec = sec - 60
LOOP UNTIL sec
hour = 0
IF min >= 60 THEN
hour = hour + 1
min = min - 60
LOOP UNTIL min
PRINT : PRINT "Interval was"; interval; "seconds."
PRINT "The time passed was"; hour; "hours,"; min; "minutes, and"; sec; "seconds."
mytime$ = TIME$
hr$ = LEFT$(mytime$, 2)
hour = VAL(hr$)
IF hour = 0 THEN hour = 12 'midnight
IF hour < = 12 THEN
mer$ = "AM"
hour = hour - 12
mer$ = "PM"
hr$ = STR$(hour)
minsec$ = RIGHT$(mytime$, 6)
clock$ = hr$ + minsec$ + " " + mer$
PRINT "Clock time is: "; clock$
Help neededby (no login)
I want a program using loop statements which can find out maximum, minimum and the average of 5 given no.s... Please help me!
We won't do homework FOR YOU!
One possible approach:by Solitaire (Login Solitaire1)
The following algorithm assumes the user will be inputting the numbers. If you have a prepared list of numbers, you need a different approach.
1. Set the minimum to the highest possible number and the maximum to the lowest.
2. Start a FOR loop to repeat 5 times.
3. Get the number.
4. Use two IF blocks to compare the number to the minimum and maximum and reassign those values as needed.
5. Total all the numbers entered.
6. After the loop ends, divide the total by 5 to get the average.
Note: No one here will write the code for you. You must make an effort to write the program yourself and post the code you have so far. Then ask for help with the specific part of the program that's giving you trouble.
This is not my homework...by HC (no login)
My friend gave me a challenge to do this... I tried it but I got a very long code which could find only the max of it... I thought that I could get some help here... I will post the code after some time...
andby HC (no login)
Which statement should I use to find max and min? I am not too good with QBASIC... I am now learning loops... Here's the code->
INPUT "ENTER NO.S" ; A, B, C, D, E
IF A>B THEN GOTO 10 ELSE
10 IF A>C THEN GOTO 30 ELSE
20 IF A>D THEN GOTO 30 ELSE
30 IF A>E THEN PRINT A; "IS GREATEST" ELSE
100 IF B>C THEN GOTO 110 ELSE
110 IF B>D THEN GOTO 120 ELSE
120 IF B>E THEN PRINT B; "IS GREATEST" ELSE
200 IF C>A THEN GOTO 210 ELSE
210 IF C>B THEN GOTO 220 ELSE
220 IF C>D THEN GOTO 230 ELSE
230 IF C>E THEN PRINT C; "IS GREATEST"
300 .............................................................................AND SO ON!!!
What ugly code!by Solitaire (Login Solitaire1)
Forgive me for being blunt, but all those GOTOs are enough to make me puke. I just don't have the stomach for it.
Please get rid of those GOTOs and learn to use a proper loop. I won't even look at that code until you clean it up.
Here is an example of a FOR-NEXT loop to get you started. This will get the average of 5 numbers the user enters, but it doesn't get the maximum or minimum values. I'll let you try to figure that out for yourself. There are several ways of doing it. Give it a try and post your code WITHOUT ANY GOTOS!!!
FOR x = 1 to 5
INPUT "Enter a number: ", snum$
num = VAL(snum$)
total = total + num
average = total / 5
INPUT "How many numbers do you want to average"; nm$
n = VAL(nm$)
FOR x = 1 to n
INPUT "Enter a number: ", snum$
num = VAL(snum$)
IF num > highest THEN highest = num 'highest = 0 when first used in program
total = total + num
average = total / n
PRINT average, highest
wellby HC (no login)
dude... i get the average thing... but max and min is puzzling me...
AND ALSOby hc (no login)
i m a beginner in QBASIC... not a pro
...by HC (no login)
I know I am troubling you all... and I am sorry for that... how to get the minimum??? I get what clippy said... but how to find min??? :(
You need to get a base value for max and min.by Solitaire (Login Solitaire1)
The following program has all the requirements. I used hi and lo instead of max and min. It uses the first number that is input for the base value, and compares hi and lo against that value in all the subsequent repeats. This will work with any number, even a negative one. Clippy's version only works with a max of 0 as the base value, and doesn't get a value for the minimum. That's because the user's smallest number can be more or less than 0. By comparing all input numbers to the first one, you have a legitimate starting value.
Alternatively, you can get a "primed" value before starting the loop by getting the user input of the first number, and then looping from 2 to 5. But then you need to assign that number to hi, lo, and tot before starting the loop. This version is shorter.
You don't need to restrict the program to 5 repeats. You can get the user's input for the number of repeats and use that variable after the TO in the FOR-NEXT loop. (That was how Clippy did it.)
Note I started out by declaring the variables by type.
DIM snum AS STRING, avg AS DOUBLE
DIM num AS INTEGER, hi AS INTEGER, lo AS INTEGER, tot AS INTEGER
FOR x = 1 TO 5
INPUT "Enter a number: ", snum$
num = VAL(snum$)
IF x = 1 THEN
hi = num
lo = num
tot = tot + num
IF num > hi THEN hi = num
IF num < lo THEN lo = num
avg = tot / 5
PRINT "The average is "; avg
PRINT "The minimum is "; lo
PRINT "The maximum is "; hi
whoaby HC (no login)
I could never do that! You and Clippy are champs! I know I am troublesome... but what does the DIM do?
Thanks... cuz I know you can answer it... ;D
Variables must be defined by type in most languages.by Solitaire (Login Solitaire1)
The DIM stands for "Dimension" meaning size. It reserves a certain number of bytes in memory depending on the type of data. For example, the INTEGER type uses 2 bytes; LONG and SINGLE use 4 bytes; and DOUBLE uses 8 bytes of memory. Number types use stack memory but STRING uses heap memory, consuming 1 byte for each character plus overhead.
QBasic allows variables to be used without declaring them first by type. Instead of using DIM, it is also possible to add a type suffix to a variable name. For example, INTEGER variables may end with %, SINGLE ends with !, LONG ends with &, and DOUBLE ends with #. Numbers are given type SINGLE (4 bytes) by default, unless you declare them otherwise or use the suffix. But STRING variables require the $ suffix unless you declare them with DIM. You may continue using the suffix after a variable name whether or not you DIM it first, but the suffix may not be used with the DIM statement itself.
Other languages (expecially C and C++) require type declaration before the variables can be assigned, so it's a good idea to get used to using it if you are serious about continuing with the study of programming.
Thanks!by HC (no login)
Okay... I understood :)
Thanks to both of you and clippy
And I am STILL being asked to fix some pages when I post!
Who do they have "fixing" the place now? A MONKEY?
a little help with a few problems?by Zack (no login)
I have a few problems that I need help with.
1) Is there a way to DRAW using SCREEN 0?
2) How do you clear the previously pressed keys? I am using _KEYHIT to navigate through my program now, but some things need an INPUT, unless there is a way to get it to recognize when your press 11 or 34 or whatever. Anyway, if to get to the INPUT you have to go through 4 menus. You press 1, 5, 2, 1 for the different menus to navigate there and then it asks you to INPUT. Once you get there, there is already "1521" on the INPUT is there a way to clear this data before it asks for your INPUT?
Thanks for any help!
>1) Is there a way to DRAW using SCREEN 0?
I don't think so.
2) How do you clear the previously pressed keys?
I don't use QB64, but in qbasic:
do while len(inkey$): loop
would do it.
This _KEYHIT of which you speak: does it not remove the keystrokes from the buffer as it reads them? If not, why don't you use a function that does?
DO: K$ = INKEY$
x = _KEYHIT
LOOP UNTIL x = 27
INPUT "Enter:", nam$
Re: Is there a way to draw using SCREEN 0...by (Login qb432l)
The only way to "draw" in SCREEN 0 is to use ASCII characters. In QBasic there is an extended character set which includes line and texture characters. Some amazing things have been done with these, but they're really just meant for drawing boxes and other simple shapes.
If you're interested, open QBasic Help (not available in QB64), click Contents, and then select ASCII Character Codes. Press Page Down for the extended set.
If you don't have QBasic, copy and run this code in QB64:
FOR n = 176 TO 223
PRINT n; CHR$(n),
Thanks so much, but one more thingby Zack (no login)
Thank you so much! Thanks for the idea of using INKEY$ along with _KEYHIT, it works really well. Also, I played around with it and made the things i wanted to DRAW out of those characters.
But one thing I forgot to ask before, that I probably should have learned a long time ago: How do you make a integer variable long? Like if i want it to display a number larger than 1 billion, it writes it in scientific notation. How can I make it so it displays the entire number?
Thanks for your continued help
Declare your variable as a LONG instead of INTEGERby Solitaire (Login Solitaire1)
Instead of: DIM myintvariable AS INTEGER
Do this: DIM mylngvariable AS LONG
If you use a suffix instead of a type declaration, use an ampersand & instead of a percent % symbol.
Also try _UNSIGNED INTEGER64 to get up to 18,446,744,073,709,551,615
Re: Thanks so much, but one more thing :Pby Zack (no login)
I ended up using the & type declaration because I had no need for the variable to be that large, but I know now how to if the need ever arises.
Also, I keep forgetting what I wanted to ask you guys. I had a list of things I needed help with, but then when I go to actually ask, I always forget. Anyway, I remembered the two things I was forgetting.
1) How do you double the size of an image using _PUT.
2) Also, is there a way to convert a string into an integer variable? I am trying to make a little alarm thing where you can set in how long you want it to go off. Then it writes a file for the current time and date. Then I want to add the time that they want to elapse before it rings to the original time and date, but I cant seem to figure out how to convert it. If there is an easier way to do what I am trying to do please tell me.
Thanks so much
Use VAL() to convert a string to a number.by Solitaire (Login Solitaire1)
The VAL() function will convert a numeric string into a number. It will ignore any spaces and stop at the first non-numeric character. If the string is non-numeric, VAL will return 0. For example:
DIM snum AS STRING, mynum AS DOUBLE
INPUT "Enter a number: ", snum$
mynum = VAL(snum$)
If the user enters: 1234qwst
VAL will return 1234
If the user enters: qrst1234
VAL will return 0.
The VAL function returns a type DOUBLE number, so it will work with decimal points. Of course, it will convert a string into a whole number, if the input does not include a fraction. If you require an integer and the input includes a dot followed by more digits, then you need to add more code. You could use the CINT() function to convert a fractional number into an integer.
Re: How do you double the size of an image using _PUT...by (Login qb432l)
Assuming you're referring to QB64's command, _PUTIMAGE, here's the link to the Wiki:
If you're referring to QBasic's PUT statement, there is no way to do it using the statement itself, you would have to physically enlarge the image and then GET it in it's enlarged form. I doubt however, that you're referring to QBasic.
I'm not really familiar with _PUTIMAGE, but I know that the second set of x/y coordinates (following _PUTIMAGE) can be used to resize the image.
Like this...by Galleon (no login)
f$ = "s2_poster_1.jpg"
i = _LOADIMAGE(f$, 32)
IF i = -1 THEN PRINT "You don't have the file '" + f$ + "'": END
i2 = _NEWIMAGE(_WIDTH(i) * 2, _HEIGHT(i) * 2, 32)
_PUTIMAGE , i, i2
SCREEN i2 'display it (optional)
Thanls guysby Zack (no login)
Thank you for pointing out the VAL() command to me, it is just what i needed.
And yes, I meant _PUTIMAGE sorry about that. But I couldn't get the way it does it in the example to work, but the way Galleon says worked fine.
Parallel port issuesby nmcmill (Login ratwouldbeking)
I am a researcher who uses QBasic essentially as an end user, with simple programming for various archaic pieces of hardware (Skinnerian operant chambers, if anyone's interested). I'm having some problems getting some equipment to respond to QBasic commands over the parallel port (Windows 98).
Our department wiring expert has put together a circuit board for an operant box that features two lights (soldered to independent pins, 8 and 9), an infrared beam (input pin 10), and a pump for delivering sucrose (output pin 2). The parallel port is connected to LPT1 (confirmed to be at hex 0378). To test, I use the following brief code, but the box is completely nonresponsive (the lights remain on and the hopper remains active).
> OUT $H378, 0
This remains the case if I use other numbers than zero, all the bits apparently remain high.
Anyone here have any idea what glaring stupidity I have committed in my coding assumptions, or must this be an issue with the hardware? Thanks for any pointers!
All pins will be high when first read so set to zero. Pins 8 and 9 are the highest bits of the port value sent. So you need values of 128 for 9 and 64 for 8. Use the ground pins to complete the circuits.
Don't load the port down! It is only 5 volts with low current capabilities. Use optoisolators and a separate(isolated) power supply to drive other devices!
QBasic under XP - screen colors corrupted.by (no login)
Suddenly, the QBasic edit and output screen colors have become corrupted when running QBasic under XP in a window and from a shortcut. (Same applies to the associated EDIT.COM.) Strangely, colors are OK when switched to full screen or if running from the command prompt.
Magenta, white and bright green all print as black. This makes the window unuseable. help would be much appreciated.
Try this video fix for XP only:
Also you may want to copy Autoexec.NT from the C:\WINDOWS\REPAIR folder to the C:\WINDOWS\SYSTEM32 folder. Sometimes that file is corrupted and Qbasic will not run at all.
Try using QB64 to compile your Qbasic programs.
QBasic screen colorsby (Login slowneutron)
Have found how to correct the problem - posted under QB Tricks & Techniques: "Proceedure for changing QBasic screen colors under Windows XP"
*Yes, I'm upgrading the QB64 website. Refer to my post in the QB64 N54 forum here.by Galleon (no login)
Full screen mode in Windows 7 or Vista...by Solitaire (Login Solitaire1)
The following excerpt appeared in a Windows 7 newsletter. It also describes how to get the command prompt to fill the screen, although it's not a true full screen. The full story is at this link:
The article doesn't explain how to install the device drivers or where to get them from. (Who needs Aero anyway!?!) Maybe someone here can find out.
In Windows 7 or Windows Vista, if you try to maximize the command prompt window, it will expand only to cover around half the screen. You will not be even able to drag and increase its size!
In Windows XP, after you open a command prompt, you could run the cmd in full-screen mode by clicking Alt+Enter, but if you try this in Windows Vista and later, you will get the following message: This system does not support fullscreen mode.
This happens because in Windows 7 and Windows Vista, the device drivers do not support running all of the DOS video modes. The device drivers are based on the Windows Display Driver Model (WDDM).
You may be able to work around this problem by installing the Microsoft Windows XP version of the video drivers for your video adapter. But by doing this, while you may be able to to run full screen DOS programs, you may lose the ability to run Aero!
*Thanks, Solitaire -- although I'm getting used to losing the old stuff, bit by bit.by (Login qb432l)
Qbasic full screen mode in Windows 7by (no login)
Thank you so much.
Anyway to time things in sub 1 second intervals?by (no login)
I searched but couldn't find anything definitive.
Are whole seconds the smallest time increment TIMER and TIME$ can be directly used for? Or is there some other command, or some variation of those commands that will return fractions of seconds as counted on the system clock?
I'm making a program to calibrate a pendulum clock, but it takes a while for the pendulum to drift off by more than a whole second. If there was a way to get tenths, hundredths, or milliseconds from the system clock, it would make for easier programming.
I can always try measuring loop cycles and get a rough approximation of fractions of a second, but easier is better, if it exists :) .
What does TIMER actually return?by Loudhvx (no login)
Sorry, I'm not on a work computer, so I couldn't try it, but also couldn't find documentation on what TIMER actually returns. I find that some say it's the number of seconds since midnight, but I guess I assumed it was whole (integer) seconds.
Based on some tutorials, I gather it is in some other format which includes decimal fractions of a second. Is that correct? If so, then I guess that's all I need. I think I can work with 1/18ths of a second.
At midnight TIMER goes to 0 to restart the second count. So a loop "could" keep looping forever if the delay value added makes the final TIMER value greater than 86399.
Delay .5 'calls SUB for 1/2 second
SUB Delay (Dlay!)
start = TIMER
DO WHILE start + Dlay! >= TIMER
IF start > TIMER THEN start = start - 86400
*Thanks. It's a short-run program, but will keep in mind.by Loudhvx (no login)
MAYBE ...by OPRESION (no login)
*Resolved. Can use TIMER. Thanks!by Loudhvx (no login)
You're right about TIMER. Number of seconds since last midnight. Accurate to approximately 1/18.2 of a second.
If you want more accurate timing you can read the PIT counter that gets updated about a million times a second, but this is tricky. I can dig up some details if you want.
There is also the screen refresh interval which is usually 60Hz. I don't think this method is going to suit your application.
QB64 allows more precise timing with _TIMER and other things. I would suggest you look into this unless you are using DOS.
*Thanks. Found the PIT details on a tutorial.by Lou (no login)
Disk Read/Write Sectors QB7 or QB4.1by Dave (no login)
Hello everyone. I am wondering what commands to use to read and write to a HDD sector really simply. If possible could someone make a function called writesector(address,data) and data=readsector(address). Thanks im also wondering if its possible to be able to directly access the pins of the IDE port but that is optional
MAYBE ...by OPRESION (no login)
I did not find any suitable codeby Dave (no login)
I did not find any suitable code on that website. I tried the boot sector example but it did not work on either qb 4.5 or QBX 7.
see int 0x25 and int 0x26 functions in the above file. You might also look at chapter 10.
I wrote a read disk demo, but it doesn't work in NTVDM. It doesn't seem to work in DOSBox either, at least the version I've got. I took it to my old Win 98se computer, and the only drive it would work on was my USB flash drive.
I wrote the buffer dump portion in a hurry, but it seems to work.
I'll let you figure out how to write a sector. (this is dangerous, of course).
Why do you need raw sector access? I assume you are using DOS or Win 9x instead of NTVDM?
;public domain, feb 2011, michael calkins
int 0x25 ;destroys all except segment registers. SP needs to have 2 added
'public domain, feb 2011, michael calkins
sector AS LONG
numsectors AS INTEGER
bufferoffs AS INTEGER
buffersegm AS INTEGER
drivenum AS INTEGER 'although an integer, only the low byte is used.
er AS INTEGER
errorcode AS INTEGER
DIM readdiskblock AS readdiskblockt
DIM buffer AS STRING * 512
DIM code AS STRING * 72, t AS STRING, i, c, l, a
t = "5589E5608B5E088EDB8B5E068A470AB9FFFFCD25721781C4020089E581C51000"
t = t + "8B5E0631D289570C615DCA040081C4020089E581C510008B5E06BAFFFF89570C"
t = t + "89470E615DCA0400"
FOR i = 0 TO 71
MID$(code, i + 1, 1) = CHR$(VAL("&h" + MID$(t, (i * 2) + 1, 2)))
COLOR 7, 0: CLS
readdiskblock.sector = 0
readdiskblock.numsectors = 1
readdiskblock.drivenum = 2
readdiskblock.buffersegm = VARSEG(buffer)
readdiskblock.bufferoffs = VARPTR(buffer)
DEF SEG = VARSEG(code)
CALL absolute(SEG readdiskblock, VARPTR(code))
IF readdiskblock.er THEN
PRINT "error code: 0x"; HEX$(readdiskblock.errorcode)
WIDTH 80, 50
COLOR 7, 0: CLS : COLOR 3
FOR i = 0 TO 15
LOCATE 1, 6 + (i * 3): PRINT HEX$(i);
LOCATE 1, 65 + i: PRINT HEX$(i);
FOR i = 0 TO 31
t = HEX$(i)
IF LEN(t) < 2 THEN t = "0" + t
PRINT t; "0"
DEF SEG = &HB800
FOR i = 0 TO 511
a = ASC(MID$(buffer, i + 1, 1))
t = HEX$(a)
IF LEN(t) < 2 THEN t = "0" + t
l = i \ 16
c = i MOD 16
LOCATE l + 2, (c * 3) + 5: PRINT t
POKE c * 2 + 128 + (160 * (l + 1)), a
SLEEP: DO UNTIL LEN(INKEY$): LOOP
WIDTH 80, 25: COLOR 7, 0: CLS
Re: read sector demoby Dave (no login)
I am unfortunately wanting to run this software on my Windows XP machine. Thanks for the demo i will try it out now. Is there a way to get it to work through windows XP or is the access prevention levels too high (like with controlling the parallel ports)
First, I don't have much knowledge or experience with parallel ports on any OS, so I'll skip that.
As far as the sector access, I don't think it's a matter of access rights, I think it's a matter of the subsystem not implementing it.
The exact message is:
16 bit MS-DOS Subsystem
Command Prompt - qbasic readdisk
An Application has attempted to directly access the hard disk, which cannot be supported. This may cause the application to function incorrectly. Choose 'Close' to terminate the application.
I know it is possible to do it, because Sysinternals RootkitRevealer does it. (A number of Sysinternals programs install drivers, but from what I am reading elsewhere, I think an application can do it without a special driver.)
Here is a paragraph from Windows Internals, 4th edition, chapter 10, Storage Management. Typing accuracy not guaranteed.
As you saw in Chapter 3, the Windows API is unaware of the Windows object manager namespace. Windows reserves two different namespace subdirectories to use, one of which is the \Global?? (\?? on Windows 2000) subdirectory. (The other is the \BaseNamedObjects subdirectory, which is covered in Chapter 3.) In this subdirectory, Windows makes available device objects that Windows applications interact with-including COM and parallel ports-as well as disks. Because disk objects actually reside in other subdirectories, Windows uses symbolic links to connect names under \Global?? with objects located elsewhere in the namespace. For each physical disk on a system, the I/O manager creates a \Global??\PhysicalDriveX link that points to \Device\HarddiskX\Partition0. (Numbers, starting from 0, replace X.) Windows applications that directly interact with the sectors on a disk open the disk by calling the Windows CreateFile function and specifying the name \\.\PhysicalDriveX (in which X is the disk number) as a parameter. The Windows application layer converts the name to \Global??\PhysicalDriveX before handing the name to the Windows object manager.
Here is the MSDN article for CreateFile function:
A Google search found this: