Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What's with "RUN" and "CLS"?
#1
Probably two of the simplest instructions,  Run and Cls are confusing the hell out of me!
When I run this code:
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Run
I would expect either the Cls, or the Run, to wipe the screen clean. According to Help, Run clears the current programme (and I assume this means its screen as well) but it doesn't!

So, I added the Cls, expecting that this, at least, would clear the screen, but it only cleans down to the first  _Delay (or Sleep) line. Why does the text after _Delay not get wiped?  Huh
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#2
It *does* wipe the screen clear.   You just so happen to write on it immediately after.  Try this and watch.

Code: (Select All)
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
_Delay 4
Run
Reply
#3
Or, for an added thought exercise, let's take a look at what's going on with the code:

Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Run   <--- at this point, we start over again.  Right?


So isn't our code actually something like:

Code: (Select All)
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
....



Make the issue a little more obvious now?
Reply
#4
(01-09-2023, 04:17 AM)SMcNeill Wrote: Or, for an added thought exercise, let's take a look at what's going on with the code:

Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Run   <--- at this point, we start over again.  Right?


So isn't our code actually something like:

Code: (Select All)
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
Screen 1
Print "ABC"
Print "DEF"
_Delay 1
Print "XXX"
_Delay 1
Cls
....



Make the issue a little more obvious now?
Ahah, gotit! Thanks Steve.

Now I can move on to the *really* tricky ones, like If... Then... Else  Big Grin
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Run a YouTube Video From a QB64 Program? Magdha 4 356 12-13-2025, 02:57 PM
Last Post: Magdha
  Run code without compiler phil 9.0 7 1,316 12-05-2024, 08:52 AM
Last Post: phil 9.0
  [Solved] How come CLS clears more than the _DEST image here? Dav 2 757 10-07-2024, 12:14 AM
Last Post: Dav
  HELP TO RUN QBASIC CODE FROM 90s ! musss1 12 2,794 06-10-2024, 09:19 PM
Last Post: Kernelpanic
  Auto reload program upon RUN Cobalt 2 879 07-06-2023, 11:08 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)