Ansisub 1/2

 BBS: Inland Empire Archive
Date: 02-20-93 (11:17)             Number: 390
From: JEFF FREEMAN                 Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Ansisub 1/2                    Conf: (2) Quik_Bas
The following routines have ZERO error-trapping.

    This program will emulate ANSI, such as files created with TDraw,
    etc.

    This is far preferable to opening the screen as a file, since that
    prohibits the use of several BASIC functions (VIEW PRINT, CSRLIN,
    et al).

    Currently, only colors and cursor movement/locates are
    supported.  I was able to display several ansi files without a
    problem with only these features.

As I understand it, PUBLIC DOMAIN, by definition, means
that the thing *cannot* be copyrighted.

You may need to add some code to properly deal with CHR$(10), CHR$(13)
and CHR$(12).  I will later, I suppose. ;)

=====8<===============8<==============8<===========
DECLARE SUB DoAnsi (Ansi$)
DECLARE SUB AnsiSub (Txt$)
DEFINT A-Z

    'Released to the Public Domain by Jeff Freeman, 1993

CLS

  OPEN COMMAND$ FOR INPUT AS #1
  WHILE NOT EOF(1)
    LINE INPUT #1, Txt$
    AnsiSub Txt$
  WEND
  CLOSE 1

SUB AnsiSub (Txt$)

    'This sub will display up to the first ANSI sequence, pass that
    'sequence to the DOANSI SUB and remove it (and the displayed portion
    'of the string) from the string, repeating until the entire string
    'has either been displayed or passed to DOANSI.

  DO
    StrStart = INSTR(Txt$, CHR$(27) + "[")
    IF StrStart = 0 THEN StrStart = LEN(Txt$) + 1
    IF StrStart <> 1 THEN
      PRINT LEFT$(Txt$, StrStart - 1);
      Txt$ = MID$(Txt$, StrStart)
    END IF
    StrEnd = 1
    DO: StrEnd = StrEnd + 1
    LOOP WHILE INSTR("[0123456789;", MID$(Txt$, StrEnd, 1))_
                                    <> 0 AND StrEnd <= LEN(Txt$)
    Ansi$ = LEFT$(Txt$, StrEnd)
    Txt$ = MID$(Txt$, StrEnd + 1)
    DoAnsi Ansi$
  LOOP WHILE LEN(Txt$)

END SUB

'sub DOANSI () STATIC is in the following post.


---
 * Origin: WarWorld's point away from home... (1:124/7006.1)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET