Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
8 replies Latest Post - ‏2013-01-25T16:36:26Z by george.baker
Naveesh
Naveesh
16 Posts
ACCEPTED ANSWER

Pinned topic Important: Can we compare two macro variable in hats macro

‏2012-08-25T16:14:33Z |
Hi,

Can we compare two macro variable in a macro?

Thanks,

Regards,
-NAVEESH
Updated on 2013-01-25T16:36:26Z at 2013-01-25T16:36:26Z by george.baker
  • tmparker
    tmparker
    518 Posts
    ACCEPTED ANSWER

    Re: Important: Can we compare two macro variable in hats macro

    ‏2012-08-27T16:40:26Z  in response to Naveesh
    I just wrote a quick test macro to compare a string I extracted from the host screen to a string I prompted the user to enter. I used the conditional screen descriptor to compare. I had 2 screens created, one where they were equal and one where they were not equal. In the equal screen I print the word "true" in a field and for the not equal screen I print the word "false" in a field. Worked just fine in both cases.

    Here is the code for the macro if you want to try this yourself:
    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?><macro> <associatedConnections default=
    "main"> <connection name=
    "main"/> </associatedConnections> <extracts> <extract handler=
    "default.jsp" index=
    "0" indexed=
    "false" name=
    "extractStr1" overwrite=
    "true" planetype=
    "TEXT_PLANE" save=
    "false" separator=
    "" showHandler=
    "false" updateVariableImmediately=
    "false" variableName=
    ""/> </extracts> <prompts> <prompt handler=
    "default.jsp" name=
    "promptStr2" separator=
    "" source=
    "handler" value=
    "" variableIndex=
    "0" variableIndexed=
    "false" variableName=
    "" welApplID=
    "" welIsPassword=
    "false"/> </prompts> <HAScript author=
    "" blockinput=
    "false" creationdate=
    "" delayifnotenhancedtn=
    "0" description=
    "" ignorepauseforenhancedtn=
    "true" ignorepausetimeforenhancedtn=
    "true" name=
    "TestStringCompare" pausetime=
    "100" promptall=
    "true" supressclearevents=
    "false" timeout=
    "60000" usevars=
    "true">   <vars> <create name=
    "$str1$" type=
    "string" value=
    ""/> <create name=
    "$str2$" type=
    "string" value=
    ""/> </vars>     <screen entryscreen=
    "true" exitscreen=
    "false" name=
    "Screen1" transient=
    "false"> <comment> !visualinfo:x=141;showActions=1;lastPropertiesPage=com.ibm.hats.vme.properties.ScreenRecoPropertiesPage;associatedScreenName=TestStringCompare\Screen1.hsc;y=27;! </comment> <description uselogic=
    "1 and 2"> <oia invertmatch=
    "false" optional=
    "false" status=
    "NOTINHIBITED"/> <block casesense=
    "false" col=
    "48" invertmatch=
    "false" optional=
    "false" row=
    "2"> <string value=
    "'System  . . .'"/> <string value=
    "'Subsystem . .'"/> <string value=
    "'Display . . .'"/> </block> </description> <actions> <extract assigntovar=
    "$str1$" continuous=
    "false" ecol=
    "20" erow=
    "6" name=
    "'extractStr1'" planetype=
    "TEXT_PLANE" scol=
    "17" srow=
    "6" unwrap=
    "false"/> <input col=
    "0" encrypted=
    "false" movecursor=
    "true" row=
    "0" value=
    "'[enter]'" xlatehostkeys=
    "true"/> </actions> <nextscreens timeout=
    "0"> <nextscreen name=
    "Screen2"/> </nextscreens> </screen>   <screen entryscreen=
    "false" exitscreen=
    "false" name=
    "Screen2" transient=
    "false"> <comment> !visualinfo:x=141;showActions=1;lastPropertiesPage=com.ibm.hats.vme.properties.ScreenRecoPropertiesPage;associatedScreenName=TestStringCompare\Screen2.hsc;y=147;! </comment> <description uselogic=
    "1 and 2"> <oia invertmatch=
    "false" optional=
    "false" status=
    "NOTINHIBITED"/> <string casesense=
    "false" col=
    "31" invertmatch=
    "false" optional=
    "false" row=
    "1" value=
    "'Sign-on Information'" wrap=
    "false"/> </description> <actions> <prompt assigntovar=
    "$str2$" clearfield=
    "false" col=
    "1" default=
    "" description=
    "" encrypted=
    "false" len=
    "80" movecursor=
    "false" name=
    "'promptStr2'" required=
    "false" row=
    "1" title=
    "" varupdateonly=
    "false" xlatehostkeys=
    "true"/> <input col=
    "0" encrypted=
    "false" movecursor=
    "true" row=
    "0" value=
    "'[enter]'" xlatehostkeys=
    "true"/> </actions> <nextscreens timeout=
    "0"> <nextscreen name=
    "Screen3"/> <nextscreen name=
    "Screen4"/> </nextscreens> </screen>   <screen entryscreen=
    "false" exitscreen=
    "true" name=
    "Screen3" transient=
    "false"> <comment> !visualinfo:x=27;showActions=1;lastPropertiesPage=com.ibm.hats.vme.properties.ScreenRecoPropertiesPage;associatedScreenName=TestStringCompare\Screen3.hsc;y=267;! </comment> <description uselogic=
    "1 and 2"> <oia invertmatch=
    "false" optional=
    "false" status=
    "NOTINHIBITED"/> <condition invertmatch=
    "false" optional=
    "false" value=
    "$str1$ == $str2$"/> </description> <actions> <input col=
    "0" encrypted=
    "false" movecursor=
    "true" row=
    "0" value=
    "'true'" xlatehostkeys=
    "true"/> </actions> <nextscreens timeout=
    "0"> </nextscreens> </screen>   <screen entryscreen=
    "false" exitscreen=
    "true" name=
    "Screen4" transient=
    "false"> <comment> !visualinfo:x=256;showActions=1;lastPropertiesPage=com.ibm.hats.vme.properties.ScreenRecoPropertiesPage;associatedScreenName=TestStringCompare\Screen3.hsc;y=267;! </comment> <description uselogic=
    "1 and 2"> <oia invertmatch=
    "false" optional=
    "false" status=
    "NOTINHIBITED"/> <condition invertmatch=
    "false" optional=
    "false" value=
    "$str1$ != $str2$"/> </description> <actions> <input col=
    "0" encrypted=
    "false" movecursor=
    "true" row=
    "0" value=
    "'false'" xlatehostkeys=
    "true"/> </actions> <nextscreens timeout=
    "0"> </nextscreens> </screen>   </HAScript> </macro>
    
  • Naveesh
    Naveesh
    16 Posts
    ACCEPTED ANSWER

    Re: Important: Can we compare two macro variable in hats macro

    ‏2012-08-28T02:39:44Z  in response to Naveesh
    Thanks much Tim for your assistance.

    Regards,
    -NAVEESH
  • george.baker
    george.baker
    314 Posts
    ACCEPTED ANSWER

    Re: Important: Can we compare two macro variable in hats macro

    ‏2013-01-24T20:36:10Z  in response to Naveesh
    The InfoCenter states that in a <condition> statement you can evaluate a conditional expression as you did $str1$ != $str2$. I need to evaluate integer values, like looping, in the conditional statement and I need to use either less than (<) or greater than (>), but the macro editor is flagging this as invalid, sayingg the < and the > are not valid.

    How can I code such a statement. Here is an example of what I need:
    
    <condition invertmatch=
    "false" optional=
    "false" value=
    "$index$ <= 40"/>
    


    Where $index$ is defined as an integer.
    • tmparker
      tmparker
      518 Posts
      ACCEPTED ANSWER

      Re: Important: Can we compare two macro variable in hats macro

      ‏2013-01-24T21:33:01Z  in response to george.baker
      Hi George,

      I'm not sure how you are doing this but there are 2 places this can be used, in a macro screen descriptor or in the macro action. For a macro, I simply went into the VME and added a conditional statement. I then did a compare of a value I called int1 to see if it is greater than 40. Got no errors in the editor. The code showed up as this:
      
      <
      
      if condition=
      "$int1$ &gt; 40"> <input col=
      "0" encrypted=
      "false" movecursor=
      "true" row=
      "0" value=
      "'greater than[enter]'" xlatehostkeys=
      "true"/> </if>
      


      For a macro screen descriptor, I went into the advanced editor and added a conditional statement doing the same comparison as above. Got no errors in the editor and the code looked like this:
      
      <condition invertmatch=
      "false" optional=
      "false" value=
      "$int1$ &gt; 40"/>
      


      I can tell you that the comparison symbols you use will get converted to the entity reference values used in HTML by the editor. Not sure how you managed to get the actual symbols in your condition statement unless you manually did that in the source.

      Thanks
      Tim
  • george.baker
    george.baker
    314 Posts
    ACCEPTED ANSWER

    Re: Important: Can we compare two macro variable in hats macro

    ‏2013-01-25T15:47:41Z  in response to Naveesh
    Thanks Tim.

    The InfoCenter documentation needs to make a bigger deal of the fact that in macros you should use the following mappings:
    < typed as &lt;
    > typed as >
    & typed as &
    Please consider this a request for the next update of the HATS and the InfoCenter.

    General comment: If you are writing Advanced Macros the Advanced Macro Editor does a better job of validating and properly generating statements than does the VME. Please take the request to update the VME to allow entering of the <condition> in the GUI. In general the VME should have all the capabilities of the Advanced Macro Editor.
  • george.baker
    george.baker
    314 Posts
    ACCEPTED ANSWER

    Re: Important: Can we compare two macro variable in hats macro

    ‏2013-01-25T15:51:55Z  in response to Naveesh
    The symbols do not render correctly on this page. How did you code the post so that the codes for <, > and & displayed as the correct character strings?
    • tmparker
      tmparker
      518 Posts
      ACCEPTED ANSWER

      Re: Important: Can we compare two macro variable in hats macro

      ‏2013-01-25T16:24:26Z  in response to george.baker
      You have to use a "{code}" block in order to show it in the forum.
  • george.baker
    george.baker
    314 Posts
    ACCEPTED ANSWER

    Re: Important: Can we compare two macro variable in hats macro

    ‏2013-01-25T16:36:26Z  in response to Naveesh
    I tried it and looked at the preview mode and it did not render properly. The > symbol was improperly rendered.
    
    < typed as &lt; > typed as > & typed as &amp;