Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 911071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:08:33+00:00 2026-05-15T17:08:33+00:00

I am an amateur try to hack together a little project. It is a

  • 0

I am an amateur try to hack together a little project. It is a simple note storage and retrieval console app on Windows Vista (and XP – i’m hoping to run the whole thing off a USB Stick).

I use Sqlite as the store and Tcl/SQL scripts to add notes (and tags!) and also retrieve them by tag. 3 tables and a “Toxi” schema.

So anyway… I want to use it from either a “dos prompt” or more frequently tclsh (NOT wish!) I don’t want the windowing shell or to use TK at all. But to help visually distinguish some things, stdin from stdout, notes from timestamps, etc, I want to change the font color on-the-fly with some kind of crude markup.

I found a c++ project that will do exactly this! Jaded Hobo put it up on: http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=9130. Jaded Hobo says the header file “Console.H” is sufficient to include in a c++ project, but he doesn’t know TCL.

I found SWIG, the interface compiler, and I’m going to give it a try. But I’m clueless on a few things:

  1. Can just a header file be enough?

  2. The SWIG Win32 examples aren’t as edifying as the ‘nix example and they use MS VC++ (VStudio)- I want to use Quincy/MinGW.

    (Oh, btw this is my first ever attempt at using C of any kind. So can you show how to use SWIG with Quincy?)

  3. How can I glean from the header source just what the heck to type in my Tcl script to use it?

Thank you for reading this, let alone answering. I started to put it on comp.lang.tcl but I don’t like my email addr broadcast like that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:08:33+00:00Added an answer on May 15, 2026 at 5:08 pm

    A header isn’t enough by itself. On the other hand, you really don’t need to go to all that much work since this page indicates that the API is actually really simple. Here’s the C code that you need:

    #include <tcl.h>
    #include <windows.h>
    
    static int MySetConsoleColorCmd(
        ClientData clientData, Tcl_Interp *interp,
        int objc, Tcl_Obj *const objv[])
    {
        HANDLE hConsole;
        int code;
    
        /* Parse arguments, first for argument count, then for number format */
        if (objc != 2) {
            Tcl_WrongNumArgs(interp, 1, objv, "colorCode");
            return TCL_ERROR;
        } else if (Tcl_GetIntFromObj(interp, objv[1], &code) != TCL_OK) {
            return TCL_ERROR;
        }
    
        /* Get console handle, checking for the error case */
        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        if (hConsole == INVALID_HANDLE_VALUE) {
            Tcl_SetResult(interp, "not a console application", TCL_STATIC);
            return TCL_ERROR;
        }
    
        /* Set the color! */
        SetConsoleTextAttribute(hConsole, code);
        return TCL_OK;
    }
    
    /* Standard entry point for loadable library */
    int Consolecolor_Init(Tcl_Interp *interp) {
        Tcl_CreateObjCommand(interp, "consolecolor", MySetConsoleColorCmd,
                NULL, NULL);
        return TCL_OK;
    }
    

    Compile this up into a DLL (it’s got no fancy dependencies at all, beyond Tcl itself) called consolecolor.dll (the name should match the entry point function somewhat) and then you’ll be able to use the load command to import the new consolecolor command into your code, like this:

    load /path/to/consolecolor.dll
    
    # Duplicate example from the page mentioned at the top of this answer
    for {set k 1} {$k < 255} {incr k} {
        consolecolor $k
        puts "$k => I want to be nice today!"
    }
    

    For a guide to how to pick colors, see this MSDN page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am an amateur mac user and I'm trying to make a c++ project
I am an amateur programmer. When I publish an app from Visual Studio Express,
I'm an amateur, admittedly so, but I'm having fun trying to learn a little
I'm a total amateur writing a small App to track to changes in folders.
I want to try to write (amateur here!) a multiplayer game, and now at
I'm an amateur developer creating a short app and I'm having trouble using both
I'm an amateur developer and I'm creating an Android app that will perform long
My question might seem a little amateur but I can't find an answer online
I am an amateur programmer who is working on a console dice roller, quite
I'm an amateur with ANTLR and I'm creating an interpreter for a simple processor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.