Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screen attribute statement ignored on SUB exit (*solved*)
#1
Bug 
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"
Reply
#2
(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)
Reply
#3
1.14.1-beta8 - the one you made with the INPUT changes to allow the system pip sound.
Reply
#4
I can confirm the same issue exists in the 1.14.1 release version.
Reply
#5
(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-...ta4.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...-beta4.zip
http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz
Reply
#6
Thanks, that certainly fixes the test case above Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)