home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Tu-Basic / MC1.INC < prev    next >
Text File  |  1987-04-01  |  5KB  |  188 lines

  1. '┌───────────────────────────────────────────────────────────────────────────┐
  2. '│                               MC.BAS                                   │
  3. '│                             VERSION 1.0                                   │
  4. '│                                                                           │
  5. '│                           MODULE: MC1.INC                                 │
  6. '│                                                                           │
  7. '│                   Turbo Basic                     │
  8. '│        (C) Copyright 1987 by Borland International             │
  9. '│                                                                           │
  10. '│ DESCRIPTION: Miscellaneous commands and utilities (Keyboard,screen,         │
  11. '│              Autocalc)                             │
  12. '│                                                                           │
  13. '└───────────────────────────────────────────────────────────────────────────┘
  14.  
  15.  
  16. SUB ClearStat
  17. ' ClearStat clears the status line at line number @StatusLine%
  18.  
  19.    LOCATE %StatusLine ,1                    ' Go to the status line location
  20.    PRINT LEFT$(SPACE$(%ScreenSize ),79);    ' and write blanks over anything
  21.                            ' there
  22. END SUB
  23.  
  24. SUB Msg( Buffer$ )
  25. ' Msg displays a message on the status line
  26.  
  27.    CALL ClearStat                         ' Clear out anything that is on the
  28.                                           ' status line
  29.    LOCATE %StatusLine ,1                  ' Go there
  30.    Buffers$=LEFT$(Buffer$,%ScreenSize )   ' Make sure the string will fit
  31.    PRINT Buffer$;                         ' print out the message
  32.  
  33. END SUB
  34.  
  35. SUB Flash(X%,Buffer$,Blink%)
  36. ' Display a temporary flashing message to the user.
  37.  
  38.     Buffers$=LEFT$(Buffer$,%ScreenSize ) ' Make sure the string will fit
  39.     LOCATE %FlashLine ,X%
  40.     IF Blink% THEN
  41.       CALL BlinkVideo
  42.       PRINT Buffer$;
  43.       WHILE NOT INSTAT : WEND
  44.     ELSE
  45.       CALL NormVideo
  46.       PRINT Buffer$;
  47.     END IF
  48.  
  49. END SUB
  50.  
  51. DEF FNMASK$(Fw%,Nd%)
  52.     IF Nd%<=-1 THEN
  53.        FNMASK$="."+STRING$(FW%-5,"#")+"^^^^"
  54.     ELSEIF Nd%=0 THEN
  55.        FNMASK$=STRING$(FW%,"#")
  56.     ELSE
  57.        FNmask$=STRING$(FW%-Nd%-1,"#")+"."+STRING$(Nd%,"#")
  58.     END IF
  59. END DEF
  60.  
  61. SUB Auto
  62. ' Toggles AutoCalc on AND off
  63.  
  64.     shared Autocalc%
  65.  
  66.     AutoCalc% = NOT AutoCalc%
  67.     CALL DISPAUTO               ' call the routine that displays AutoCalc
  68.                     ' state
  69. END SUB
  70.  
  71. SUB ReadKBD(RetChar$)
  72. ' This function reads a keystroke from the keyboard and returns 1 OR 2
  73. ' character string.
  74.  
  75.     DO
  76.       RetChar$ = INKEY$          ' get the keyboard input
  77.     LOOP UNTIL RetChar$<>""
  78.  
  79. END SUB
  80.  
  81. SUB IBMCh( Ch$ )
  82. ' IBMCh returns the control character associated with the function keys.
  83. ' (ie. right arrow will be changed TO a ^D.
  84.  
  85.     IF ( asc(Ch$) = 0 ) THEN         ' Check to see if the character is null
  86.       SELECT CASE asc(MID$(Ch$,2,1)) ' If so then a function key was hit and
  87.                                      ' we need to check the scan code
  88.         CASE 72                      ' Up Arrow
  89.           Ch$ = CHR$(5)
  90.         CASE 80                      ' Down Arrow
  91.           Ch$ = CHR$(24)
  92.         CASE 77                      ' Right Arrow
  93.           Ch$ = CHR$(4)
  94.         CASE 75                      ' Left Arrow
  95.           Ch$ = CHR$(19)
  96.         CASE 83                      ' Delete Key
  97.           Ch$ = CHR$(7)
  98.         CASE 82                      ' Insert Key
  99.           Ch$ = CHR$(22)
  100.         CASE 71                      ' Home key
  101.           Ch$ = CHR$(1)
  102.         CASE 79                      ' END key
  103.           Ch$ = CHR$(6)
  104.         CASE 60                      ' F2 key
  105.           Ch$ = CHR$(%EditKey )
  106.         CASE 15                      ' Shift Tab
  107.           Ch$ = CHR$(15)
  108.         CASE ELSE                    ' Everything else
  109.           Ch$ = CHR$(0)
  110.       END SELECT
  111.     END IF
  112. END SUB
  113.  
  114. SUB ClrEol
  115. ' This procedure clears any text from the current cursor position
  116. ' to the end of the line on the screen.
  117.  
  118.     LOCAL OldX%
  119.  
  120.     OldX% = POS
  121.     PRINT SPACE$(80-Oldx%-1);
  122.     LOCATE ,OldX%
  123.  
  124. END SUB
  125.  
  126. DEF FNUnsign&(V&)
  127. ' to prevent negative value
  128.     IF V&<0 THEN FNUnsign&=V&+65536 ELSE FNUnsign&=V&
  129. END DEF
  130.  
  131. SUB LowVideo
  132.    COLOR %LowColor ,0
  133. END SUB
  134.  
  135. SUB NormVideo
  136.    COLOR %NormColor ,0
  137. END SUB
  138.  
  139. SUB BlinkVideo
  140.   COLOR %BlinkColor ,0
  141. END SUB
  142.  
  143. SUB InvVideo
  144.   COLOR 0,7
  145. END SUB
  146.  
  147. DEF FNgetcmd$
  148. 'Get the command line parameter
  149.     STATIC Cmdi%
  150.     LOCAL  Cmdline$,Cmdchar$,Cmdword%
  151.     Cmdline$="" : Cmdword%=0
  152.     IF Cmdi%=0 THEN incr Cmdi%
  153.    DO
  154.       Cmdchar$=MID$(command$,Cmdi%,1)
  155.       IF Cmdchar$<>" " THEN
  156.           Cmdline$=Cmdline$+Cmdchar$ : Cmdword%=1
  157.       END IF
  158.       incr Cmdi%
  159.    LOOP UNTIL Cmdchar$="" OR (Cmdword%=1 AND Cmdchar$=" ")
  160.    FNgetcmd$=Cmdline$
  161. END DEF
  162.  
  163. DEF FNActivityTime$(BeginTimer)
  164.  
  165.   LOCAL t$,t,h
  166.  
  167.   t=INT(TIMER-BeginTimer)
  168.   IF t>0 THEN
  169.     h=INT(t/3600.0)
  170.     IF h>0 THEN
  171.       t$=t$+STR$(h)+" Hour"
  172.       IF h>1 THEN t$=t$+"s"
  173.     END IF
  174.     t=t-h*3600.0
  175.     h=INT(t/60.0)
  176.     IF h>0 THEN
  177.       t$=t$+STR$(h)+" Minute"
  178.       IF h>1 THEN t$=t$+"s"
  179.     END IF
  180.     h=t-h*60.0
  181.     IF h>0 THEN
  182.       t$=t$+STR$(h)+" Second"
  183.       IF h>1 THEN t$=t$+"s"
  184.     END IF
  185.     FNActivityTime$=t$
  186.   END IF
  187. END DEF
  188.