$$Include{docs/siteMacros.textCarver}

# Other Commands
TextCarver includes a wide range of built-in commands.


### Variable manipulation
You can use \$\$Clear to erase a variable entirely, or just clear some parts of it:
$$exampleSimple{}
\$\$Clear{person}
\$\$Clear{person.lastName}
\$\$Clear{person.lastName[2]}
$$endExample{}


### Iteration
For more complex operations, you can use \$\$ForEach to iterate over each element of a variable:

$$example{}
\$\$people = {Alex | Blair | Chris}
\$\$ForEach{
|.var person
|.source \$\$people{}
|.do Hello \$\$person{}
}

$$exampleRight{}
Hello Alex
Hello Blair
Hello Chris

$$endExample{}


### File access
Use \$\$Include to include the contents of another file:
$$exampleSimple{}
\$\$Include{content.md}
$$endExample{}

Use \$\$FilesInDirectory to list the contents of a directory:
$$exampleSimple{}
\$\$FilesInDirectory{staffDirectory}
$$endExample{}

Use the \$\$IfFileExists conditional to check for the presence of a file:
$$exampleSimple{}
\$\$IfFileExists{optionalContent.md}
$$endExample{}


### Text manipulation
There are some built-in text manipulation commands. If you’re familiar with JavaScript, you’ll feel right at home with these.

$$example{}
\$\$Split{, | a,b,c}

$$exampleRight{}
a
b
c

$$endExample{}
<br>

$$example{}
\$\$people = {Alex | Blair | Chris}
\$\$Join{, | \$\$people{}}

$$exampleRight{}
Alex,Blair,Chris

$$endExample{}
<br>

$$example{}
\$\$people = {Chris | Blair | Alex}
\$\$Sort{\$\$people{}}

$$exampleRight{}
Alex
Blair
Chris

$$endExample{}
<br>

$$example{}
\$\$people = {Chris | Blair | Alex | Chris}
\$\$SortUnique{\$\$people{}}

$$exampleRight{}
Alex
Blair
Chris

$$endExample{}
<br>

$$example{}
\$\$Replace{sailor | admiral | Hello sailor}

$$exampleRight{}
Hello admiral

$$endExample{}
<br>

$$example{}
\$\$ReplaceRegex{\d{3} | g | secret | The code is 123}

$$exampleRight{}
The code is secret

$$endExample{}



[Next: ATX Headers](3aAtxHeaders.html)
