Scrolling

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
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Scrolling

Post by Sinuvoid »

Ok, when i use the command prompt to print stuff in qbasic, how would i beable to scroll through it? use VIEW? I dunno. I cant even guess on how to put the results in an array :?
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: Scrolling

Post by Mac »

Lee wrote:Ok, when i use the command prompt to print stuff in qbasic, how would i beable to scroll through it? use VIEW? I dunno. I cant even guess on how to put the results in an array :?
I am unable to determine what you want.

Could you please explain further. What is the problem? I'll make a problem up for you and you can see how to explain problems

Mac

---------------------------------------

I am running a program that prompts me for input, which I provide. It then prints some results and then asks the next question. As this process continues, the old printouts scroll off the top of the page. But I want to look at all my output. How can I scroll up and see printouts that have scrolled off the page.

-----------------------------------------
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

Yes! thats my problem...Execpt Im using teh Command prompt command "Find" and then it prints the stuff out like nuts and it goes off the top of the screen :P How do I scroll back up?

EDIT: Can you please help to explain to me what teh formula for the GFX is?
Example:

Code: Select all

SCREEN 13
RESTORE Fire
DIM FireDrawing (0 TO 32) AS INTEGER
FOR PY = 0 TO 5
  FOR PX = 0 TO 5
    READ A
    PSET (PX, PY), A
  NEXT PX
NEXT PY
GET (0,0)-(5,5), FireDrawing
PUT (20, 20), FireDrawing

Fire:
DATA 00,00,04,04,00,00
DATA 00,04,14,14,04,00
DATA 00,04,14,14,04,00
DATA 04,14,14,14,14,04
DATA 04,14,14,14,14,04
DATA 04,14,14,14,14,04
DATA 04,04,04,04,04,04
That from this tutorial http://www.petesqbsite.com/forum/postin ... st&p=15939

EDIT: How do I put variables in teh DRAW command?
User avatar
coma8coma1
Veteran
Posts: 100
Joined: Sat Dec 08, 2007 5:29 pm
Location: Maryland, USA

Post by coma8coma1 »

you mean the DOS command prompt?

isn't there some kind of switch you can add to the end of the command, like "/p" (minus the quotation marks) that makes it spit out the results a page at a time, requiring a keypress to go on?
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

Nope
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Post by Mac »

[quote="Lee"]Im using the Command prompt command "Find" and then it prints the stuff out like nuts and it goes off the top of the screen. How do I scroll back up?

After the FIND command, add "> MyFile.txt"

(If your operating system doesn't work, write your whole FIND command out to a BAT file and shell to it.

Mac

Code: Select all

Stuff$ = (Whatever you are searching for)
File$ = (Wherever you are searching. perhaps *.doc ?)
cmd$ = "FIND /I " + CHR$(34) + Stuff$ + CHR$(34) + " " + File$
PRINT cmd$
OPEN "MyFile.bat" FOR OUTPUT AS #1
PRINT #1, cmd$ + ">MyFile.txt"
CLOSE
SHELL "MyFile.bat"
PRINT "Here is the stuff you can scroll as you please"
OPEN "MyFile.txt" FOR INPUT AS #1
WHILE NOT EOF(1): LINE INPUT #1, l$: PRINT l$: WEND
CLOSE
SYSTEM
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

Can you please explain the code?
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Explain?????????????

Post by Mac »

Lee wrote:Can you please explain the code?
??? What's there to explain ???

I'll do my best:

Stuff$ = (Whatever you are searching for)

You define some variable, I suggested Stuff$ but you could use any name. You put "$" to mean it is a text variable. You set it to whatever you are searching for. You brought up the subject of FIND, not me, so you have to know what the heck you are searching for, right??


File$ = (Wherever you are searching. perhaps *.doc ?)

If you are going to run a FIND command at the DOS prompt, you have to name what to search. You brought up the subject of FIND, not me, so you have to know what file or files you are searching. Don't ask me. Only you know that.

cmd$ = "FIND /I " + CHR$(34) + Stuff$ + CHR$(34) + " " + File$

Here is a variable set to the command you want to run under DOS. Suppose Stuff$="z3" and File$="*.bas", then cmd$ will be
FIND /I "z3" *.bas
which means "search every file in the current directory that ends with ".bas" and print out every occurrences of "z3" or "Z3". (The /I means to ignore case)

PRINT cmd$
Just so we can see what command we are going to do

OPEN "MyFile.bat" FOR OUTPUT AS #1
If you don't know what that command does, then please go away. You need more basics before you can waste our time trying to answer your questions.

PRINT #1, cmd$ + ">MyFile.txt"
This will put the following line in the file your opened, MyFile.bat
(You DO know what a bat-file is, I hope)
FIND /I "z3" *.bas >MyFile.txt
(Assuming the two variable values I made up for you)

CLOSE
(I'll lose my cool and start flaming if you don't know what this does)

SHELL "MyFile.bat"
This will execute the BAT file we just wrote, namely, it will do
FIND /I "z3" *.bas >MyFile.txt
namely it will search for all files in the current directory that end with ".bas" and write any lines that contain "z3" or "Z3" and it will write them into MyFile.txt.
That is the meaning of ">". To DOS, it means to redirect the printout so that rather than going to the screen it goes to a file.

PRINT "Here is the stuff you can scroll as you please"
This is just an instruction I put so that if you run this program, you see what is in file "MyFile.txt".

OPEN "MyFile.txt" FOR INPUT AS #1
WHILE NOT EOF(1): LINE INPUT #1, l$: PRINT l$: WEND
CLOSE
(Don't ask!! If you can't see what this does, you are really wasting my time)

SYSTEM
This terminates your program. Put END there if you want.

Mac
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

Ok, I should have been more specific there :P But the only part of the code I didnt understand was

Code: Select all

 FIND /I "z3" *.bas >MyFile.txt  
With the little greater than sign. But you explained it quiet well :) Thanks Much!

(off topic) How is it possible to put variables in the draw command?
User avatar
Seb McClouth
Veteran
Posts: 342
Joined: Wed Nov 09, 2005 7:47 am
Location: Inside the Matrix...
Contact:

Post by Seb McClouth »

Or use DOSKEY... in the old glorifull days of Dos, we used DOSKEY for that matter. It could bring back up to a certain amount of commands.

Look around for the source... since DOS is now opensource... hehehe
QBinux is a Linux distribution with the aim of integrating the work of the vast community of free software developers at Pete's QBASIC Site in order to create a modern, performant, safe and easy to use system for system administrators and desktop users.
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

WHOA?!?!? :? :!: :!: :idea: :idea: :?: :?:
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Post by Mac »

Seb McClouth wrote:Or use DOSKEY
Ignore that, Lee. DOSKEY is a utility that stores recent commands you made at the DOS prompt so you don't have to type them again, but just use up-arrow to get to old commands, etc.

It has nothing to do with your problem regarding scrolling output.

Mac
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid »

k, thanks :P 'Cause I was like,"WHAT THE HELL?!?"

ok but another question is how do i put variables in the DRAW command?I swear I've tried everything :?
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Post by Mac »

Lee wrote:but another question is how do i put variables in the DRAW command?
I suggest starting a new thread with this question. Title "How to draw using DRAW command"

I presume you couldn't figure out the example in the QBasic HELP section:
SCREEN 1
Triangle$ = "F60 L120 E60"
DRAW "C2 X" + VARPTR$(Triangle$)
DRAW "BD30 P1,2 C3 M-30,-30"

Mac
Post Reply