How to add variable into C# block?

KitKat21

Client
Регистрация
02.05.2017
Сообщения
268
Реакции
192
Баллы
43
Hi guys!

I hope someone can help. How can I add a variable into a C# block?

I need to add a variable into the code below:

Tab tab = instance.ActiveTab;
// Action designer, type Set
HtmlElement he = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("section", "fulltagname", "section", "text", {-Variable.RNDmatch-});
if (he.IsVoid) return -1;
tab.FullEmulationMouseMoveAboveHtmlElement(he, 300);


Thanks!
 
project.Variables["RNDmatch"].Value

Thank you!

I've tried this method but it never worked for me. :( I must be doing something small wrong.

Here's my error log:

Compile code of Error in action "CS1503" "Argument 5: cannot convert from 'string' to 'int'". [Row: 3; Column: 131]


Here's the code:


Tab tab = instance.ActiveTab;
// Action designer, type Set
HtmlElement he = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("section", "fulltagname", "section", "text", project.Variables["RNDmatch"].Value);
if (he.IsVoid) return -1;
tab.FullEmulationMouseMoveAboveHtmlElement(he, 300);


Did I do something wrong? Do I need to put " symbol around the "project.Variables["RNDmatch"].Value" ?
 
need - Convert.ToInt32(project.Variables["RNDmatch"].Value)

Thanks for your help!

Like this?

Convert.ToInt32(project.Variables["RNDmatch"].Value)
Tab tab = instance.ActiveTab;
// Action designer, type Set
HtmlElement he = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("section", "fulltagname", "section", "text", project.Variables["RNDmatch"].Value);
if (he.IsVoid) return -1;
tab.FullEmulationMouseMoveAboveHtmlElement(he, 300);


I'm still getting fail error. :( Error message:

Compile code of Error in action "CS1002" "; expected". [Row: 1; Column: 53]
 
Tab tab = instance.ActiveTab;
// Action designer, type Set
HtmlElement he = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("section", "fulltagname", "section", "text", int.Parse(project.Variables["RNDmatch"].Value));
if (he.IsVoid) return -1;
tab.FullEmulationMouseMoveAboveHtmlElement(he, 300);
 
  • Спасибо
Реакции: VladZen и KitKat21
Tab tab = instance.ActiveTab;
// Action designer, type Set
HtmlElement he = instance.ActiveTab.GetDocumentByAddress("0").FindElementByAttribute("section", "fulltagname", "section", "text", int.Parse(project.Variables["RNDmatch"].Value));
if (he.IsVoid) return -1;
tab.FullEmulationMouseMoveAboveHtmlElement(he, 300);

Yay, it works!! Awesome!! :D :) Thank you so much!!!
 
Hello,

I have similar issue with variables in C# code.

C#:
Развернуть Свернуть Копировать
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName =@"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"; // Путь к программе
p.StartInfo.Arguments = "-l project.Variables["MyVariable"].Value TestPDF.pdf"; // -l это спец.ключ для быстрой генерации. Теряем качество
p.Start();
p.WaitForExit(99999);

Compiling code of Error in action "CS1002" "; expected". [Row: 6; Column: 48]
Compiling code of Error in action "CS1002" "; expected". [Row: 6; Column: 68]

What do i need to do ?
 
p.StartInfo.Arguments = "-l "+ project.Variables["MyVariable"].Value + " TestPDF.pdf"; // -l это спец.ключ для быстрой генерации. Теряем качество
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)