home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / homonlib.zip / PICKINFO.BAS < prev    next >
BASIC Source File  |  1995-04-13  |  2KB  |  57 lines

  1. DEFINT A-Z
  2.  
  3. DECLARE FUNCTION PickInfo$ (p$, k, e)
  4.  
  5. FUNCTION PickInfo$ (p$, k, e)
  6. '****************************************************************************
  7. 'This function interprets the return string from the PickOne$() and
  8. ' PickSome$() functions.
  9. '
  10. 'The return value from the Pick function is passed as p$.  The integer
  11. ' variables passed as k and e will be assigned the value of the keypress and
  12. ' element number respectively.
  13. '
  14. 'PickInfo$() returns the actual character value of the keypress used to exit
  15. ' the Pick function.
  16. '
  17. 'See the comments within PickOne$() for a more detailed explanation of the
  18. ' Pick functions' return values.
  19. '
  20. 'Examples:     k$ = PickInfo$("", k, e)        -->  k$ = CHR$(27)
  21. '                                                   k  = 27
  22. '              (User pressed ESC)                   e  = 0
  23. '
  24. '              k$ = PickInfo$("*-59 4", k, e)  -->  k$ = CHR$(0)+CHR$(59)
  25. '                                                   k  = -59
  26. '              (User pressed F1 on element 4)       e  = 4
  27. '
  28. '              k$ = PickInfo$("19", k, e)      -->  k$ = CHR$(13)
  29. '                                                   k  = 13
  30. '              (User pressed Enter on element 19)   e  = 19
  31. '
  32. 'Note: This function is a good example of how to get more than one return
  33. ' value from a function.
  34. '
  35. '****************************************************************************
  36.  
  37. IF p$ = "" THEN                         'User pressed ESC
  38.      k = 27
  39.      e = 0
  40. ELSEIF LEFT$(p$, 1) = "*" THEN          'User pressed a hotkey
  41.      s = INSTR(p$, " ")
  42.      k = VAL(MID$(p$, 2, s - 2))
  43.      e = VAL(MID$(p$, s + 1))
  44. ELSE                                    'User pressed Enter
  45.      k = 13
  46.      e = VAL(p$)
  47. END IF
  48.  
  49. IF k > 0 THEN                           'Convert the keypress integer into a
  50.      PickInfo$ = CHR$(k)                'real INKEY$ character value.
  51. ELSE
  52.      PickInfo$ = CHR$(0) + CHR$(-k)
  53. END IF
  54.  
  55. END FUNCTION
  56.  
  57.