|  | 
|   | 
 | 
  p.specht
 
   | Jens-Arne Reumschüssel fand dazu eine Lösung, die ohne API-Fummelei auskommt und eine deutliche Beschleunigung sowohl im Interpreter als auch Compiler bringt. Dazu hier mein kleiner Benchmark.
 WindowTitle "Messageabholendes Waitinput beschleunigt:"+\
"     Lösung von Jens-Arne Reumschüssel testen"
CLS:Randomize:font 2
declare n&,tm&,i&,x&,y&,txt$,ungueltig&
 $IFNDEF COMPILER
txt$="INTERPRETER"
n&=2500
 $ELSE
txt$="COMPILER"
n&=4000
 $ENDIF
AppendMenuBar 100," "+txt$+" zählt bis "+str$(n&)+\
".     ESC-Taste soll erkannt werden und zerstört den laufenden Test!"
print "\n OHNE Beschleunigung:",:x&=%pos:y&=%csrlin
waitinput 3:sound 200,20:ungueltig&=0
tm&=&GetTickCount
Whileloop n&:locate 20,20:print &Loop;"     ";
    i&=&Loop
    waitinput 3
    if %Key="27":ungueltig&=1:break:endif
    Endwhile
    tm&=&GetTickCount-tm&
    locate y&,x&
    ifnot ungueltig&: print tm&,"ms"
        else :print "<abgebrochen>":clear ungueltig&
    Endif
    print "\n NUR Fastmode:",:x&=%pos:y&=%csrlin
    waitinput 3:sound 200,20:ungueltig&=0
    tm&=&GetTickCount
    set("Fastmode",1)
    Whileloop n&:locate 20,20:print &Loop;"     ";
        waitinput 3
        if %Key="27":ungueltig&=1:break:endif
        Endwhile
        set("Fastmode",0)
        tm&=&GetTickCount-tm&
        locate y&,x&
        ifnot ungueltig&: print tm&,"ms"
            else :print "<abgebrochen>":clear ungueltig&
        Endif
        print "\n NUR MIT rnd()-Chance:",:x&=%pos:y&=%csrlin
        waitinput 3::sound 200,20:ungueltig&=0
        tm&=&GetTickCount
        Whileloop n&:locate 20,20:print &Loop;"     ";
            if rnd()>0.95
                waitinput 3
                if %Key="27":ungueltig&=1:break:endif
                endif
            Endwhile
            tm&=&GetTickCount-tm&
            locate y&,x&
            ifnot ungueltig&: print tm&,"ms"
                else :print "<abgebrochen>":clear ungueltig&
            Endif
            print "\n LÖSUNG von Jens-Arne R.: Fastmode mit %PeekMessage:",:x&=%pos:y&=%csrlin
            waitinput 3:sound 200,20:ungueltig&=0
            tm&=&GetTickCount
            set("Fastmode",1)
            Whileloop n&:locate 20,20:print &Loop;"     ";
                if %PeekMessage
                    waitinput 3
                    if %Key="27":ungueltig&=1:break:endif
                    Endif
                Endwhile
                set("Fastmode",0)
                tm&=&GetTickCount-tm&
                locate y&,x&
                ifnot ungueltig&: print tm&,"ms"
                    else :print "<abgebrochen>":clear ungueltig&
                Endif
                print "\n OHNE JEDE ABFRAGE:",:x&=%pos:y&=%csrlin
                waitinput 3:sound 200,20:ungueltig&=0
                tm&=&GetTickCount
                Whileloop n&:locate 20,20:print &Loop;"     ";
                Endwhile
                tm&=&GetTickCount-tm&
                locate y&,x&
                ifnot ungueltig&: print tm&,"ms"
                    else :print "<abgebrochen>":clear ungueltig&
                Endif
                hold:
                sound 2000,60
                Waitinput 7000:casenot %wmTimer:goto "hold"
                END
 |  
  | 
|   | 
 | XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...   | 29.05.2021  ▲ |  
  | 
|   | 
 
 
  |