run two loops at once
run two loops at once
(OP)
is there any way you can run two loops at once that are not inside each other??? i want one loop to open a file and print a line and the other loop ti input and save a message.
how do i do that
.... srry im new with some of this stuff..
how do i do that
.... srry im new with some of this stuff..
RE: run two loops at once
Then the first Qbasic program could issue another "SHELL" "START" command. this is fairly straight forward if you are familiar with the Qbasic "SHELL" command & the WINDOWS "START" command. The new WINDOWS can run Max/Min plus a lot of other options.
These two new windows can be independent tasks of the orinination Qbasic program or it can "WAIT" on either window but that would defeat your purpose of doing multi-tasking the set of ".BAT" files.
to get help with the "START" command enter "START /?" on a command line.
Hope this helps.
I teach a lot of programming so I can learn. You can never learn it all.
RE: run two loops at once
RE: run two loops at once
The first SHELL starts a sub shell that executes the directory request command with it's output going to a simple file. The swcond one starts a new window of NOTEPAD editing the created file. The second window can continue to run as an independent window even if the original Qbasic program terminates.
You can start any number of additional windows running independent of each other if desired. You will have to figure out the application needs but this is a simple implementation of what I was talking about.
A SHELL could issue the Windows "START" command.
SHELL "C:\DIR >C:\TEMP\DIR.TXT"
SHELL "NOTEPAD C:\TEMP\DIR.TXT"
I teach a lot of programming so I can learn. You can never learn it all.
RE: run two loops at once
if so just put calls to a print line sub, or a call to an input/save sub
RE: run two loops at once
CODE
CG ReadFile 'This will goto ReadFile but also immediately continue
OPEN "OutFile.dat" for output as #2
do
line input "Enter message to be saved: "; M$
if M$="" then exit do
print #2, m$
loop
close #2
END Me ' This would end only this task
ReadFile:
OPEN "InFile.dat" for input as #1
do
if EOF(1) then exit do
line INPUT #1, l$
print l$
line input "Read another line? "; a$
loop while ucase$(a$)="Y"
close #1
End Me ' This would end only this task
(In my imaginary instruction set, as soon as no tasks are running, the program would END.)
Anyway, you can't do that. Even if you could, it would be very confusing to the user. If the user hits a key, which of the two tasks would receive it?
That said, I would add that you can accomplish stuff like the above in a single task if you write your own replacement for LINE INPUT so that your basic program looks like
CODE
call Task1(""): call Task2("") ' Each will return when it needs a character
do
k$=inkey$
if k$=(some key that means swap tasks) then
if Status=1 then Status=2
elseif k$<>"" then
if Status=1 then call Task1(k$) else call Task2(k$)
endif
loop
That's just the big picture. Lots of details to make it work. So you really need to explain exactly what you want to accomplish and why.
Mac
RE: run two loops at once
Ed Fair
Give the wrong symptoms, get the wrong solutions.
RE: run two loops at once
CODE
call Task1(""): call Task2("") ' Each will return when it needs a character
do
k$=inkey$
if k$=(some key that means swap tasks) then
if Status=1 then Status=2
elseif k$<>"" then
if Status=1 then call Task1(k$) else call Task2(k$)
endif
loop