/
Обычные макросы => C# макросы

Обычные макросы => C# макросы

This page has been translated automatically

We want to provide you with the latest help content in your language as soon as possible. This page has been translated automatically and may contain grammatical errors or inaccuracies. We want this content to be useful to you. Please let us know at the bottom of this page if this information was helpful.

View the original article in Russian: Обычные макросы => C# макросы

Work with text

Let's say the yourText variable stores your text.

Regular macro

C # macro

Regular macro

C # macro

String.SubString

yourText.Substring(…)

var yourText = "For the second time in three years..."; return yourText.Substring(3,10);

String.Replace

yourText.Replace(…)

var yourText = "For the second time in three years..."; return yourText.Replace("For","*");

String.Insert

yourText.Insert(…)

var yourText = "For the second time in three years..."; return yourText.Insert(0, "Hi there.");

String.ToUpper

yourText.ToUpper()

String.ToLower

yourText.ToLower()

String.Split

Macros.TextProcessing.Split(…)

var yourText = "email:password"; return Macros.TextProcessing.Split(yourText,":","0").First();

String.SplitCount

yourText.Split(…).Length

var yourText = "email:password"; return Macros.TextProcessing.Split(yourText,":","all").Count();

String.RemoveDuplicates

Macros.TextProcessing.RemoveDuplicates(…)

var yourText = "email:password:email"; return Macros.TextProcessing.RemoveDuplicates(yourText,":");

String.Enter

System.Environment.NewLine

var yourText = "email"+System.Environment.NewLine +"password"; return yourText;

String.Spintax

Macros.TextProcessing.Spintax(…)

var yourText = "{Hi|Hey}"; return Macros.TextProcessing.Spintax(yourText);

Profile and personal data

Regular macro

C # macro

Regular macro

C # macro

Profile.Age

project.Profile.Age

Profile.Login

project.Profile.Login

Profile.ZipCode

project.Profile.ZipCode

Random variables

Regular macro

C # macro

Regular macro

C # macro

Random.Int

Random.Next(…)

var r = new Random(); return r.Next(1,100);

Random.Double

Random.NextDouble()

var r = new Random(); return r.NextDouble();

Files and directories

Regular macro

C # macro

Regular macro

C # macro

File.GetString

Macros.FileSystem.FileGetLine()

var path = @"D:\file.txt"; return Macros.FileSystem.FileGetLine(path,"2",false);

File.GetBlock

Macros.FileSystem.FileGetBlock()

var path = @"D:\file.txt"; return Macros.FileSystem.FileGetBlock(path,System.Environment.NewLine,"all",false);

File.AppendString

Macros.FileSystem.FileAppendString()

var path = @"D:\file.txt"; return Macros.FileSystem.FileAppendString(path,"new line", true);

File.CountOfStrings

Macros.FileSystem.FileCountOfLines()

var path = @"D:\file.txt"; return Macros.FileSystem.FileCountOfLines(path);

File.Copy

Macros.FileSystem.FileCopy()

var path = @"D:\file.txt"; Macros.FileSystem.FileCopy(path,"D:\newfile.txt");

Directory.CountOfFiles

Macros.FileSystem.DirectoryCountOfFiles()

var path = @"D:\"; return Macros.FileSystem.DirectoryCountOfFiles(path);

Directory.RandomFile

Macros.FileSystem.DirectoryRandomFile()

var path = @"D:\"; return Macros.FileSystem.DirectoryRandomFile(path);

Directory.DeleteFileByMask

Macros.FileSystem.DirectoryDeleteFileByMask()

var path = @"D:\"; Macros.FileSystem.DirectoryDeleteFileByMask(path,"*.txt");

Directory.DeleteFile

Macros.FileSystem.DirectoryDeleteFile()

var path = @"D:\file.txt"; Macros.FileSystem.DirectoryDeleteFile(path);

Directory.SelfFile

Macros.FileSystem.DirectoryDeleteDirectory()

var path = @"D:\"; Macros.FileSystem.DirectoryDeleteDirectory(path,true,true);

Regular expressions

string regex = project.Variables["myRegEx"].Value; string text = project.Variables["textToParse"].Value; var reg = new System.Text.RegularExpressions.Regex(regex, System.Text.RegularExpressions.RegexOptions.None); return reg.Matches(text)[0];

Counters

Regular macro

C # macro

Regular macro

C # macro

Counter.Set

var counter = 0;

Counter.Add

counter++;

Counter.Multiple

counter = counter*2;

Counter.Get

return counter;

In order to work with project variables in the code, you must use the following construction:

var tmp = project.Variables["variable"].Value; var counter = System.Convert.ToInt32(tmp);

Global Variables

To work with global variables in the code, its value is taken using the following construction:

var tmp = project.GlobalVariables["license@email.com","globVar"].Value; var counter = System.Convert.ToInt32(tmp);

Operations with global variables are similar to operations with counters.

Related content