GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Command: Say (print text to the script console)


#1

Say - a simple to use script command to output text to the script console of DO.

Description:
Prints text to the other logs/script console of DO. It’s handy while test driving buttons, logging actions and variable values when clicking buttons or printing results after running commands. The command is called say and not echo, print, log, etc. because these are already in use by windows or batch commands. You can also use it to clear the script console before running things that output a lot of text.

Features:

  • colored output (not officially supported, so use at your own risk)
  • resolving of variables of any scope (global/lister/tab…)
  • using standard syntax known from buttons and modifiers: {$} = {$glob:}, {$lst:}, {$src:}, {$dst:}

Usage:
To print a regular text:

Say This is regular text!To print a regular text and show content of a global variable:

Say The global variable "MyVar" is set to: {$myvar} //or Say The global variable "MyVar" is set to: {$glob:myvar}To output a source tab scoped variable:

To print red text :

Say <red>This is red text.To print white text on red background:

Say <white,red>This is white text on red background.To clear the script console before printing text:

Demo:


The codes used to create the output above:

DOpus.Create.Command.RunCommand("Say <white,dpurple>Hello! o) Tthis is a quick colored text output demonstration!<cls>"); DOpus.Create.Command.RunCommand("Say"); PrintCol('blue'); PrintCol('purple'); PrintCol('red'); PrintCol('orange'); PrintCol('yellow'); PrintCol('cyan'); PrintCol('green'); PrintCol('gray'); DOpus.Create.Command.RunCommand("Say"); DOpus.Create.Command.RunCommand("Say <,cyan>This text has some cyan,<clear> <white,red>red<clear>, <white,blue>blue<clear> and <white,black>black bg<clear>, <,cyan>you see? o)"); function PrintCol(col){ var pad=""; while (pad.length+col.length<10) pad+=" "; DOpus.Create.Command.RunCommand("Say <"+col+",black>"+col.toUpperCase() +pad+"<l"+col+"> Light <"+col+ ">Regular <d"+col+">Dark "+ "<white,l"+col+"> LightBG <white,"+col+"> RegularBG <white,d"+col+"> DarkBG "); }


Hint:
To get the same behaviour as an internal DO command (in regard to resolving codes for each item and being run multiple times)…
Create a usercommand called “ForEach” and use Say in conjunction with ForEach like shown right below the screenshot:

ForEach CMD=Say Processing file: {f} SetAttr TOGGLEATTR=a

Installation:
To install the command, download the *.js.txt file below and drag it to Preferences / Toolbars / Scripts.
After that the command shall be ready to use in buttons, scripts and externally from dopusrt.exe of course.

cya,
tbone

Download:

[ul][li]Latest: v0.3.2 - command-template added to make button variables like {file} work, fixed “Say” as the commands name:
Command.Generic_Say.js.txt (8.72 KB)
[/li]
[li]v0.3.1 - minor changes, supports automatic updates/scriptwizard:
Command.Generic_Say.js.txt (4.05 KB)
[/li]
[li]v0.2a - clears console with and supports colored output:
Command.Generic_Say.js.txt (3.19 KB)
[/li]
[li]v0.1 - initial version:
Command.Generic_Say.js.txt (1.72 KB)[/li][/ul]


Test basic code standard Opus?
Copy folder with parent
ScriptCommands w/o template and {file}
Using variables in COPY
Button to output text only
#2

Updated to v0.2

  • clears console with
  • supports colored output, watch the screenie! o)

Updated to v0.2a

  • keep text in <…>, if it does not match fg/bg color names

#3

Updated to v0.3.2

  • command-template added to make button variables like {file} work
  • fixed “Say” as the commands name

#4

Added information on how to make “Say” work like a regular internal command, watch the “Hint:” section.
Some more details and the “why” can be found here: Script command vs. internal command and {f}