Forum
Screen attribute statement ignored on SUB exit (*solved*) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: Screen attribute statement ignored on SUB exit (*solved*) (/showthread.php?tid=1020)



Screen attribute statement ignored on SUB exit (*solved*) - patters - 01-26-2021

If I have multiple attribute changes on a single line, the last one is ignored on exit from a SUB.
Consider this example which exposes the problem:
Code:
SUB screenAttributes
    PAPER 3: INK 7: BRIGHT 1
END SUB

SUB screenAttributes2
    PAPER 4: BRIGHT 1: INK 2
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"

For the first example print, it should be bright but it isn't.
The second example print should have red ink but it doesn't.
I thought I was going mad until I found this.

If I substitute another command in this last statement position of the SUB (like a PRINT for instance) then that works. It's only attribute assignments that seem to fail. Also, if I insert another command before the END SUB, then it all works as expected. e.g. the below code works fine:
Code:
SUB screenAttributes
    PAPER 3: INK 7: BRIGHT 1
    BEEP 0.1,60
END SUB

SUB screenAttributes2
    PAPER 4: BRIGHT 1: INK 2
    BEEP 0.1,60
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"




On further testing, the issue is not related to multiple colon-separated statements on the same line. With the following code the compiler also loses the last statement in each Sub and fails to work as expected:
Code:
SUB screenAttributes
    PAPER 3
    INK 7
    BRIGHT 1
END SUB

SUB screenAttributes2
    PAPER 4
    BRIGHT 1
    INK 2
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"



RE: Screen attribute statement ignored on SUB exit - boriel - 01-26-2021

(01-26-2021, 12:22 PM)patters Wrote: If I have multiple attribute changes on a single line, the last one is ignored on exit from a SUB.
Consider this example which exposes the problem:
Code:
SUB screenAttributes
    PAPER 3: INK 7: BRIGHT 1
END SUB

SUB screenAttributes2
    PAPER 4: BRIGHT 1: INK 2
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"

For the first example print, it should be bright but it isn't.
The second example print should have red ink but it doesn't.
I thought I was going mad until I found this.

If I substitute another command in this last statement position of the SUB (like a PRINT for instance) then that works. It's only attribute assignments that seem to fail. Also, if I insert another command before the END SUB, then it all works as expected. e.g. the below code works fine:
Code:
SUB screenAttributes
    PAPER 3: INK 7: BRIGHT 1
    BEEP 0.1,60
END SUB

SUB screenAttributes2
    PAPER 4: BRIGHT 1: INK 2
    BEEP 0.1,60
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"




On further testing, the issue is not related to multiple colon-separated statements on the same line. With the following code the compiler also loses the last statement in each Sub and fails to work as expected:
Code:
SUB screenAttributes
    PAPER 3
    INK 7
    BRIGHT 1
END SUB

SUB screenAttributes2
    PAPER 4
    BRIGHT 1
    INK 2
END SUB

CLS
screenAttributes()
PRINT AT 0,0;"test"

screenAttributes2()
PRINT AT 2,0;"test2"

What version are you using? (zxbc --version)


RE: Screen attribute statement ignored on SUB exit - patters - 01-26-2021

1.14.1-beta8 - the one you made with the INPUT changes to allow the system pip sound.


RE: Screen attribute statement ignored on SUB exit - patters - 01-27-2021

I can confirm the same issue exists in the 1.14.1 release version.


RE: Screen attribute statement ignored on SUB exit - boriel - 01-27-2021

(01-27-2021, 09:06 AM)patters Wrote: I can confirm the same issue exists in the 1.14.1 release version.

Try this beta, and tell me please:
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta4.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta4.zip
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta4-win32.zip
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta4-linux64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta4-macos.tar.gz


RE: Screen attribute statement ignored on SUB exit - patters - 01-28-2021

Thanks, that certainly fixes the test case above Smile