<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Eval macro with string argument in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37851#M8556</link>
    <description>&lt;P&gt;Define your macro as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if("$arg1$"=="test","true","false") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The quotes around $arg1$ are necessary. Then the value placed into the macro content by string substitution again gets treated as a string rather than as a reference to a field.&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2013 11:51:13 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2013-05-17T11:51:13Z</dc:date>
    <item>
      <title>Eval macro with string argument</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37849#M8554</link>
      <description>&lt;P&gt;I'm trying to define a Splunk eval based macro that takes a string as a parameter (where the string must be able to contain spaces), tests the value of the string, and then returns a value based on the outcome of that test.  But I can't get it to work.  Taking as a simplified example...&lt;/P&gt;

&lt;P&gt;Macro definition: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if ($arg1$=="Test String", "true", "false")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Macro invocation:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`name("Test String")`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The macro always evaluates to false.  I've tried every combination of single and double quotes that I can think of in both the macro definition and invocation, but I can't seem to get this to work.  Am I missing something?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 10:48:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37849#M8554</guid>
      <dc:creator>MatMeredith</dc:creator>
      <dc:date>2013-05-17T10:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Eval macro with string argument</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37850#M8555</link>
      <description>&lt;P&gt;Hello Mat,&lt;BR /&gt;
please write the macro definiton as:&lt;/P&gt;

&lt;P&gt;" if ($arg1$=="Test String", "true", "false")&lt;/P&gt;

&lt;P&gt;and call the eval statement as "eval a=`macro_name((Backslash)\"Test String(Backslash)\")" as double quote will give you error&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 11:40:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37850#M8555</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2013-05-17T11:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Eval macro with string argument</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37851#M8556</link>
      <description>&lt;P&gt;Define your macro as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if("$arg1$"=="test","true","false") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The quotes around $arg1$ are necessary. Then the value placed into the macro content by string substitution again gets treated as a string rather than as a reference to a field.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 11:51:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37851#M8556</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-05-17T11:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Eval macro with string argument</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37852#M8557</link>
      <description>&lt;P&gt;Hello Martin,&lt;BR /&gt;
both the scenario works for me, just had to tweak the passing of arguments.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2013 12:05:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37852#M8557</guid>
      <dc:creator>linu1988</dc:creator>
      <dc:date>2013-05-17T12:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Eval macro with string argument</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37853#M8558</link>
      <description>&lt;P&gt;Perfect -- thank you Martin.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2013 08:52:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-macro-with-string-argument/m-p/37853#M8558</guid>
      <dc:creator>MatMeredith</dc:creator>
      <dc:date>2013-05-20T08:52:13Z</dc:date>
    </item>
  </channel>
</rss>

