Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PAUSE not working (*solved*)
#1
Bug 
In my program PAUSE doesn't seem to work. Is that normal? I would find it useful to delay execution a bit while my program prints an error on screen when the result of an INPUT isn't compliant. I can't see any mention of PAUSE in the wiki. I mean I can use a FOR loop to count to 10,000 instead, but I thought the aim of Boriel BASIC is to be a faster superset of Sinclair BASIC so it's surprising this seems to be missing.
Reply
#2
For the time being I have copied a Sub from the Berks Man source code which does the job using the CPU's HALT instruction:
Code:
SUB Wait(w AS uInteger)
    'Pause for w frames
    WHILE w > 0
        w=w-1
        ASM
        HALT
        END ASM
    END WHILE
END SUB
Reply
#3
(12-29-2020, 03:56 AM)patters Wrote: In my program PAUSE doesn't seem to work. Is that normal? I would find it useful to delay execution a bit while my program prints an error on screen when the result of an INPUT isn't compliant. I can't see any mention of PAUSE in the wiki. I mean I can use a FOR loop to count to 10,000 instead, but I thought the aim of Boriel BASIC is to be a faster superset of Sinclair BASIC so it's surprising this seems to be missing.

PAUSE is implemented and it's just a call to the ROM pause (which basically does what your sub does). Are you disabling the interruptions with DI or something?

I've just tested it and it works:
Code:
PAUSE 50
PRINT "HELLO"

Will wait for 50 frames and then print the message. Remember that pause can be cancelled by pressing a key Wink
Reply
#4
No, the only other bit of ASM is some DEFBs to define UDGs. I am using the input.bas library, could that be impacting things?
Reply
#5
That's it!!
Apparently INPUT does something that makes the next PAUSE to be ignored (further PAUSE's will be taking into account).
Thanks for the report. Will investigate this!
Reply
#6
Ok. Seems I got it.
I will fix it in the next release. In the mean time, you can avoid the bug but doing:
Code:
POKE 23611, PEEK 23611 bAND 0xEF
after calling INPUT. It seems bit 5 of FLAGS (23611) must be reset after reading the keyboard.
Reply
#7
Wow, so fast to fix! Smile
I also spotted another issue with Input. If you try to delete a character entered during the INPUT the cursor jumps to the line above (at least in my program which prints the INPUT question on line 22).
Reply
#8
Ok, Let's fix that. Can you post a little example?

In the meantime, if you want to try with a beta with the fix mentioned above, you can download from here:

Windows: http://www.boriel.com/files/zxb/zxbasic-...-win32.zip
Linux: http://www.boriel.com/files/zxb/zxbasic-...x64.tar.gz
Mac OS: http://www.boriel.com/files/zxb/zxbasic-...cos.tar.gz

Source (Python):
http://www.boriel.com/files/zxb/zxbasic-...ta1.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...-beta1.zip
Reply
#9
Sure. During the INPUT prompt, enter a character, then delete it and you'll see the cursor jump up to the line above.
Code:
#include <input.bas>
DIM ans AS Integer
DIM scoreToWin AS uByte

FUNCTION userInputFN(inputXPos AS uByte, prompt AS String, default AS Byte, ansMaxLen AS uByte, ansMinVal AS Byte, ansMaxVal AS Byte) AS Integer
    Prompt:
    PRINT AT 23,inputXPos; prompt; " [";default;"]: ";
    INK 1
    answer$=INPUT(ansMaxLen)
    INK 0
    'String checks
    IF answer$="" THEN
        ans=default
    ELSE
        FOR n=0 TO (LEN answer$)-1
            IF CODE answer$(n)<45 OR CODE answer$(n)>57 THEN
                PRINT AT 23,inputXPos; "Entry error",,
                PAUSE 50
                GO TO Prompt:
            END IF
        NEXT n
        'Checks passed, convert to value
        ans=INT(VAL(answer$))
    END IF
    IF ans<ansMinVal THEN ans=ansMinVal: PRINT AT 23,0; "Constrained to min",: PAUSE 50
    IF ans>ansMaxVal THEN ans=ansMaxVal: PRINT AT 23,0; "Constrained to max",: PAUSE 50
    PRINT AT 23,0;,,
    RETURN ans
END FUNCTION

scoreToWin=5
scoreToWin=userInputFN(0, "Score to win match (1-9)", scoreToWin, 1, 1, 9)
PRINT scoreToWin

I just tried beta 1.14 in Mac OS and it doesn't seem to have fixed the INPUT/PAUSE issue. The code I posted above still isn't PAUSEing properly even when compiled using 1.14.
Reply
#10
Can you try with this version, please?
Tell me if it's fixed:
http://www.boriel.com/files/zxb/zxbasic-...ta2.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...-beta2.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

This one is harder to fix, as it's related to the PRINT + SCROLL management.
Reply
#11
I can confirm that 1.14beta2 build has fixed my specific issue with the delete spoiling the INPUT cursor. However, PAUSE still isn't working. Your reponse wasn't entirely clear - do I need to add that code workaround, or was your intention to fix the compiler so that wouldn't be necessary? Thanks.
Reply
#12
Both errors should have gone.
Please try this new beta3, and tell me:

http://www.boriel.com/files/zxb/zxbasic-...ta3.tar.gz
http://www.boriel.com/files/zxb/zxbasic-...-beta3.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
#13
Yes, that last beta build has fixed both of the issues. Did you see my other new post in this subforum? I'm guessing it's something simple, but it's driving me a bit crazy Smile
Reply
#14
(12-29-2020, 11:52 PM)patters Wrote: Yes, that last beta build has fixed both of the issues. Did you see my other new post in this subforum? I'm guessing it's something simple, but it's driving me a bit crazy Smile

Please check the thread about the TAB bug, because I did a "regression" of this one and it should all be fixed now.
I'm waiting for your confirmation to include the change in the official release. Angel
Reply
#15
Yes I can confirm that 1.14beta6 and beta9 have fixed this issue.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)