[PATCH]: Translator doesn't load variables for a macro correctly (1 Viewer)

Clinton

Portal Member
October 2, 2008
27
9
There is a bug in how Translator saves and load variables to and from a file when executing a macro. Although the 'Save Variables' macro command successfully writes variables to a file, the 'Load Variables' command has a bug that means it will not load the variables back.

The bug is in IRSSUtils module VariableList.cs in the Load method:


Code:
      XmlNodeList variableNodes = doc.DocumentElement.SelectNodes([COLOR="Red"]"VariableList"[/COLOR]);

      foreach (XmlNode node in variableNodes)
        SetVariable(node.Name, [COLOR="red"]node.Value[/COLOR]);

Alternative code that works is:

Code:
      XmlNodeList variableNodes = doc.SelectNodes([COLOR="Green"]"/variables/*"[/COLOR]);

      foreach (XmlNode node in variableNodes)
        SetVariable(node.Name, [COLOR="green"]node.InnerText[/COLOR]);

Chemelli, would you please add this in the next build?
 

chemelli

Retired Team Member
  • Premium Supporter
  • September 28, 2006
    6,159
    2,264
    51
    Milano, Italy
    Home Country
    Italy Italy
    There is a bug in how Translator saves and load variables to and from a file when executing a macro. Although the 'Save Variables' macro command successfully writes variables to a file, the 'Load Variables' command has a bug that means it will not load the variables back.

    The bug is in IRSSUtils module VariableList.cs in the Load method:


    Code:
          XmlNodeList variableNodes = doc.DocumentElement.SelectNodes([COLOR="Red"]"VariableList"[/COLOR]);
    
          foreach (XmlNode node in variableNodes)
            SetVariable(node.Name, [COLOR="red"]node.Value[/COLOR]);

    Alternative code that works is:

    Code:
          XmlNodeList variableNodes = doc.SelectNodes([COLOR="Green"]"/variables/*"[/COLOR]);
    
          foreach (XmlNode node in variableNodes)
            SetVariable(node.Name, [COLOR="green"]node.InnerText[/COLOR]);

    Chemelli, would you please add this in the next build?

    Need to check before committing, and I'm pretty busy those days. :sorry:

    Simone
     

    Clinton

    Portal Member
    October 2, 2008
    27
    9
    Chemelli - thanks for the response. I appreciate the time you spend keeping this project going. As a user I like to share solutions to bugs I find, as that helps improve the project. It is a pity if solutions cannot get incorporated.

    To confirm the bug (and verify the solution) you just need a macro that sets a variable, saves variables, clears variables, loads variables and inspects variables.

    Thanks again for your efforts.
     

    chemelli

    Retired Team Member
  • Premium Supporter
  • September 28, 2006
    6,159
    2,264
    51
    Milano, Italy
    Home Country
    Italy Italy
    There is a bug in how Translator saves and load variables to and from a file when executing a macro. Although the 'Save Variables' macro command successfully writes variables to a file, the 'Load Variables' command has a bug that means it will not load the variables back.

    The bug is in IRSSUtils module VariableList.cs in the Load method:


    Code:
          XmlNodeList variableNodes = doc.DocumentElement.SelectNodes([COLOR="Red"]"VariableList"[/COLOR]);
    
          foreach (XmlNode node in variableNodes)
            SetVariable(node.Name, [COLOR="red"]node.Value[/COLOR]);

    Alternative code that works is:

    Code:
          XmlNodeList variableNodes = doc.SelectNodes([COLOR="Green"]"/variables/*"[/COLOR]);
    
          foreach (XmlNode node in variableNodes)
            SetVariable(node.Name, [COLOR="green"]node.InnerText[/COLOR]);

    Chemelli, would you please add this in the next build?

    Need to check before committing, and I'm pretty busy those days. :sorry:

    Simone

    Code checked and confirmed to be working.

    Commited to svn3210.

    :D

    Simone
     

    barnabas1969

    Portal Member
    July 17, 2011
    27
    1
    Home Country
    United States of America United States of America
    It looks like this bug is back in build 4189. Not as if I actually expect to get a response to a forum post though...

    Oh... I should be polite? I forgot about that... just like I forgot to donate. Maybe some support will refresh my memory!
     

    rekenaar

    Retired Team Member
  • Premium Supporter
  • December 17, 2006
    4,421
    805
    Home Country
    South Africa South Africa
    Well, if we have to choose between "polite" or "donation" we will 1st of all choose "polite". That is after all what keeps the devs, giving their free time, going. Spending hours so that we can use the software for free. My respect to them.

    I saw plenty of users raving the past few months about the good support in the MP forums from team members to community members. Unfortunately, IRSS is currently in maintenance mode and that is the reason things are a bit quite here. Your best option is to politely bump your problems every once in a while until one of the others devs have time to take up another challenge.

    Thanks for understanding :)
     

    barnabas1969

    Portal Member
    July 17, 2011
    27
    1
    Home Country
    United States of America United States of America
    I do appreciate the time the developers spend on this software very much. IRSS is actually pretty cool. However, there are a few problems that I would really like to get fixed... and I'm willing to contribute financially. I'm just frustrated that I've received absolutely no response to other posts.
     

    chemelli

    Retired Team Member
  • Premium Supporter
  • September 28, 2006
    6,159
    2,264
    51
    Milano, Italy
    Home Country
    Italy Italy
    ... Not as if I actually expect to get a response to a forum post though...

    Oh... I should be polite? I forgot about that... just like I forgot to donate. Maybe some support will refresh my memory!

    Seems previous issue was not only confirmed but also fixed with a community patch. I don't see any other post after mine saying something is not working...only this, quite unpolite.

    I totally agree with our Rekenaar, first politeness then maybe money.

    Simone
     

    barnabas1969

    Portal Member
    July 17, 2011
    27
    1
    Home Country
    United States of America United States of America
    I'm sorry for my rudeness.

    Now that I have your attention, I would appreciate your help. I've pasted my macro and the resulting VariableList file below. If the patch has been applied to version 1.4.2.4189, then I don't understand what's wrong.

    Here's my macro:
    Code:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <macro>
      <item command="Load Variables: C:\Users\HTPC\Documents\mute" />
      <item command="If: var_MUTE|==|1|SET_MUTE_OFF|SET_MUTE_ON" />
      <item command="Label: SET_MUTE_ON" />
      <item command="Macro: Receiver_Mute_ON" />
      <item command="Set Variable: var_MUTE|1" />
      <item command="Goto Label: FINISH" />
      <item command="Label: SET_MUTE_OFF" />
      <item command="Macro: Receiver_Mute_OFF" />
      <item command="Set Variable: var_MUTE|0" />
      <item command="Goto Label: FINISH" />
      <item command="Label: FINISH" />
      <item command="Save Variables: C:\Users\HTPC\Documents\mute" />
    </macro>

    Here's the VariableList file:
    Code:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <variables>
    	<MUTE>[COLOR="Red"]System.Byte[][/COLOR]</MUTE>
    </variables>
     

    barnabas1969

    Portal Member
    July 17, 2011
    27
    1
    Home Country
    United States of America United States of America
    Please see my post in this thread. I am sincere in what I wrote. I would like to learn and contribute.

    I truly believe that immersion in a new language (be it a spoken language or a computer language) is the best way to learn. I would love to learn how to use new tools (SourceForge, SVN's, C#, etc). I need help from someone with experience to guide me. I would appreciate enough information so that I can find the information and learn something.

    Thanks,
    Brian
     

    Users who are viewing this thread

    Top Bottom