Click
Click "New Command"
In the "When I say" field, enter a name for the command(of your own choosing)
Click "Other >", "Advanced", "Set a Text Value"
In the "Variable Name" field, enter "~file"(see VoiceAttackHelp.pdf page 177 and 178 for info on variable prefixes)
Click the radio button next to "Value from file/URI"
Click "..."
Browse to the config file you want to change(or a test copy of it, in case something goes wrong)
Click "Open"
Click "OK"
Click "Other >", "Advanced ⯈", "Set a Text Value"
In the "Variable Name" field, enter "~find"
In the "Text" field, enter the text you want to replace within the target file
Click "OK"
Click "Other >", "Advanced ⯈", "Set a Text Value"
In the "Variable Name" field, enter "~replace"
In the "Text" field, enter the text you want to insert into the target file
Click "OK"
Click "Other >", "Advanced ⯈", "Execute an Inline Function ⯈", "C# Code"
Copy this:
using System;
using System.Text.RegularExpressions;
public class VAInline
{
public void main()
{
string text = VA.GetText("~file");
string find = VA.GetText("~find");
string replace = VA.GetText("~replace");
if (text.IndexOf(find, StringComparison.OrdinalIgnoreCase) >= 0)
{
VA.SetText("~output", Regex.Replace(text, Regex.Escape(find), replace.Replace("$","$$"), RegexOptions.IgnoreCase));
VA.WriteToLog("Text found and replaced", "green");
}
else
{
VA.WriteToLog("Text not found", "red");
}
}
}
And paste over the default 27 lines(Ctrl-A, Ctrl-V)
Click "Compile", aftert a short delay you should see "Compile succesful" if you pasted correctly
Check "Wait for the inline function to finish before continuing"
In the "Description" field, enter "Find and replace"(this is optional, but helps when editing commands later on)
Click "OK"
Click "Other >", "Advanced ⯈", "Begin a Conditional(If Statement) Block ⯈", "Single Condition"
Click the "Text" tab
In the "Variable Name / Token" field, enter "~output"(This is different from the original example; Either will work, but the token is redundant in this case, force of habit)
In the dropdown, select "Has Been Set"
Click "OK"
Click "Other >", "Advanced ⯈", "Write Text to a File"
In the "Text" field, enter "{TXT:~output}"
Click "..."
Browse to the config file you want to change(or the test copy you selected previously)
Click "Open"
Check "Overwrite file if it already exists"
Click "OK"
You should now have this in your action list(file paths may differ):
Set Text [~file] to [C:\VAtest.txt]
Set Text [~find] to 'thirdPerson=True'
Set Text [~replace] to 'thirdPerson=False'
Inline C# Function: Find and replace, wait until execution finishes
Begin Text Compare : [~output] Has Been Set
Write (overwrite), '{TXT:~output}' to file 'C:\VAtest.txt'
End Condition
Click "OK"
Click "Apply" or "Done", then test the command.