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:
{$<varname>}
={$glob:<varname>}
{$lst:<varname>}
{$src:<varname>}
{$dst:<varname>}
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:
Say The value of the source tab scoped variable called "TabVar" is: {$src:tabvar}
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:
Say The console has been cleared before.<cls>
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:
-
Latest: v0.3.8 - 2024-05-17 - reorder version history
Command.Generic_Say.js.txt (10.4 KB) -
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) -
v0.3.1 - minor changes, supports automatic updates/scriptwizard:
Command.Generic_Say.js.txt (4.05 KB) -
v0.2a - clears console with and supports colored output:
Command.Generic_Say.js.txt (3.19 KB) -
v0.1 - initial version:
Command.Generic_Say.js.txt (1.72 KB)