I'm not sure if this would work for my purposes directly, as the variable will be sent to the clipboard via an inline function directly.. (I'm using this in conjunction with our discussions regarding richText.
Although, your point is well taken.
I suppose, by the same logic, I could have an inline function parse the tokens, send it back to VA, which can populate the story, and then send it out via the normal variable to clipboard inline function? That is, have an inline function function as write to log would.
i.e.
Set text [story] to '|{TXT:character1} and |{TXT:character2}...
Run Inline function : which removes "|", and setting the result to VA variable "storyRefresh"
then
Set richText to storyReady
Run Inline function : Which copies that to clipboard
Somewhat confusingly, and for context, if you recall our prior discussion, the inline function run to generate the variable text itself was . . . (I am citing it here, as I feel it would throw a wrench/complication in the proposed solution)
string openingBraceSubstitute = ((char)2).ToString();
string richText = VA.GetText("richText");
if (!String.IsNullOrEmpty(richText))
{
Clipboard.SetText
(
richText.Replace("\\{", openingBraceSubstitute)
.Replace("{", "|{")
.Replace("\\}", "}")
.Replace("\r\n", "{NEWLINE}")
.Replace(openingBraceSubstitute, "{")
);
That works well, and is allowing my tokens to function. My only issue now is "updating" the tokens.
It would seem, if I understand you correctly, your suggesting adding an escape, "|" to the token, which would prevent it from being updated on declaration, at which point I would "write to log" whenever I wanted to update it, correct?
But, that seems to negate purpose of us adding the openingBraceSubstitute (STX) placeholder in the first place... correct?
If you need more context (Skip if not) this is my current work flow....WordPad :
{TXT:Character1}
and {TXT:Character2}
went to the
mallRun command : Clipboard to Literal :
Execute precompiled Inline Function: 'C:\Program Files\VoiceAttack\Apps\Inline Functions\Rich Text Clipboard to Variable.dll', wait until execution finishes
Execute precompiled Inline Function: 'C:\Program Files\VoiceAttack\Apps\Inline Functions\Rich Text Literal with Token.dll', wait until execution finishes
Which runs two inline functions. The first, "Rich Text Clipboard to Variable" being :
using System;
using System.Text;
using System.Windows.Forms;
public class VAInline
{
public void main()
{
if (Clipboard.ContainsText(TextDataFormat.Rtf))
{
VA.SetText("richText", Clipboard.GetText(TextDataFormat.Rtf));
}
else
{
VA.SetText("richText", Clipboard.GetText());
VA.WriteToLog("No Rich Text Format data in clipboard; copied as regular text", "yellow");
}
}
}
and the second, "Rich Text Literal with Token" being :
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
public class VAInline
{
public void main()
{
string openingBraceSubstitute = ((char)2).ToString();
string richText = VA.GetText("richText");
if (!String.IsNullOrEmpty(richText))
{
Clipboard.SetText
(
richText.Replace("\\{", openingBraceSubstitute)
.Replace("{", "|{")
.Replace("\\}", "}")
.Replace("\r\n", "{NEWLINE}")
.Replace(openingBraceSubstitute, "{")
);
}
else
{
VA.WriteToLog("No text to paste", "red");
}
}
}
/* */
which gives me a clipboard value of :
|{\rtf1\ansi\ansicpg1252\deff0\nouicompat|{\fonttbl|{\f0\fnil\fcharset0 Calibri;}}{NEWLINE}|{\*\generator Riched20 10.0.19041}\viewkind4\uc1 {NEWLINE}\pard\sa200\sl276\slmult1\f0\fs22\lang9{TXT:Character1} \b and\b0 {TXT:Character2} \ul went\ulnone to the \i mall\i0\par{NEWLINE}\par{NEWLINE}}{NEWLINE}
which is manually placed into the "set text value to" field.
I am then wanting to populate that variable.
To test my current version, vs the proposed solution, I placed 2 variations of the above into variables as follows :
Current Version:
Set text [story] to '|{\rtf1\ansi\ansicpg1252\deff0\nouicompat|{\fonttbl|{\f0\fnil\fcharset0 Calibri;}}{NEWLINE}|{\*\generator Riched20 10.0.19041}\viewkind4\uc1 {NEWLINE}\pard\sa200\sl276\slmult1\f0\fs22\lang9
{TXT:Character1} \b and\b0
{TXT:Character2} \ul went\ulnone to the \i mall\i0\par{NEWLINE}\par{NEWLINE}}{NEWLINE}'
With proposed escapes:
Set text [story2] to '|{\rtf1\ansi\ansicpg1252\deff0\nouicompat|{\fonttbl|{\f0\fnil\fcharset0 Calibri;}}{NEWLINE}|{\*\generator Riched20 10.0.19041}\viewkind4\uc1 {NEWLINE}\pard\sa200\sl276\slmult1\f0\fs22\lang9
|{TXT:Character1} \b and\b0
|{TXT:Character2} \ul went\ulnone to the \i mall\i0\par{NEWLINE}\par{NEWLINE}}{NEWLINE}'
and executed the following :
Set text [Character1] to [Not Set]
Set text [Character2] to [Not Set]
Set text [story] to '|{\rtf1\ansi\ansicpg1252\deff0\nouicompat|{\fonttbl|{\f0\fnil\fcharset0 Calibri;}}{NEWLINE}|{\*\generator Riched20 10.0.19041}\viewkind4\uc1 {NEWLINE}\...
Set text [story2] to '|{\rtf1\ansi\ansicpg1252\deff0\nouicompat|{\fonttbl|{\f0\fnil\fcharset0 Calibri;}}{NEWLINE}|{\*\generator Riched20 10.0.19041}\viewkind4\uc1 {NEWLINE}...
Set text [Character1] to 'Bill'
Set text [Character2] to 'Ted'
Set text [richText] to [story]
Execute precompiled Inline Function: 'C:\Program Files\VoiceAttack\Apps\Inline Functions\Rich Text Variable to Clipboard.dll', wait until execution finishes
Press Left Ctrl+V keys and hold for 0.05 seconds and release
Set text [richText] to [story2]
Execute precompiled Inline Function: 'C:\Program Files\VoiceAttack\Apps\Inline Functions\Rich Text Variable to Clipboard.dll', wait until execution finishes
Press Left Ctrl+V keys and hold for 0.05 seconds and release
with the output being :
Not set and Not set went to the mall
TXT:Character1 andTXT:Character2 went to the mall