Author Topic: Unexpected behaviour of RUN statement  (Read 4359 times)

0 Members and 1 Guest are viewing this topic.

Offline zaadstra

  • Newbie
  • Posts: 78
    • View Profile
Unexpected behaviour of RUN statement
« on: January 02, 2021, 10:29:27 am »
Hi,

I ran into a strange thing in my program, which after narrowing down to a piece of test code, might be a bug in the RUN statement.

In my program I am using the bottom line (locate 25,1) as status line.  This all works fine, and the printing on that line and elsewhere on screen doesn't cause screen scrolling.  In some part of the program, I can choose to restart and do this with the RUN statement, as this makes sure all files are closed and variables 'forgotten'.

After this re-RUN, the program screen starts scrolling when printing on line 23.  This isn't an issue at first run.

This small piece of code shows the issue.  First time you see a scrolling counter, and the two bottom lines are static as expected.  After re-RUN, line 24 is also used and the screen starts scrolling.  The status line (25) then also scrolls away.

I've been messing with CLS, changing to different SCREEN, making sure last print command isn't at bottom etc.
It looks like a re-RUN isn't a 100% clean restart of the program?
If you enable the GOTO Start line (jumps to line 1) the program doesn't break.  But then all garbage is not cleared ;-)

Any thoughts?


Code: QB64: [Select]
  1. Start:
  2. LOCATE 25, 1
  3. PRINT "Nice status line! @"; TIME$;
  4. LOCATE 1, 1
  5.  
  6. FOR i = 1 TO 400
  7.    PRINT i
  8.    FOR j = 1 TO 2500000: NEXT
  9.  
  10. LOCATE 12, 12
  11. INPUT "Press enter to RUN"; x$
  12.  
  13. 'GOTO Start
  14.  

Offline Mad Axeman

  • Newbie
  • Posts: 74
    • View Profile
    • My web site - Harrythetrout
Re: Unexpected behaviour of RUN statement
« Reply #1 on: January 02, 2021, 12:20:58 pm »
I'm just confused as to why it isn't doing it the first time it's run. There's nothing telling it to stop at line 23 and start scrolling????
Oh look - a sig file :-)

Offline zaadstra

  • Newbie
  • Posts: 78
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #2 on: January 02, 2021, 12:21:50 pm »
After re- (re- re- ...) reading the wiki page for RUN,  I decided to use CLEAR and then jump to a StartOfProgram: label.

I assume that RUN does the same, only it seems to mess up the screen settings.

Offline zaadstra

  • Newbie
  • Posts: 78
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #3 on: January 02, 2021, 12:25:57 pm »
I'm just confused as to why it isn't doing it the first time it's run. There's nothing telling it to stop at line 23 and start scrolling????

I can only guess this is legacy behaviour,  as the ancient QuickBasic versions also had this feature.   I like it a lot, as you can have a scrolling screen together with a static line for status messages, as demonstrated in the code snippet.

You can use VIEW PRINT too to accomplish something like this, but this is far more easy to use.



Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #4 on: January 02, 2021, 12:53:31 pm »
I'm just confused as to why it isn't doing it the first time it's run. There's nothing telling it to stop at line 23 and start scrolling????

+1 I think so too! But why isn't it repeating on re RUN?

I don't how important this is but if you really need to "run" a program fresh, you could call it up under shell.
« Last Edit: January 02, 2021, 12:57:49 pm by bplus »

Offline Mad Axeman

  • Newbie
  • Posts: 74
    • View Profile
    • My web site - Harrythetrout
Re: Unexpected behaviour of RUN statement
« Reply #5 on: January 02, 2021, 01:13:14 pm »
If you 'un rem' (that doesn't look right!) the GOTO Start and run it it'll keep working as on the first run. So what's different about calling 'RUN' from within a programme? Weird!
Oh look - a sig file :-)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #6 on: January 02, 2021, 02:07:47 pm »
Well guess what?!

It runs fine in QB64 stable version 1.3, the RUN gets same results as the first pass.

So this is a difference between QB64 64 bit (Windows 10) stable 1.3 and stable 1.4.

Offline zaadstra

  • Newbie
  • Posts: 78
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #7 on: January 02, 2021, 02:16:54 pm »
If you 'un rem' (that doesn't look right!) the GOTO Start and run it it'll keep working as on the first run. So what's different about calling 'RUN' from within a programme? Weird!

The difference is that RUN also CLEARs all variables etc. and closes files. Then restarts program in memory.

Well guess what?!

It runs fine in QB64 stable version 1.3, the RUN gets same results as the first pass.

So this is a difference between QB64 64 bit (Windows 10) stable 1.3 and stable 1.4.

Now that is an interesting find!  I guess this is food for the QB64 techies now.

Offline Mad Axeman

  • Newbie
  • Posts: 74
    • View Profile
    • My web site - Harrythetrout
Re: Unexpected behaviour of RUN statement
« Reply #8 on: January 02, 2021, 03:18:14 pm »
The difference is that RUN also CLEARs all variables etc. and closes files. Then restarts program in memory.
But when you first RUN the prog there's no variables/open files etc. so shouldn't be any difference.
Oh look - a sig file :-)

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #9 on: January 03, 2021, 07:59:52 pm »
RUN and CLEAR are messed up, period. They do not clear all values as they did in QBasic. If you know what is causing the problem, you need to set the value befor using the RUN statement. As an alternative, you could open another instance of your program with SHELL, and then end the first instance.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Unexpected behaviour of RUN statement
« Reply #10 on: January 03, 2021, 08:44:58 pm »
RUN and CLEAR are messed up, period. They do not clear all values as they did in QBasic. If you know what is causing the problem, you need to set the value befor using the RUN statement. As an alternative, you could open another instance of your program with SHELL, and then end the first instance.

Pete

That would be the way I’d do it.

SHELL _DONTWAIT COMMAND$(0)
SYSTEM
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline zaadstra

  • Newbie
  • Posts: 78
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #11 on: January 04, 2021, 06:00:49 am »
RUN and CLEAR are messed up, period. They do not clear all values as they did in QBasic. If you know what is causing the problem, you need to set the value befor using the RUN statement. As an alternative, you could open another instance of your program with SHELL, and then end the first instance.

Pete
I do not have indications that variables are not cleared. That said, I usually preset most variables at start of program. 
It is only the screen layout that get messed up. 

As Bplus found out, this seems to be a bug introduced between versions 1.3 and 1.4.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #12 on: January 04, 2021, 01:25:20 pm »
It's been around a lot longer than v1.3. It's one of my pet peeves that has never gets fixed, especially the CLEAR statement.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline zaadstra

  • Newbie
  • Posts: 78
    • View Profile
Re: Unexpected behaviour of RUN statement
« Reply #13 on: January 04, 2021, 04:15:18 pm »
Let's hope this can get some attention in the upcoming v1.5?   How hard can it be,  LOL !!!