How to add variable into C# block?

Discussion in 'Questions' started by KitKat21, Feb 14, 2018.

  1. KitKat21

    KitKat21 Client

    Joined:
    May 2, 2017
    Messages:
    55
    Likes Received:
    9
    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!
     
  2. arhip1985

    arhip1985 Client

    Joined:
    Oct 31, 2011
    Messages:
    2,227
    Likes Received:
    448
    project.Variables["RNDmatch"].Value
     
  3. KitKat21

    KitKat21 Client

    Joined:
    May 2, 2017
    Messages:
    55
    Likes Received:
    9
    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" ?
     
  4. arhip1985

    arhip1985 Client

    Joined:
    Oct 31, 2011
    Messages:
    2,227
    Likes Received:
    448
    need - Convert.ToInt32(project.Variables["RNDmatch"].Value)
     
    KitKat21 likes this.
  5. KitKat21

    KitKat21 Client

    Joined:
    May 2, 2017
    Messages:
    55
    Likes Received:
    9
    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]
     
  6. ssXXXss

    ssXXXss Client

    Joined:
    Dec 23, 2014
    Messages:
    5,020
    Likes Received:
    1,302
    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 and KitKat21 like this.
  7. KitKat21

    KitKat21 Client

    Joined:
    May 2, 2017
    Messages:
    55
    Likes Received:
    9
    Yay, it works!! Awesome!! :D :-) Thank you so much!!!
     

Пользователи просматривающие тему (Пользователей: 0, Гостей: 0)