Announcement

Collapse
No announcement yet.

Sub not passing value

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

  • Sub not passing value

    I have written a routine to examine the INKEY to catch the
    function keys of F1 thru F12, and if caught, do whatever is
    assigned to that key.

    First time the routine kicks in, it CORRECTLY identifies the
    F key pressed, and passes it back to the line that called it.

    Now the second time the routine kicks in, it correctly
    identifies the F key pressed (I have watched the debugger), but
    as soon as it hits the RETURN statement, all my variables for
    identifying the key pressed get cleared.

    I need for this NOT to clear when returning. Can anyone
    help out please?

    Thank you.

    ------------------


    [This message has been edited by Robert Carneal (edited April 08, 2003).]

  • #2
    You will more than likely need to post some sample code demonstrating the
    problem. If you are using SUB or FUNCTION are you passing the variables
    BYREF or BYVAL? You could also use STATIC variables if you need the SUB
    or FUNCTION to retain the values between calls.


    ------------------
    Scott Slater
    Summit Computer Networks
    www.summitcn.com
    Scott Slater
    Summit Computer Networks, Inc.
    www.summitcn.com

    Comment


    • #3
      <Copy>
      You will more than likely need to post some sample code
      demonstrating the problem.
      <End>

      Scott, I will post the code tomorrow. The program is not on
      this computer. I am using Global variables.

      ------------------

      Comment


      • #4
        Well, I don't have the answer to as why my variables were
        clearing the second time it exits from the sub routine, BUT,
        I have stopped the problem by programming the catch of function
        keys in another way.

        Rather than "catch" the key pressed, I am using the ON KEY
        statement, which so far is doing the job I wrote the
        sub routine for.

        I do have another inquiry as a result of this: According to
        PowerBASIC Help System, the ON KEY Statement traps:
        n = 1..10 traps F1 thru F10
        n = 11..14 traps up, left, right, down arrows
        n = 15..25 traps key defined by the KEY statement
        n = 30..31 traps F11..F12 keys.

        I would like to trap the Home, End, PageUp, & PageDown keys in
        addition to the Function keys. Does anyone have a clean way to
        do this?

        Thank you.

        ------------------

        Comment


        • #5
          I used to use something like this:

          Code:
            WHILE Char$ = ""  
               char$ = INKEY$
               CALL some kind of processor sharing routine
            WEND
            Keynumber% = CVI(char$ + CHR$(0))

          PRINT Keynumber% would give you the number for each.

          ------------------

          Comment


          • #6
            n = 15..25 traps key defined by the KEY statement

            ------------------
            Tom Hanlin
            PowerBASIC Staff

            Comment

            Working...
            X