<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">

<html>

<!--(==============================================================)-->
<!--(Document created with RoboEditor. )============================-->
<!--(==============================================================)-->

<head>

<title>attrwithval</title>

<!--(Meta)==========================================================-->

<meta http-equiv=content-type content="text/html; charset=windows-1252">
<meta name=date content="01 4, 2002 1:03:13 PM">
<meta name=generator content="RoboHELP by eHelp Corporation - www.ehelp.com">
<meta name=generator-major-version content=0.1>
<meta name=generator-minor-version content=1>
<meta name=filetype content=kadov>
<meta name=filetype-version content=1>
<meta name=page-count content=1>
<meta name=layout-height content=1129>
<meta name=layout-width content=1024>


<!--(Links)=========================================================-->

<link REL="StyleSheet" HREF="default.css">



</head>

<!--(Body)==========================================================-->


<body>

<h1>attrwithval</h1>

<h2>Purpose</h2>

<p>Check <span style="font-style: italic;">concept</span> to see if it 
 has attribute <span style="font-style: italic;">attrStr</span> with value 
 <span style="font-style: italic;">valStr</span>.</p>

<h2>Syntax</h2>

<p style="line-height: normal;
			margin-bottom: 14pt;
			margin-top: 14pt;
			x-text-tab-stops: repeat 1in;
			white-space: nowrap;
			font-family: monospace;
			font-size: 10pt;">returnedBoolean = attrwithval(concept, attrStr, valStr)</p>

<p style="margin-left: 40px;
			line-height: normal;
			margin-bottom: 14pt;
			margin-top: 14pt;
			x-text-tab-stops: repeat 1in;
			white-space: nowrap;
			font-family: monospace;
			font-size: 10pt;">returnedBoolean - type: bool (1 or 0)<br>
concept - type: con<br>
attrStr - type: str<br>
valStr - type: str</p>

<h2>Returns</h2>

<p>1 if the concept has the attribute-value pair, 0 otherwise. Passed a 
 bad concept, the function writes an error to the output log.</p>

<h2>Remarks</h2>

<p>If an attribute has multiple values, returns true if one of the values 
 matches <span style="font-style: italic;">valStr</span>. <!--kadov_tag{{<spaces>}}-->&nbsp;<!--kadov_tag{{</spaces>}}-->Limited 
 to string-valued attributes.</p>

<h2>Example</h2>

<p style="line-height: normal;
			margin-bottom: 14pt;
			margin-top: 14pt;
			x-text-tab-stops: repeat 1in;
			white-space: nowrap;
			font-family: monospace;
			font-size: 10pt;"># if you find apples in the concept hierarchy<br>
if (findconcept(findroot(),&quot;apple&quot;)) <br>
# kill them (to start fresh) <br>
rmconcept(findconcept(findroot(),&quot;apple&quot;));<br>
# Create the apple concept<br>
G(&quot;apple&quot;) = makeconcept(findroot(),&quot;apple&quot;);<br>
# Apple's color's red<br>
addstrval(G(&quot;apple&quot;),&quot;color&quot;,&quot;red&quot;);<br>
# MacIntosh apples are also red<br>
addstrval(makeconcept(G(&quot;apple&quot;),&quot;MacIntosh&quot;),&quot;color&quot;,&quot;red&quot;);<br>
# Print out apple's attribute and value<br>
if(attrname(findattrs(G(&quot;apple&quot;)))){ <br>
&quot;output.txt&quot; &lt;&lt; &quot;1) apples &quot; &lt;&lt; attrname(findattrs(G(&quot;apple&quot;))); <br>
&quot;output.txt&quot; &lt;&lt; &quot; &quot; <br>
&lt;&lt; getstrval(attrvals(findattrs(G(&quot;apple&quot;)))) &lt;&lt; &quot;\n&quot;;<br>
}<br>
# Test for a given attribute and value<br>
&quot;output.txt&quot; &lt;&lt; &quot;2) are apples red? &quot; &lt;&lt; <span style="font-weight: bold; x-text-underline: normal; /*begin!kadov{{*/ text-decoration: underline; /*}}end!kadov*/ "><br>
attrwithval</span>(G(&quot;apple&quot;), &quot;color&quot;, &quot;red&quot;) &lt;&lt; &quot;\n&quot;;<br>
&quot;output.txt&quot; &lt;&lt; &quot;3) are apples blue? &quot; &lt;&lt;<span style="font-weight: bold; x-text-underline: normal; /*begin!kadov{{*/ text-decoration: underline; /*}}end!kadov*/ "><br>
attrwithval</span>(G(&quot;apple&quot;), &quot;color&quot;, &quot;blue&quot;) &lt;&lt; &quot;\n&quot;;<br>
# Change a value of a given attribute to another value.<br>
attrchange(findroot(), &quot;color&quot;, &quot;red&quot;, &quot;blue&quot;);<br>
&quot;output.txt&quot; &lt;&lt; &quot;4) are apples blue now? &quot; &lt;&lt;<span style="font-weight: bold; x-text-underline: normal; /*begin!kadov{{*/ text-decoration: underline; /*}}end!kadov*/ "><br>
attrwithval</span>(G(&quot;apple&quot;), &quot;color&quot;, &quot;blue&quot;) &lt;&lt; &quot;\n&quot;;</p>

<p>The code above writes the following to output.txt:</p>

<p style="line-height: normal;
			margin-bottom: 14pt;
			margin-top: 14pt;
			x-text-tab-stops: repeat 1in;
			white-space: nowrap;
			font-family: monospace;
			font-size: 10pt;">1) apples color red<br>
2) are apples red? 1<br>
3) are apples blue? 0<br>
4) are apples blue now? 1</p>

<h2>See Also</h2>

<p><a href="attrexists.htm">attrexists</a>, <a href="attrvals.htm">attrvals</a>, 
 <!--kadov_tag{{<spaces>}}-->&nbsp;<a href="Table_of_Knowledge_Base_Functions.htm"><!--kadov_tag{{</spaces>}}-->Knowledge 
 Base Functions</a></p>

<p style="margin-bottom: 0;">&nbsp; </p>

</body>

</html>
