How to add variable into C# block?

KitKat21

Client
Регистрация
02.05.2017
Сообщения
255
Благодарностей
187
Баллы
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!
 

arhip1985

Client
Регистрация
31.10.2011
Сообщения
2 952
Благодарностей
779
Баллы
113
project.Variables["RNDmatch"].Value
 

KitKat21

Client
Регистрация
02.05.2017
Сообщения
255
Благодарностей
187
Баллы
43
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" ?
 

arhip1985

Client
Регистрация
31.10.2011
Сообщения
2 952
Благодарностей
779
Баллы
113
need - Convert.ToInt32(project.Variables["RNDmatch"].Value)
 
  • Спасибо
Реакции: paydot и KitKat21

KitKat21

Client
Регистрация
02.05.2017
Сообщения
255
Благодарностей
187
Баллы
43
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]
 

ssXXXss

Client
Регистрация
23.12.2014
Сообщения
7 379
Благодарностей
2 039
Баллы
113
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

KitKat21

Client
Регистрация
02.05.2017
Сообщения
255
Благодарностей
187
Баллы
43
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!!!
 

cherubin

Client
Регистрация
06.06.2016
Сообщения
92
Благодарностей
6
Баллы
8
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 ?
 

Phoenix78

Client
Read only
Регистрация
06.11.2018
Сообщения
11 790
Благодарностей
5 683
Баллы
113
p.StartInfo.Arguments = "-l "+ project.Variables["MyVariable"].Value + " TestPDF.pdf"; // -l это спец.ключ для быстрой генерации. Теряем качество
 

cherubin

Client
Регистрация
06.06.2016
Сообщения
92
Благодарностей
6
Баллы
8

Phoenix78

Client
Read only
Регистрация
06.11.2018
Сообщения
11 790
Благодарностей
5 683
Баллы
113

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