Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

SDK QPuts or Command

Aug
1,954
71
As I continue to learn more about using the functions in TakeCmd.dll with PureBasic,
I was wondering what the advantages are of using QPuts instead of Command for displaying output.

As an example,
Command allows me to expand TCC internal variables before output;
Code:
If Len(theArg) = 0
    Command_("echo USAGE: Test %_year-1960",0)
    ProcedureReturn #Null 
  Else
    Evaluate_(*lpszString)
  
    theResult = PeekS(*lpszString)
    
    Command_("echo " + theResult, 0)
  EndIf
That is, using Command will display,
using echo,
Code:
USAGE: Test 2023-1960
whereas QPuts will display,
Code:
USAGE: Test %_year-1960

Advice from the plugin experts (@vefatica and @Charles Dye) would be appreciated.

Joe
 
QPuts() just displays a string. That's all it does. It's a handy function for plugins because it supports TCC features like colorized stderr and Unicode redirection, but really, that's all it does: output a string. (Printf() and Qprintf() also support colorized stderr et al.)

Command(), on the other hand, can do pretty much anything. The downside is that it can do... pretty much anything. Maybe the command you're calling has been disabled, or aliased. Maybe it's an external that does something different on your system versus mine. Also, being vastly more complex, Command() is probably slower as well.
 
Printf() and Qprintf() are what I almost always use. They are, by far, the most robust.

If I don't care about piping or redirection (notably, sending VT control sequences) I use WriteConsole() and a handle to "CONOUT$" (see the help for CreateFile()).
 

Similar threads

Back
Top