Results 1 to 8 of 8

Thread: Newbie question about printf();

  1. #1
    Squire
    Join Date
    Oct 2008
    Location
    Canada
    Posts
    29

    Question Newbie question about printf();

    Hey gang:
    I'm just begining work with version 2 of the SDK. I often like to printf() debug stuff to the console whilst developing. So I had a look at class CL_Console and thought I'd be a stud and throw a printf() in there. Here's the code I threw in...

    -------------------------------------------------------------
    static void PrintF( char * Str, ... ) {
    char OutPut[1024];
    va_list Ap;
    va_start( Ap, Str );
    vsprintf( OutPut, Str, Ap );
    CL_TempStringFormat f( OutPut ); // Would rather just wite( OutPut )
    write( f.get_result() ); //
    va_end( Ap );
    }
    ----------------------------------------------------------------

    The compiler made me do a few crazy things to printf 'cause it complained if I sent "char OutPut[]' into write(). What I have shut the compiler up and the code is working. I just have an uneasy feeling about having to use CL_TempStringFormat. Is there a way I can rewrite it with a simple cast on 'OutPut' in the write() call? <I don't know much about templates, so looking at string_fromat.h confused me!>

    ...Nothing pressing as it is working, just thought somebody could bust this easily and brighten my day a bit. Thanks!

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    you can just use

    CL_String myString = "test";
    int myInt = 15;

    CL_Console::write_line("Hello, this is a %1 and %2, and these are the numbers %3 and %4", "string", myString, 17, myInt);

    No need to specify the types, it will be figured out automatically.

  3. #3
    Squire
    Join Date
    Oct 2008
    Location
    Canada
    Posts
    29

    Default

    Thanks! Yeah I figured that's what the clan was up to with the overloaded write() methods. I don't have the source handy on this computer now, but I do recall seeing a max of 4 or 5 arguments. That might cramp my style a bit. The printf I came up with does work, just I posted to see if someone could help show me how to crack the casting syntax of the template class CL_TempStringFormat and make me feel more at home with the SDK.
    No biggie. Thanks for posting. I think I'm gonna enjoy working with this SDK.
    P.S. Is version 2 (which used to be 0.9 not to long ago) listed as stable. That just poped in my head. I don't wanna get stuck working with something that is not stable. I'm assuming it's now stable and everyone's now using it...?

  4. #4
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    No, version 2 is not stable. We're still working on some quirks here and there.

    But most breaking changes from now on will be documented in the UPGRADE.txt file, so it shouldn't be a problem using v2.

  5. #5
    Squire
    Join Date
    Oct 2008
    Location
    Canada
    Posts
    29

    Default

    Ok, Thanks. Well for the next quite a while I need the GUI mostly. Would you say that the GUI is stable (enough)?
    BTW, I found a "feature" while I was playing with the basic 2d example on Windows XP. Every once in a while when the mouse pointer leaves the the example windows focus the animation stops. Sometimes it does sometimes it doesn't. If it does stop, I noticed that if I roll the mouse wheel it will startup again. ...If that's all it is it doesn't concern me right now. Just put'n it out there.

  6. #6
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    Yes, GUI is stable enough to use. We already have a user making a huge GUI app using it.

    Although some of the components are a bit rough still. But the overall GUI design won't change much.

  7. #7
    Squire
    Join Date
    Oct 2008
    Location
    Canada
    Posts
    29

    Default

    Music to my eyes, sir! Thank-you kindly!
    Would that user be Seth and the amazing Novashell?
    Is there a rough E.T.A. on a stable 2.0?

  8. #8
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    No, its not Novashell, which use ClanLib 1.0.

    No estimates on stable - We will just have to see as we go along

Similar Threads

  1. The Q's, the A's, and the newbie
    By eboy767 in forum Novashell Game Creation System
    Replies: 1
    Last Post: 04-28-2009, 09:11 AM
  2. newbie Question
    By Kagg in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 10-15-2008, 02:04 PM
  3. newbie memory management
    By celtx in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 11-09-2007, 12:13 PM
  4. Newbie tips?
    By in forum Funeral Quest
    Replies: 2
    Last Post: 11-03-2005, 11:08 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •