home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / AGSPC1B2.ZIP / INPUTLN.PPS < prev    next >
Encoding:
Text File  |  1996-07-29  |  2.0 KB  |  88 lines

  1. ;----------------------------------------------------------------------------
  2. ; Copyright(C) 1996, The AEGiS Corporation
  3. ;----------------------------------------------------------------------------
  4. ;
  5. ; FUNCTION InputLine()
  6. ;
  7. ; Inputs a line at specified coordinates, with optionnal default line and
  8. ; auto upcase
  9. ;
  10. ; value returned: the line entered by the user
  11. ;
  12. ; inputLinecontrol retains a control code uppon keys used to exit :
  13. ;
  14. ;    ENTER = 0
  15. ;    ESC   = 1
  16. ;    UP    = 2
  17. ;    DOWN  = 3
  18. ;
  19. ;----------------------------------------------------------------------------
  20. #lib
  21. Declare Function InputLine(Integer Col, Integer Row, Integer StrLen, String DefaultStr, String CharsAllowed, Boolean ConvertToUpcase) String
  22. Integer InputLineControl
  23.  
  24. ;----------------------------------------------------------------------------
  25. Function InputLine(Integer Col, Integer Row, Integer StrLen, String DefaultStr, String CharsAllowed, Boolean ConvertToUpcase) String
  26.  
  27. Integer il_L
  28. String il_Line
  29. String k
  30.  
  31. InputLineControl = 0
  32. AnsiPos Col, Row
  33.  
  34. Print "@X0B"+DefaultStr
  35. il_L = Len(DefaultStr)
  36. il_Line = DefaultStr
  37.  
  38. While (True) Do
  39.     k = Inkey()
  40.     If (ConvertToUpcase) k = Upper(k)
  41.     Select Case k
  42.     
  43.         Case Chr(27)
  44.             InputLine = il_Line;""
  45.             InputLineControl = 1
  46.             Break
  47.             
  48.         Case "UP"
  49.             InputLine = il_line;""
  50.             InputLineControl = 2
  51.             Break
  52.  
  53.         Case "DOWN"
  54.             InputLine = il_line;""
  55.             InputLineControl = 3
  56.             Break
  57.     
  58.         Case Chr(13)
  59.             InputLineControl = 0
  60.             InputLine = il_Line
  61.             Break
  62.             
  63.         Case Chr(8)
  64.             If (il_Line <> "") Then
  65.                 il_Line = Left(il_Line,len(il_Line)-1)
  66.                 Backup 1
  67.                 Print "@X0F."
  68.                 Backup 1
  69.             Endif
  70.         
  71.         Case Else
  72.             If (Len(il_Line) < StrLen & Len(k) = 1 & Asc(k) > 31) Then
  73.                 If (InStr(CharsAllowed, k)) Then
  74.                     If (Right(Il_Line,1) = " ") k = Upper(K)
  75.                     il_Line = il_Line + k
  76.                     Print "@X0B"+k
  77.                     If (len(il_Line) = StrLen) Then
  78.                         InputLine = il_Line
  79.                         Break
  80.                     Endif
  81.                 Endif
  82.             Endif
  83.     
  84.     End Select
  85. Endwhile
  86.  
  87. EndFunc
  88.