Processing key input on a do loop
#1
I am working on the GUI for my gradebook and I am having a tough time to figure out how to code this though...

First what I am looking at:


[Image: image.png]

I can move around the screen quite easily using this code:

Code: (Select All)
    'Main Gradebook loop
    PAUSE TIME
    DO

        'Inital highlight and execute command loop
        Sel.X = 1: Sel.Y = 1
        LoopX = LongName + 11: LoopY = StartY - 4
        PauseFlag = FALSE
        GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
        PUT (LoopX, LoopY), HL(), PRESET

        'Selection loop
        DO
            LIMIT LIMITRATE

            'Down case
            IF KEYDOWN(20480) OR KEYDOWN(13) THEN
                GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
                PUT (LoopX, LoopY), HL(), PRESET
                IF Sel.Y < CurrentPageCount THEN LoopY = LoopY + FONTHEIGHT + 8: Sel.Y = Sel.Y + 1
                GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
                PUT (LoopX, LoopY), HL(), PRESET
                PauseFlag = TRUE
            END IF

            'Up case
            IF KEYDOWN(18432) THEN
                GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
                PUT (LoopX, LoopY), HL(), PRESET
                IF Sel.Y > 1 THEN LoopY = LoopY - FONTHEIGHT - 8: Sel.Y = Sel.Y - 1
                GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
                PUT (LoopX, LoopY), HL(), PRESET
                PauseFlag = TRUE
            END IF

            'Right case
            IF KEYDOWN(19712) THEN
                GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
                PUT (LoopX, LoopY), HL(), PRESET
                IF Sel.X < GridCount THEN LoopX = LoopX + 50: Sel.X = Sel.X + 1
                GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
                PUT (LoopX, LoopY), HL(), PRESET
                PauseFlag = TRUE
            END IF

            'Left case
            IF KEYDOWN(19200) THEN
                GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
                PUT (LoopX, LoopY), HL(), PRESET
                IF Sel.X > 1 THEN LoopX = LoopX - 50: Sel.X = Sel.X - 1
                GET (LoopX, LoopY)-(LoopX + 48, LoopY + FONTHEIGHT + 7), HL()
                PUT (LoopX, LoopY), HL(), PRESET
                PauseFlag = TRUE
            END IF

            IF PauseFlag THEN PAUSE TIME: PauseFlag = FALSE

            DISPLAY
        LOOP UNTIL KEYDOWN(34304)
        PAUSE TIME
    LOOP UNTIL KEYDOWN(34304) 'F12 key to close the gradebook

You can see I am currently using F12 to exit both loops.

This is what I am trying to do: I want to exit the first loop when any number, period, or any other vaild F## key is pressed. Given an F## key, I can use selectcase to call various subroutines to do the commands, that seems straight forward. The next part I am not sure how to process is if it is a number or a decimal point, I want to capture and print it to screen, similar to an input statement. Any thoughts....

I know the beginning of my first loop will need to be recoded to work properly. I am just realizing as I am chugging along that the input is quickly gonna become a problem I believe.

Quick Edit: What I am trying to avoid is a double enter for input: enter -> input -> enter -> accepted and save. What I am trying to do is vaild input-> enter -> accepted and save.
Reply


Messages In This Thread
Processing key input on a do loop - by NasaCow - 04-20-2023, 11:39 AM



Users browsing this thread: 3 Guest(s)