Announcement

Collapse
No announcement yet.

Which replaced functions can I needed ?

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

  • Which replaced functions can I needed ?

    Dear Support,

    I must ported pascal source code into PBCC code:

    Code:
    ' repeat
    DO
       'write('Aantal herhalingen: ');
       'readln(tijd);
       LOCAL a AS STRING
       STDOUT "Aantal herhalingen: " : STDIN LINE a : tijd = VAL(a$)
       'repeat
       DO
           CALL sub_routine()
       'until Keypressed;
       LOOP UNTIL INSTAT
       
       LOCAL key AS STRING
       'key := ReadKey;
    'until key = chr(27);
    LOOP UNTIL INKEY$ = CHR$(27)
    1. Which functions can I use from the Pascal functions Keypressed() and ReadKey() replace into PBCC functions and C++ functions?

    2. What is the different en when I use this functions?

    INSTAT(), WAITKEY(), INKEY$(), WAITSTAT()

    With Kind regards
    Stephane

  • #2
    It was inevitable.
    "Not my circus, not my monkeys."

    Comment


    • #3
      Eric

      I read the manual but there is no clearly example when I use this functions.
      I know not all thing in programming !!!

      Stephane

      Comment


      • #4
        You are correct: INKEY$ and/or WAITKEY$ are what you want.

        WAITKEY$ is more efficient.

        There are examples here; use the SEARCH function.

        Welcome back.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Michael

          I try ported into this

          Code:
          'repeat
             DO
                 CALL sub_routine()
             'until Keypressed;
             LOOP UNTIL INSTAT
             
             LOCAL key AS STRING
             'key := ReadKey;
          'until key = chr(27);
          LOOP UNTIL WAITKEY$ = CHR$(27)
          Works my code corrected?
          I think INSTAT is the same of KeyPressed and WAITKEY$ is the same of ReadKey

          Is my solution right?

          With kind regards
          Stephane

          Comment


          • #6
            No. You omitted the first DO.

            Two samples, the first is stripped to just the minimum
            Code:
            #COMPILE EXE
            #DIM ALL
            
            SUB sub_routine()
                PRINT"." $SPC ;
                SLEEP 250
            END SUB
            
            FUNCTION PBMAIN () AS LONG
                DO
                   DO
                       sub_routine
                   LOOP UNTIL INSTAT
                LOOP UNTIL WAITKEY$ = CHR$(27)
            END FUNCTION
            the second to examine other keys that might be pressed as well.
            Code:
            #COMPILE EXE
            #DIM ALL
            
            SUB sub_routine()
                PRINT "." ;
                SLEEP 250
            END SUB
            
            FUNCTION PBMAIN () AS LONG
                LOCAL keystroke AS STRING
                DO
                   DO
                       'sub_routine will be called continually
                       'until a key is pressed and in the key board
                       'buffer
                       sub_routine
                       'the loop continues until a key, any key, is pressed,
                   LOOP UNTIL INSTAT
                   'allow buffered keys to be examined, First In First Out (FIFO)
                   keystroke$ =  INKEY$  'empty the buffer a key at a time,
                   PRINT : PRINT keystroke$  'just printing here for show.
                LOOP UNTIL keystroke$ = CHR$(27)
            END FUNCTION
            Last edited by Richard Angell; 23 Sep 2008, 10:01 AM.
            Rick Angell

            Comment


            • #7
              I start your first example.
              When I pressed to any key it doesn't quit the loop
              Why

              I think that instat doesn't work if I press to any key on my keyboard

              Stephane

              Comment


              • #8
                It does work. It is working code, but only exits when you press 'Esc" key.

                ANSI key value needed?
                Rick Angell

                Comment


                • #9
                  > think that instat doesn't work if I press to any key on my keyboard

                  I think INSTAT does work as advertised, but PB/CC 5 and PB/WIN 9 offer new syntax options for you to use if you'd like to be sure:
                  Code:
                     manual.read
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    It was inevitable.
                    Cicada adhere to a cycle, don't they? Probably the same thing.

                    Comment


                    • #11
                      Stephane Fonteyne and Alan Clarke on the same board.

                      What joy.
                      Dave.

                      You're never too old to learn something stupid.

                      Comment

                      Working...
                      X