Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LogMsg in macros?
Dean, can you log to the logfile in a macro? Mine are getting pretty complex, and I need to know what's going on in there, even when I'm not home.
Just import the CQCLogger class and you are good to go. You could do like Wuench and create a logger class. I use this method as my logger for macros as needed. I inlcuded the literals I use for the token replacements.



    // Logger
    Card4   kMsg0(0);
    Card4   kMsg1(1);
    Card4   kMsg2(2);
    Card4   kMsg3(3);




    Method MsgLogger
        [In] Card4          MsgType
       ,[InOut] String      Msg
       ,[In] Formattable    Token1
       ,[In] Formattable    Token2
       ,[In] Formattable    Token3

        CQCLogger   Logger;
                Case kMsg1 :
                Case kMsg2 :
                Case kMsg3 :
                Default :

            // Used for debugging


            Logger.LogMsg("Error writing to log: " + $Exception.GetErrorText());

msg := "This is a message for %(1)";
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
Great, thanks!
Um...kinda unrelated to this, but...can you not define literals in a macro? I'd REALLY like to be able to, as it gives the thing some cleanliness and the ability to change things out a little easier.

I'm getting a compile error on the Literals tag.
Shouldn't be a problem. What is the compile error you are getting?
It's the early bird that catches the worm, but it's the second mouse that gets the cheese...
That probably means the blocks are out of order. It probably says it's expecting something else there, right?
Dean Roddey
Explorans limites defectum
Ya, it said it was expecting "Method" or "Methods" or one of those.

I probably did put them in the wrong order. :roll: I'll check tonight. I'm glad they're allowed!

Possibly Related Threads…
Thread Author Replies Views Last Post
  CML Macros - Replacing Quotes gReatAutomation 2 260 02-13-2021, 11:59 AM
Last Post: Dean Roddey
  CML LogMsg zra 2 510 04-08-2020, 12:04 PM
Last Post: zra
  Calling global actions from macros dlmorgan999 1 1,444 07-12-2015, 08:07 AM
Last Post: Dean Roddey
  Macros won't load in editor - service restart required bbrendon 6 3,235 05-03-2014, 12:47 PM
Last Post: Dean Roddey
  CML/Driver - Async Macros bph 5 2,059 08-02-2008, 11:30 PM
Last Post: Dean Roddey
  2.4 Exception in Driver Harness When Loading Macros wuench 2 1,478 07-02-2008, 11:11 AM
Last Post: Dean Roddey
  CQCLogger vs Deprecated LogMsg methods of CQCDriverBase jrlewis 11 4,435 11-01-2007, 10:08 AM
Last Post: Dean Roddey
  Actions, Macros, and Parameters noworries 6 2,042 01-20-2007, 05:24 PM
Last Post: Dean Roddey

Forum Jump:

Users browsing this thread: 1 Guest(s)