Something exist to understand ANSI escape sequences in VB?

[b][red]This message was edited by mercman2000 at 2006-5-28 14:56:6[/red][/b][hr]
Does something exist to do this?

[code]←[0;30;40m[/code]

^^ Stuff like that. (← is supposed to be a left arrow, denoting the start of the escape sequence)

I'm just looking for read capabilities, I have the write part taken care of already.

If something already exists, I'll use it, but if not, I'll have to crack open my DOS 5 book so I can re-train myself on how to read those codes and build some kind of interpreter and display program.

Idears, or am I going to be building this one?


Comments

  • [b][red]This message was edited by DrMarten at 2006-5-29 2:39:27[/red][/b][hr]

    See the following stuff on ANSI escape stuff:>>

    http://en.wikipedia.org/wiki/ANSI_escape_code

    http://www.atariarchives.org/cfn/12/02/0075.php

    See the following for details on Decimal, Octal and Hex values of all the printable & non-printable characters:>>

    www.asciitable.com



    Regards,

    Dr M.





  • Thanks!

    But, I already know how to use ANSI, been doing it since the olden days of MS-DOS 5. I was wondering if something existed for VB already that would let me place an .ANS file into a textbox or some other control, and have all the dirty work done for me, or would I need to write up my own method to process an individual file.

    : [b][red]This message was edited by DrMarten at 2006-5-29 2:39:27[/red][/b][hr]
    :
    : See the following stuff on ANSI escape stuff:>>
    :
    : http://en.wikipedia.org/wiki/ANSI_escape_code
    :
    : http://www.atariarchives.org/cfn/12/02/0075.php
    :
    : See the following for details on Decimal, Octal and Hex values of all the printable & non-printable characters:>>
    :
    : www.asciitable.com
    :
    :
    :
    : Regards,
    :
    : Dr M.
    :
    :
    :
    :
    :
    :

    ---------------------------------------------
    I've got a plan, but I'm going to need a dead monkey, some empty liquor bottles, and a vacuum cleaner.

  • : Thanks!
    :
    : But, I already know how to use ANSI, been doing it since the olden days of MS-DOS 5. I was wondering if something existed for VB already that would let me place an .ANS file into a textbox or some other control, and have all the dirty work done for me, or would I need to write up my own method to process an individual file.

    ======================================================================
    Hi,

    All i can think of doing is to write your escape sequence(s) in on or more file(s) then write the file contents to a textbox.

    Alternatively put sequences of escape codes into variuos appropriately named strings, then copy those to a textbox.

    Don't forget to append text to your textbox if you are trying to create a picture in a textbox from characters.

    I once saw a demo on an Amiga whch may have used escape sequences.
    What it did was to build a picture from the dots that create characters, possibly masking some so that some dots were shown, others not shown.

    Imagine say a letter "S" overwritten with an "I" wouldlook nearly like a "$" except the line would be right through.

    Not sure if that is what your after doing?


    Regards,

    Dr M.

  • Visual Basic Language Reference

    AnsiSee Also
    Visual Basic Language Keywords
    The Ansi keyword indicates that strings are converted to American National Standards Institute (ANSI) values regardless of the name of the method being declared.

    The Ansi keyword is used in this context:

    Declare Statement

    Smart Device Developer Notes
    This keyword is not supported.

    See Also
    Visual Basic Language Keywords

  • Visual Basic Reference Error Messages

    The targeted version of the .NET Compact Framework does not support using the Ansi, Auto, or Unicode modifierSee Also
    Ansi | Auto | Unicode
    The version of the .NET Compact Framework you are working with does not support the Ansi, Auto, or Unicode modifiers.

    To correct this error

    Remove the modifier.
    See Also
    Ansi | Auto | Unicode

  • [b][red]This message was edited by DrMarten at 2006-5-29 11:55:52[/red][/b][hr]
    Express edition is like VB.Net get it FREE here.>>
    http://msdn.microsoft.com/vstudio/express/vb/

    You may need it for some of this stuff.

    [b][blue]You can have VB and VB.Net or/and express editions installed all at the same time as they go into different directories. :-)[/blue]
    [/b]
    [green]

    Regards,

    Dr M.[/green]
    ======================================================================

    .NET Framework Developer's Guide

    Specifying a Character SetSee Also
    Creating Prototypes in Managed Code | Platform Invoke Examples | DllImportAttribute Class | Marshaling Data with Platform Invoke
    Language
    C#

    C++

    Visual Basic

    Show All
    The DllImportAttribute.CharSet field controls string marshaling and determines how platform invoke finds function names in a DLL. This topic describes both behaviors.

    Some APIs export two versions of functions that take string arguments: narrow (ANSI) and wide (Unicode). The Win32 API, for instance, includes the following entry-point names for the MessageBox function:
    [red][b]
    MessageBoxA
    Provides 1-byte character ANSI formatting, distinguished by an "A" appended to the entry-point name. Calls to MessageBoxA always marshal strings in ANSI format, as is common on Windows 95 and Windows 98 platforms.
    [/b][/red]
    MessageBoxW
    Provides 2-byte character Unicode formatting, distinguished by a "W" appended to the entry-point name. Calls to MessageBoxW always marshal strings in Unicode format, as is common on Windows NT, Windows 2000, and Windows XP platforms.

    String Marshaling and Name Matching
    The CharSet field accepts the following values:

    CharSet.Ansi (default value)

    String marshaling
    Platform invoke marshals strings from their managed format (Unicode) to ANSI format.

    Name matching
    When the DllImportAttribute.ExactSpelling field is true, as it is by default in Visual Basic .NET, platform invoke searches only for the name you specify. For example, if you specify MessageBox, platform invoke searches for MessageBox and fails when it cannot locate the exact spelling.

    When the ExactSpelling field is false, as it is by default in the Managed Extensions for C++ and C#, platform invoke searches for the unmangled alias first (MessageBox), then the mangled name (MessageBoxA) if the unmangled alias is not found. Notice that ANSI name-matching behavior differs from Unicode name-matching behavior.

    CharSet.Unicode

    String marshaling
    Platform invoke copies strings from their managed format (Unicode) to Unicode format.

    Name matching
    When the ExactSpelling field is true, as it is by default in Visual Basic .NET, platform invoke searches only for the name you specify. For example, if you specify MessageBox, platform invoke searches for MessageBox and fails if it cannot locate the exact spelling.

    When the ExactSpelling field is false, as it is by default in the Managed Extensions for C++ and C#, platform invoke searches for the mangled name first (MessageBoxW), then the unmangled alias (MessageBox) if the mangled name is not found. Notice that Unicode name-matching behavior differs from ANSI name-matching behavior.

    CharSet.Auto

    Platform invoke chooses between ANSI and Unicode formats at run time, based on the target platform.
    Specifying a Character Set in Visual Basic
    The following example declares the MessageBox function three times, each time with different character-set behavior. You can specify character-set behavior in Visual Basic by adding the Ansi, Unicode, or Auto keyword to the declaration statement.

    If you omit the character-set keyword, as is done in the first declaration statement, the DllImportAttribute.CharSet field defaults to the ANSI character set. The second and third statements in the example explicitly specify a character set with a keyword.

    [Visual Basic]
    Imports System.Runtime.InteropServices

    Public Class Win32
    Declare Function MessageBoxA Lib "user32.dll"(ByVal hWnd As Integer, _
    ByVal txt As String, ByVal caption As String, _
    ByVal Typ As Integer) As Integer

    Declare Unicode Function MessageBoxW Lib "user32.dll" _
    (ByVal hWnd As Integer, ByVal txt As String, _
    ByVal caption As String, ByVal Typ As Integer) As Integer

    Declare Auto Function MessageBox Lib "user32.dll" _
    (ByVal hWnd As Integer, ByVal txt As String, _
    ByVal caption As String, ByVal Typ As Integer) As Integer
    End Class

    Specifying a Character Set in C# and C++
    The DllImportAttribute.CharSet field identifies the underlying character set as ANSI or Unicode. The character set controls how string arguments to a method should be marshaled. Use one of the following forms to indicate the character set:

    [C#]
    [DllImport("dllname", CharSet=CharSet.Ansi)]
    [DllImport("dllname", CharSet=CharSet.Unicode)]
    [DllImport("dllname", CharSet=CharSet.Auto)]

    [C++]
    [DllImport("dllname", CharSet=CharSet::Ansi)]
    [DllImport("dllname", CharSet=CharSet::Unicode)]
    [DllImport("dllname", CharSet=CharSet::Auto)]

    The following example shows three managed definitions of the MessageBox function attributed to specify a character set. In the first definition, by its omission, the CharSet field defaults to the ANSI character set.

    [C#]
    [DllImport("user32.dll")]
    public static extern int MessageBoxA(int hWnd, String text,
    String caption, uint type);
    [DllImport("user32.dll", CharSet=CharSet.Unicode)]
    public static extern int MessageBoxW(int hWnd, String text,
    String caption, uint type);
    [DllImport("user32.dll", CharSet=CharSet.Auto)]
    public static extern int MessageBox(int hWnd, String text,
    String caption, uint type);

    [C++]
    typedef void* HWND;

    //Can use MessageBox or MessageBoxA.
    [DllImport("user32")]
    extern "C" int MessageBox(HWND hWnd,
    String* pText,
    String* pCaption,
    unsigned int uType);

    //Can use MessageBox or MessageBoxW.
    [DllImport("user32", CharSet=CharSet::Unicode)]
    extern "C" int MessageBoxW(HWND hWnd,
    String* pText,
    String* pCaption,
    unsigned int uType);

    //Must use MessageBox.
    [DllImport("user32", CharSet=CharSet::Auto)]
    extern "C" int MessageBox(HWND hWnd,
    String* pText,
    String* pCaption,
    unsigned int uType);

    See Also
    Creating Prototypes in Managed Code | Platform Invoke Examples | DllImportAttribute Class | Marshaling Data with Platform Invoke

  • ANSI used in that sense is a standard for encoding characters, not the old-school DOS coloring technique, but referring to code pages. (I think)

    I think after searching extensively for a week and then asking here, my only alternative is going to be to write up something that will be able to parse out these files for me.

    Just trying to weasel out of some work is all. If I want to make this little animation project come together, looks like I'll have to write the bloody thing myself.

    Thanks for the help and reference materials, a little refresher course never hurt anybody.
    ---------------------------------------------
    I've got a plan, but I'm going to need a dead monkey, some empty liquor bottles, and a vacuum cleaner.

  • Like you said is not the same thing what VB knows about ANSI, that ANSI ESCAPE SEQUENCE. Those escape sequences even in MSDOS (not *nix) was not very popular, because you had to load a driver that wasnt isntalled with the product, you had to edit you config.sys and add the ansi.sys driver. Norton Utilities had an exelent replacement for the ansi.sys.

    The solely purpouse was position and color, some escape not ansi allow other fucntions, even when there is a product out there, I would write that, parse that file is not RegEx expression, is only a translation between a fixed length string into a function in vb. I would think translate into RTF.

    ----
    : ANSI used in that sense is a standard for encoding characters, not the old-school DOS coloring technique, but referring to code pages. (I think)
    :
    : I think after searching extensively for a week and then asking here, my only alternative is going to be to write up something that will be able to parse out these files for me.
    :
    : Just trying to weasel out of some work is all. If I want to make this little animation project come together, looks like I'll have to write the bloody thing myself.
    :
    : Thanks for the help and reference materials, a little refresher course never hurt anybody.
    : ---------------------------------------------
    : I've got a plan, but I'm going to need a dead monkey, some empty liquor bottles, and a vacuum cleaner.
    :
    :

    [red]Good luck![/red]
    [blue]Hackman[/blue]

  • Translate into RTF? That would add ungodly amounts of overhead I think.

    You have an awesome idea though, I know what characters are going to be used for the look of the ANSI artwork, just the ASCII codes 176,177,178, and 219. If I twiddled with some bits as I was reading the file...

    Foreground:
    000 - Black
    001 - Red
    010 - Green
    011 - Yellow
    100 - Blue
    101 - Magenta
    110 - Cyan
    111 - White

    Background:
    000 - Black
    001 - Red
    010 - Green
    011 - Yellow
    100 - Blue
    101 - Magenta
    110 - Cyan
    111 - White

    Character:
    00 - ░
    01 - ▒
    10 - ▓
    11 - █

    So, the character 30 (00011110) would mean, black foreground, white background, and use ▓ as the character. Hrm. You know, I think I just might have something here.

    : Like you said is not the same thing what VB knows about ANSI, that ANSI ESCAPE SEQUENCE. Those escape sequences even in MSDOS (not *nix) was not very popular, because you had to load a driver that wasnt isntalled with the product, you had to edit you config.sys and add the ansi.sys driver. Norton Utilities had an exelent replacement for the ansi.sys.
    :
    : The solely purpouse was position and color, some escape not ansi allow other fucntions, even when there is a product out there, I would write that, parse that file is not RegEx expression, is only a translation between a fixed length string into a function in vb. I would think translate into RTF.
    :
    : ----
    : : ANSI used in that sense is a standard for encoding characters, not the old-school DOS coloring technique, but referring to code pages. (I think)
    : :
    : : I think after searching extensively for a week and then asking here, my only alternative is going to be to write up something that will be able to parse out these files for me.
    : :
    : : Just trying to weasel out of some work is all. If I want to make this little animation project come together, looks like I'll have to write the bloody thing myself.
    : :
    : : Thanks for the help and reference materials, a little refresher course never hurt anybody.
    : : ---------------------------------------------
    : : I've got a plan, but I'm going to need a dead monkey, some empty liquor bottles, and a vacuum cleaner.
    : :
    : :
    :
    : [red]Good luck![/red]
    : [blue]Hackman[/blue]
    :
    :

    ---------------------------------------------
    I've got a plan, but I'm going to need a dead monkey, some empty liquor bottles, and a vacuum cleaner.

  • Ok, why not HTML + CSS ?

    You have a file with this...

    [code]&#9619ABC&#9618DEF[/code]

    Replace with ...

    [code]

    ABC

    DEF[/code]

    tag do not need the

    .

    And a style sheet ...

    [code]&#9619 {
    color:red;
    back-color: blue
    }[/code]

    ITS ALMOST THE SAME TRANSLATE INTO RTF.
    --------------------

    : Translate into RTF? That would add ungodly amounts of overhead I think.
    :
    : You have an awesome idea though, I know what characters are going to be used for the look of the ANSI artwork, just the ASCII codes 176,177,178, and 219. If I twiddled with some bits as I was reading the file...
    :
    : Foreground:
    : 000 - Black
    : 001 - Red
    : 010 - Green
    : 011 - Yellow
    : 100 - Blue
    : 101 - Magenta
    : 110 - Cyan
    : 111 - White
    :
    : Background:
    : 000 - Black
    : 001 - Red
    : 010 - Green
    : 011 - Yellow
    : 100 - Blue
    : 101 - Magenta
    : 110 - Cyan
    : 111 - White
    :
    : Character:
    : 00 - ░
    : 01 - ▒
    : 10 - ▓
    : 11 - █
    :
    : So, the character 30 (00011110) would mean, black foreground, white background, and use ▓ as the character. Hrm. You know, I think I just might have something here.
    :
    : : Like you said is not the same thing what VB knows about ANSI, that ANSI ESCAPE SEQUENCE. Those escape sequences even in MSDOS (not *nix) was not very popular, because you had to load a driver that wasnt isntalled with the product, you had to edit you config.sys and add the ansi.sys driver. Norton Utilities had an exelent replacement for the ansi.sys.
    : :
    : : The solely purpouse was position and color, some escape not ansi allow other fucntions, even when there is a product out there, I would write that, parse that file is not RegEx expression, is only a translation between a fixed length string into a function in vb. I would think translate into RTF.
    : :
    : : ----
    : : : ANSI used in that sense is a standard for encoding characters, not the old-school DOS coloring technique, but referring to code pages. (I think)
    : : :
    : : : I think after searching extensively for a week and then asking here, my only alternative is going to be to write up something that will be able to parse out these files for me.
    : : :
    : : : Just trying to weasel out of some work is all. If I want to make this little animation project come together, looks like I'll have to write the bloody thing myself.
    : : :
    : : : Thanks for the help and reference materials, a little refresher course never hurt anybody.
    : : : ---------------------------------------------
    : : : I've got a plan, but I'm going to need a dead monkey, some empty liquor bottles, and a vacuum cleaner.
    : : :
    : : :
    : :
    : : [red]Good luck![/red]
    : : [blue]Hackman[/blue]
    : :
    : :
    :
    : ---------------------------------------------
    : I've got a plan, but I'm going to need a dead monkey, some empty liquor bottles, and a vacuum cleaner.
    :
    :

    [red]Good luck![/red]
    [blue]Hackman[/blue]

  • : Thanks!
    :
    : But, I already know how to use ANSI, been doing it since the olden days of MS-DOS 5. I was wondering if something existed for VB already that would let me place an .ANS file into a textbox or some other control, and have all the dirty work done for me, or would I need to write up my own method to process an individual file.

    ======================================================================

    Hi,

    On reading your original post here, i've thought that you could use a text_changed sub event to do all of this kind of processing for you automatically,[b][blue]if this is what your are after achieving?[/blue][/b]

    However, would you want the same text style in every textbox?
    I'm guessing you are after doing this in an automatic or a
    semi-automatic fashion?

    You could assign different ANSI sequences to different buttons or/and menu items too.
    This would give the effect of making programs, "skinnable", almost,
    with different colour backgrounds too.

    Is this along the lines of your original idea?


    Regards,

    Dr M.

  • [b][red]This message was edited by DrMarten at 2006-6-5 13:37:44[/red][/b][hr]
    Hi,

    This is also in the middle somewhere ( of this thread i mean ).


    On reading your original post here, i've thought that you could use a text_changed sub event to do all of this kind of processing for you automatically,if this is what your are after achieving?

    However, would you want the same text style in every textbox?
    I'm guessing you are after doing this in an automatic or a
    semi-automatic fashion?

    You could assign different ANSI sequences to different buttons or/and menu items too.
    This would give the effect of making programs, "skinnable", almost,
    with different colour backgrounds too.

    Is this along the lines of your original idea?


    Regards,

    Dr M.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories