home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l180 / 1.ddi / CDEMO1.BAS < prev    next >
Encoding:
BASIC Source File  |  1989-02-07  |  6.2 KB  |  187 lines

  1.   ' ************************************************
  2.   ' **  Name:          CDEMO1                     **
  3.   ' **  Type:          Program                    **
  4.   ' **  Module:        CDEMO1.BAS                 **
  5.   ' **  Language:      Microsoft QuickBASIC 4.00  **
  6.   ' ************************************************
  7.   '
  8.   ' Demonstrates the QuickC routines presented in
  9.   ' the file CTOOLS1.C.
  10.   '
  11.   ' USAGE:           No command line parameters
  12.   ' REQUIREMENTS:    CGA
  13.   '                  MIXED.QLB/.LIB
  14.   ' .MAK FILE:       (none)
  15.   ' PARAMETERS:      (none)
  16.   ' VARIABLES:       a%(0 TO 1999) Storage space for first text screen
  17.   '                  b%(0 TO 1999) Storage space for second text screen
  18.   '                  i%            Looping index
  19.   '                  sseg%         Word and byte move source segment
  20.   '                                part of address
  21.   '                  soff%         Word and byte move source offset
  22.   '                                part of address
  23.   '                  dseg%         Word and byte move destination segment
  24.   '                                part of address
  25.   '                  doff%         Word and byte move destination offset
  26.   '                                part of address
  27.   '                  nwords%       Number of words to move
  28.   '                  nbytes%       Number of bytes to move
  29.   '                  t$            Copy of TIME$
  30.   '                  quitflag%     Signal to end first demonstration
  31.   
  32.   
  33.   ' Functions
  34.     DECLARE FUNCTION IsItAlnum% CDECL (BYVAL c AS INTEGER)
  35.     DECLARE FUNCTION IsItAlpha% CDECL (BYVAL c AS INTEGER)
  36.     DECLARE FUNCTION IsItAscii% CDECL (BYVAL c AS INTEGER)
  37.     DECLARE FUNCTION IsItCntrl% CDECL (BYVAL c AS INTEGER)
  38.     DECLARE FUNCTION IsItDigit% CDECL (BYVAL c AS INTEGER)
  39.     DECLARE FUNCTION IsItGraph% CDECL (BYVAL c AS INTEGER)
  40.     DECLARE FUNCTION IsItLower% CDECL (BYVAL c AS INTEGER)
  41.     DECLARE FUNCTION IsItPrint% CDECL (BYVAL c AS INTEGER)
  42.     DECLARE FUNCTION IsItPunct% CDECL (BYVAL c AS INTEGER)
  43.     DECLARE FUNCTION IsItSpace% CDECL (BYVAL c AS INTEGER)
  44.     DECLARE FUNCTION IsItUpper% CDECL (BYVAL c AS INTEGER)
  45.     DECLARE FUNCTION IsItXDigit% CDECL (BYVAL c AS INTEGER)
  46.   
  47.   ' Subprograms
  48.     DECLARE SUB MovBytes CDECL (sseg%, soff%, dseg%, doff%, nbytes%)
  49.     DECLARE SUB MovWords CDECL (sseg%, soff%, dseg%, doff%, nwords%)
  50.   
  51.   ' Make two buffers for the first page of video memory
  52.     DIM a%(0 TO 1999), b%(0 TO 1999)
  53.   
  54.   ' Prevent scrolling when printing in row 25, column 80
  55.     VIEW PRINT 1 TO 25
  56.   
  57.   ' Create the first page of text
  58.     CLS
  59.     COLOR 14, 4
  60.     FOR i% = 1 TO 25
  61.         PRINT STRING$(80, 179);
  62.     NEXT i%
  63.     COLOR 15, 1
  64.     LOCATE 11, 25
  65.     PRINT STRING$(30, 32);
  66.     LOCATE 12, 25
  67.     PRINT "    -  Calling MovWords  -    "
  68.     LOCATE 13, 25
  69.     PRINT STRING$(30, 32);
  70.   
  71.   ' Move the screen memory into the first array
  72.     sseg% = &HB800
  73.     soff% = 0
  74.     dseg% = VARSEG(a%(0))
  75.     doff% = VARPTR(a%(0))
  76.     nwords% = 2000
  77.     MovWords sseg%, soff%, dseg%, doff%, nwords%
  78.   
  79.   ' Create the second page of text
  80.     CLS
  81.     COLOR 14, 4
  82.     FOR i% = 1 TO 25
  83.         PRINT STRING$(80, 196);
  84.     NEXT i%
  85.     COLOR 15, 1
  86.     LOCATE 11, 25
  87.     PRINT STRING$(30, 32);
  88.     LOCATE 12, 25
  89.     PRINT "    -  Calling MovBytes  -    "
  90.     LOCATE 13, 25
  91.     PRINT STRING$(30, 32);
  92.   
  93.   ' Move the screen memory into the second array
  94.     sseg% = &HB800
  95.     soff% = 0
  96.     dseg% = VARSEG(b%(0))
  97.     doff% = VARPTR(b%(0))
  98.     nwords% = 2000
  99.     MovWords sseg%, soff%, dseg%, doff%, nwords%
  100.   
  101.   ' Set destination to the video screen memory
  102.     dseg% = &HB800
  103.     doff% = 0
  104.   
  105.   ' Do the following until a key is pressed
  106.     DO
  107.       
  108.       ' Move 2000 words from first array to screen memory
  109.         sseg% = VARSEG(a%(0))
  110.         soff% = VARPTR(a%(0))
  111.         nwords% = 2000
  112.         MovWords sseg%, soff%, dseg%, doff%, nwords%
  113.       
  114.       ' Wait one second
  115.         t$ = TIME$
  116.         DO
  117.             IF INKEY$ <> "" THEN
  118.                 t$ = ""
  119.                 quitFlag% = 1
  120.             END IF
  121.         LOOP UNTIL TIME$ <> t$
  122.       
  123.       ' Move 4000 bytes from second array to screen memory
  124.         sseg% = VARSEG(b%(0))
  125.         soff% = VARPTR(b%(0))
  126.         nbytes% = 4000
  127.         MovBytes sseg%, soff%, dseg%, doff%, nbytes%
  128.       
  129.       ' Wait one second
  130.         t$ = TIME$
  131.         DO
  132.             IF INKEY$ <> "" THEN
  133.                 t$ = ""
  134.                 quitFlag% = 1
  135.             END IF
  136.         LOOP UNTIL TIME$ <> t$
  137.       
  138.     LOOP UNTIL quitFlag%
  139.   
  140.   ' Create a table of all 256 characters and their type designations
  141.     FOR i% = 0 TO 255
  142.       
  143.       ' After each screenful display a heading
  144.         IF i% MOD 19 = 0 THEN
  145.           
  146.           ' If not the first heading, prompt user before continuing
  147.             IF i% THEN
  148.                 PRINT
  149.                 PRINT "Press any key to continue"
  150.                 DO WHILE INKEY$ = ""
  151.                 LOOP
  152.             END IF
  153.           
  154.           ' Print the heading
  155.             CLS
  156.             PRINT "Char   Alnum Alpha Ascii Cntrl Digit Graph ";
  157.             PRINT "Lower Print Punct Space Upper XDigit"
  158.             PRINT
  159.         END IF
  160.       
  161.       ' Some characters we don't want to display
  162.         SELECT CASE i%
  163.         CASE 7, 8, 9, 10, 11, 12, 13, 29, 30, 31
  164.             PRINT USING "###    "; i%;
  165.         CASE ELSE
  166.             PRINT USING "### \ \"; i%, CHR$(i%);
  167.         END SELECT
  168.       
  169.       ' Display "1" if test is true, "0" otherwise
  170.         PRINT USING "  #   "; 1 + (0 = IsItAlnum%(i%));
  171.         PRINT USING "  #   "; 1 + (0 = IsItAlpha%(i%));
  172.         PRINT USING "  #   "; 1 + (0 = IsItAscii%(i%));
  173.         PRINT USING "  #   "; 1 + (0 = IsItCntrl%(i%));
  174.         PRINT USING "  #   "; 1 + (0 = IsItDigit%(i%));
  175.         PRINT USING "  #   "; 1 + (0 = IsItGraph%(i%));
  176.         PRINT USING "  #   "; 1 + (0 = IsItLower%(i%));
  177.         PRINT USING "  #   "; 1 + (0 = IsItPrint%(i%));
  178.         PRINT USING "  #   "; 1 + (0 = IsItPunct%(i%));
  179.         PRINT USING "  #   "; 1 + (0 = IsItSpace%(i%));
  180.         PRINT USING "  #   "; 1 + (0 = IsItUpper%(i%));
  181.         PRINT USING "  #   "; 1 + (0 = IsItXDigit%(i%))
  182.       
  183.     NEXT i%
  184.     END
  185.   
  186.  
  187.