How can I write my own Print function?

 

Hello all

I want to write a function like this:

void myPrint(...args) {
        if (debugFlag)
                Print(...args)
}

But I don't know what argument I should pass to myPrint() function instead of ...args which support all data types

Thanks in advance

 
MohammadX: Hello all. I want to write a function like this: But I don't know what argument I should pass to myPrint() function instead of ...args which support all data types. Thanks in advance
 
MohammadX:

Hello all

I want to write a function like this:

But I don't know what argument I should pass to myPrint() function instead of ...args which support all data types

Thanks in advance

If the purpose is to have control over the printing across compilations , for debugging , you could as well send the string as you would format it for Print()

So if you had :

Print("Ticket is "+IntegerToString(ticket));

you do :

DebugPrint("Ticket is "+IntegerToString(ticket));

and the DebugPrint has the print switch internally which is defined on top of your code.

Furthermore , in later or past projects you just throw the DebugPrint function in , set the define and replace all Prints with DebugPrints (via the find window)

 
Lorentzos Roussos #:

If the purpose is to have control over the printing across compilations , for debugging , you could as well send the string as you would format it for Print()

So if you had :

you do :

and the DebugPrint has the print switch internally which is defined on top of your code.

Furthermore , in later or past projects you just throw the DebugPrint function in , set the define and replace all Prints with DebugPrints (via the find window)


It was useful. Thanks 🙂