ZennoLab

Automate everything

User Tools

Site Tools


Sidebar

Translations of this page:

en:zennoposter:csharp-macros-replacement

Regular macros => C# macros

Text processing

For instance, yourText stores your text.

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
Profile.Age project.Profile.Age
Profile.Login project.Profile.Login
Profile.ZipCode project.Profile.ZipCode

Random values

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
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";
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
Counter.Set var counter = 0;
Counter.Add counter++;
Counter.Multiple counter = counter*2;
Counter.Get return counter;

You can operate with ZennoPoster variables in C# code by such a way:

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

Global variables

You can operate with ZennoPoster global variables in C# code by such a way:

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

Operations with global variables are quite similar to operations with counters.

en/zennoposter/csharp-macros-replacement.txt · Last modified: 2015/07/14 15:51 (external edit)