\begin{manpage}{MS DOS Device Driver Library}{BBL}{Version 1.0}
\par
\subtitle{N...
...tion from the software and
documentation.
\par
\end{itemize}\par
\end{manpage}

The following QBASIC program demonstrates how to open BBL as a device and write two lines (default mode 1; the first line will be scrolled up).

    /* EXAMPLE 1 */
        'Demonstrate use of BBL from a BASIC program
        
        OPEN "bbl-drvr" FOR OUTPUT AS #1
        mode$ = CHR$(14)     'mode introducer
        vt$ = CHR$(11)       'vertical position introducer
        ht$ = CHR$(9)        'horizontal position introducer
        bs$ = CHR$(8)        'backspace
        cr$ = CHR$(13)       'carriage return
        lf$ = CHR$(10)       'line feed
        
        PRINT #1, mode$; "0"    'set to mode 0 and write out two lines
        PRINT #1, "12.34"
        PRINT #1, "56.78"
        
        PRINT #1, mode$; "1"    'just one line in mode 1
        PRINT #1, "12.34"

        PRINT #1, mode$; "2"    ' ... and in mode 2, only 3 chars wide
        PRINT #1, "012"
        
        start = TIMER
        PRINT #1, mode$; "1"       'in mode 1 ...
        FOR i = 0 TO 99
        PRINT #1, ht$; "1"         'go to position 1
        PRINT #1, USING "###"; i   'and write an integer
        NEXT i
        endt = TIMER
        PRINT "Elapsed time for 100 iterations = "; endt - start; "sec"
        
        END

The following example is a fragment from a Turbo C program that serves as the testing program for BBL.

        /* EXAMPLE 2 */
        /*  Turbo C program to test use of BBL device driver */
        
        #include        <stdio.h>
        #include        <conio.h>
        #include        <dos.h>
        
        FILE *out;
        void pause(void);
        void mode(int m);
        void hpos(int col);
        void vpos(int row);
        
        int main(void)
        {
                printf("Program to test BBL device driver\n");
                printf("When paused, press any key to continue\n\n");
                if ( (out=fopen("BBL-DRVR","wt")) == NULL) {
                        fprintf(stderr, "Cannot open output file.\n");
                        return 1;
                }
        
        // mode 0 wrap
                clrscr();
                printf("One long string, wraps to three lines in mode 1");
                pause();
                clrscr();
                mode(0);
                fputs("This line should wrap",out);
                pause();
                
        // wrap in mode 1  --- scrolls
                clrscr();
                printf("One string (pause in middle) scrolls in mode 1");
                pause();
                clrscr();
                mode(1);
                fputs("Wrap ",out);
                pause();
                fputs("Scrol",out);
                pause();
        
        // wrap in mode 2 --- scrolls
                clrscr();
                printf("One string (pause in middle) scrolls in mode 2");
                pause();
                clrscr();
                mode(2);
                fputs("Wrp",out);
                pause();
                fputs("Scl",out);
                pause();
        
                return 0;
        }
        
        void mode(int m)
        {
                fputc('\x0e',out); fputc('0'+m,out);
        }
        
        void vpos(int row)
        {
                fputc('\v',out); fputc('0'+row,out);
        }
        
        void hpos(int col)
        {
                fputc('\t',out); fputc('0'+col,out);
        }
        
        void pause(void)
        {
                fflush(out);
                while (!kbhit()) ;
                getch();
        }