Announcement

Collapse
No announcement yet.

Letter click

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Letter click

    Hi to all,

    I hoped that it will easy, but...

    My problem is:
    I tried control of run my program by inkey$.
    (By usual manner inside a suitable loop.)

    Example:
    .........
    ..........
    if inkey$="y" then ActionAA
    ..........
    ..........

    I want call ActionAA when "y" will click as a mouse button.
    (y is pressed first and press is released aftewards)
    I want prevent from repeating of ActionAA by holding "y"

    Thanks for yours suggestions
    Lubos

    ------------------
    Lubos
    A view on PowerBASIC
    Lubos
    A view on PowerBASIC

  • #2
    > want prevent from repeating of ActionAA by [WHEN or WHILE?] holding "y"

    Empty the keyboard buffer before restarting loop:
    Code:
    DO
      Z$ = INKEY$
      IF Z$ = "y" THEN
         Call ActionAA
         WHILE LEN(Inkey$):WEND   '<< remove all pending keystrokes
      END IF
    LOOP
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Hi Michael,

      thank you for nearly immideate reply, but it does not work.
      (In fact I tried very similar codes without desiderated results).
      Try substitute ActionAA by simple beep. If you will hold
      "y" for longer time: beep, beep, beep ......

      Lubos

      ------------------
      Lubos
      A view on PowerBASIC
      Lubos
      A view on PowerBASIC

      Comment


      • #4
        If you will hold "y" for longer time: beep, beep, beep ......
        Of course it does. You overflowed the keyboard buffer and the system (not your application) complains.

        All you can do to try to prevent that is periodically empty the KB buffer (whilst doing the "ActionAA").

        Or maybe there's a way to do this with PB/DOS by coding in your own keyboard interrupt handler, but short of that your best bet is probably:
        Code:
        PRINT "Don't hold down the [optional expletive] key, it's not going to go faster anyway!"

        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Here are the mouse functions I use. Be sure to check out the
          "NoButtons" function.
          Code:
          REM ******************
          REM *                *
          REM * Mouse routines *
          REM *                *
          REM ******************
          
          function ResetMouse                             'AX = FFFFh = Installed
          	reg 1,0                                 'AX = 0000h = Not installed
                  call interrupt &h33                     'BX = Number of buttons
                  function = reg(2)                       '
                  end function                            '
                                                          '
          Sub MouseOn                                     '
          	reg 1,1                                 'No output
                  call interrupt &h33                     '
                  end sub                                 '
                                                          '
          Sub MouseOff                                    '
          	reg 1,2                                 'No Output
                  call interrupt &h33                     '
                  end sub                                 '
                                                          '
          Function LeftButton                             '
          	reg 1,3                                 ' Bit 0 = Left Button
                  call interrupt &h33                     ' Bit 1 = Right Button
                  t$ = bin$(reg(2))                       ' Bit 2 = Center Button
                  t$ = bits16$(t$)                        '
                  function = val(mid$(t$,16,1))           ' CX = Mouse Col
                  end function                            ' DX = Mouse row
                                                          '
          Function RightButton                            '
          	reg 1,3                                 '
                  call interrupt &h33                     '
                  t$ = bin$(reg(2))                       '
                  t$ = bits16$(t$)                        '
                  function = val(mid$(t$,15,1))           '
                  end function                            '
                                                          '
          Function CenterButton                           '
          	reg 1,3                                 '
                  call interrupt &h33                     '
                  t$ = bin$(reg(2))                       '
                  t$ = bits16$(t$)                        '
                  function = val(mid$(t$,14,1))           '
                  end function                            '
                                                          '
          Function MouseRow                               '
          	reg 1,3                                 '
                  call interrupt &h33                     '
                  t = reg(4)                              '
                  function = int(t / 8) + 1               '
                  end function                            '
                                                          '
          Function MouseCol                               '
          	reg 1,3                                 '
                  call interrupt &h33                     '
                  t = reg(3)                              '
                  function = int(t / 8) + 1               '
                  end function                            '
                                                          '
          Function NoButtons                              '
                  do until rightbutton = 0 and _          ' 
                            leftbutton = 0                '
                  loop                                    ' 
                  end function                            '
                                                          '
          function bits16$(t$)                            '
          	do until len(t$) = 16                   '
                  t$ = "0" + t$                           '
                  loop                                    '
          	function = t$                           '
                  end function                            '
          ------------------
          There are no atheists in a fox hole or the morning of a math test.
          If my flag offends you, I'll help you pack.

          Comment


          • #6
            Lubos,

            Since DOS days I've used a little function like this one to
            control all input into my programs. There may be more here than
            you need but you'll get the idea. One thing you'll want to do
            before accepting user input on a new field or screen is to call
            INPUT FLUSH to make sure there are no lingering key strokes in
            the buffer. Other than that this one should work well for you.

            Code:
            FUNCTION fGetKey () AS LONG
             
              DIM I AS LOCAL  LONG                                   '
              DIM K AS LOCAL  LONG                                   '
                                                                     '
              K = CVL(WAITKEY$)                                      '
              I = (INSHIFT AND &b011111)                             ' ALT, CTRL & SHIFT
                                                                     '
              IF (I AND  3) THEN BIT SET K, 20                       ' etiher ALT keys
              IF (I AND 12) THEN BIT SET K, 21                       ' either CTRL keys
                                                                     '
              IF (K <  31) OR (K > 255) THEN                         ' if not a letter key
                IF (I AND 16) THEN BIT SET K, 22                     '  set either SHIFT keys
              END IF                                                 '
                                                                     '
              FUNCTION = K                                           '
                                                                     '
            END FUNCTION
            ------------------
            C'ya
            Don
            don at DASoftVSS dot com
            http://www.DASoftVSS.com
            C'ya
            Don

            http://www.ImagesBy.me

            Comment


            • #7
              Hi Don,

              thank you for example of your code. But, I am afraid
              that it is PB/CC code. Anyway, I found something
              on your web pages. It looks usefull. Thank you again.

              Lubos

              ------------------
              Lubos
              A view on PowerBASIC
              Lubos
              A view on PowerBASIC

              Comment

              Working...
              X