<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.visual-prolog.com/index.php?action=history&amp;feed=atom&amp;title=COM_Memory_Handling_in_Visual_Prolog</id>
	<title>COM Memory Handling in Visual Prolog - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.visual-prolog.com/index.php?action=history&amp;feed=atom&amp;title=COM_Memory_Handling_in_Visual_Prolog"/>
	<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;action=history"/>
	<updated>2026-05-01T21:13:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;diff=4226&amp;oldid=prev</id>
		<title>Thomas Linder Puls: category</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;diff=4226&amp;oldid=prev"/>
		<updated>2016-03-04T09:46:46Z</updated>

		<summary type="html">&lt;p&gt;category&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:46, 4 March 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l167&quot;&gt;Line 167:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 167:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Tutorials]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Memory Handling]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Memory Handling]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;diff=894&amp;oldid=prev</id>
		<title>Thomas Linder Puls: categorized</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;diff=894&amp;oldid=prev"/>
		<updated>2008-01-19T21:47:58Z</updated>

		<summary type="html">&lt;p&gt;categorized&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:47, 19 January 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l168&quot;&gt;Line 168:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 168:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Tutorials]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Memory Handling]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;diff=448&amp;oldid=prev</id>
		<title>Kari Rastas at 09:17, 3 October 2007</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;diff=448&amp;oldid=prev"/>
		<updated>2007-10-03T09:17:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:17, 3 October 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Component Object Model (COM) implies usage of COM memory. When we use an external COM component or create our own COM component, we should handle parameters correctly.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[wikipedia:Component_object_model|&lt;/ins&gt;Component Object Model&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] &lt;/ins&gt;(COM) implies usage of COM memory. When we use an external COM component or create our own COM component, we should handle parameters correctly.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The IDE generates necessary memory conversions, allocations and releasing on creating of COM package using component&amp;#039;s type library. So normally, you do not have to consider the memory handling. However, sometimes some code is written manually, and then the rules must be known.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The IDE generates necessary memory conversions, allocations and releasing on creating of COM package using component&amp;#039;s type library. So normally, you do not have to consider the memory handling. However, sometimes some code is written manually, and then the rules must be known.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l21&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Call a COM Predicate. Handle Returned Memory==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Call a COM Predicate. Handle Returned Memory==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;When we use an external COM component, we can call a predicate, which returns COM memory to us. Usually we want to use the returned information for some time; hence we should copy the returned memory and free the COM memory then. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;Once the data is copied to Prolog memory it is controlled by the garbage collector.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;When we use an external COM component, we can call a predicate, which returns COM memory to us. Usually we want to use the returned information for some time; hence we should copy the returned memory and free the COM memory then. Once the data is copied to Prolog memory it is controlled by the garbage collector.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In the example below, the returned parameter has string type.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In the example below, the returned parameter has string type.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kari Rastas</name></author>
	</entry>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;diff=224&amp;oldid=prev</id>
		<title>Thomas Linder Puls: Move from WEB</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=COM_Memory_Handling_in_Visual_Prolog&amp;diff=224&amp;oldid=prev"/>
		<updated>2007-08-26T21:25:34Z</updated>

		<summary type="html">&lt;p&gt;Move from WEB&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The Component Object Model (COM) implies usage of COM memory. When we use an external COM component or create our own COM component, we should handle parameters correctly.&lt;br /&gt;
&lt;br /&gt;
The IDE generates necessary memory conversions, allocations and releasing on creating of COM package using component&amp;#039;s type library. So normally, you do not have to consider the memory handling. However, sometimes some code is written manually, and then the rules must be known.&lt;br /&gt;
&lt;br /&gt;
The possible situations are:&lt;br /&gt;
&lt;br /&gt;
*Call a COM predicate, which returns a parameter in COM memory;&lt;br /&gt;
&lt;br /&gt;
*Call a COM predicate with input parameter;&lt;br /&gt;
&lt;br /&gt;
*Call a COM predicate with input mutable parameter;&lt;br /&gt;
&lt;br /&gt;
*Implement a COM predicate, which gives us a parameter in COM memory;&lt;br /&gt;
&lt;br /&gt;
*Implement a COM predicate, which returns a parameter in COM memory;&lt;br /&gt;
&lt;br /&gt;
*Implement a COM Predicate. In/Out Parameter;&lt;br /&gt;
&lt;br /&gt;
Please notice that integral parameters do not need special memory handling, but strings and structure domains require such memory handling.&lt;br /&gt;
&lt;br /&gt;
==Call a COM Predicate. Handle Returned Memory==&lt;br /&gt;
&lt;br /&gt;
When we use an external COM component, we can call a predicate, which returns COM memory to us. Usually we want to use the returned information for some time; hence we should copy the returned memory and free the COM memory then.  Once the data is copied to Prolog memory it is controlled by the garbage collector.&lt;br /&gt;
&lt;br /&gt;
In the example below, the returned parameter has string type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;clauses&lt;br /&gt;
    p() = Parameter:-&lt;br /&gt;
        HResult = someComPredicate(ComParameter),&lt;br /&gt;
        HResult = s_ok,&lt;br /&gt;
        !,&lt;br /&gt;
        Parameter= string::createCopy(ComParameter),&lt;br /&gt;
        comMemory::taskMemFree(ComParameter).&lt;br /&gt;
    p() = &amp;quot;&amp;quot;.&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Call a COM Predicate. Fill Input Parameter==&lt;br /&gt;
&lt;br /&gt;
When we use an external COM component, we can call a predicate, which requires our information. We can use any memory for such input parameters. If we use COM memory, then we should free it after the predicate invocation.&lt;br /&gt;
&lt;br /&gt;
In the example below the parameter has myDom type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;domains&lt;br /&gt;
    myDom = myDom(integer X, string S).&lt;br /&gt;
clauses&lt;br /&gt;
    q(myDom(X, S)) :-&lt;br /&gt;
        HResult = someComPredicate(myDom(X, S)),&lt;br /&gt;
        check(HResult).&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IDE uses COM memory for input parameters when generating COM code. The IDE also generates the code to release the COM memory.&lt;br /&gt;
&lt;br /&gt;
==Call a COM Predicate. Fill Mutable Parameter==&lt;br /&gt;
&lt;br /&gt;
When we use an external COM component, we can call a predicate, which requires our information and which changes it. We should use COM memory for such parameters. After the call we should free the result COM memory.&lt;br /&gt;
&lt;br /&gt;
In the example below, the parameter has myDom type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;domains&lt;br /&gt;
    myDom = myDom(integer X, string S).&lt;br /&gt;
clauses&lt;br /&gt;
    q(myDom(X, S)) = myDom(NewX, NewS):-&lt;br /&gt;
        ComParameterPtr= comMemory::taskMemAlloc(sizeofdomain(myDom)),&lt;br /&gt;
        ComS= comMemory::allocString(S),&lt;br /&gt;
        memory::copy(ComParameterPtr,&lt;br /&gt;
            uncheckedConvert(pointer,myDom(X, ComS)),&lt;br /&gt;
            sizeofdomain(myDom)),&lt;br /&gt;
        ComParameter= uncheckedConvert(myDom, ComParameterPtr)&lt;br /&gt;
        HResult = someComPredicate(ComParameter),&lt;br /&gt;
        ComParameter= myDom(NewX, NewComS),&lt;br /&gt;
        NewS= string::createCopy(NewComS),&lt;br /&gt;
        comMemory::taskMemFree(NewComS),&lt;br /&gt;
        comMemory::taskMemFree(ComParameter),&lt;br /&gt;
        check(HResult).&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please notice that inner fields can be changed, so it is necessary to find new values and release them.&lt;br /&gt;
&lt;br /&gt;
==Implement a COM Predicate. Handle Input Memory==&lt;br /&gt;
&lt;br /&gt;
When we create our own COM component or when we implement a callback predicate, we can receive a parameter in COM memory.&lt;br /&gt;
&lt;br /&gt;
It is important to notice that this memory should &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; be released.&lt;br /&gt;
&lt;br /&gt;
But if we are going to use the information for some time, then we should copy the memory.&lt;br /&gt;
&lt;br /&gt;
In the example below, the parameter has bstr type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;clauses&lt;br /&gt;
    someComPredicate(ComParameter) = s_ok :-&lt;br /&gt;
        trap(somePredicate(basicString::toString(ComParameter)),&lt;br /&gt;
            TraceId, processTraceId(TraceId)),&lt;br /&gt;
        !.&lt;br /&gt;
    someComPredicate(_) = e_fail.&lt;br /&gt;
&lt;br /&gt;
clauses&lt;br /&gt;
    somePredicate(Parameter) :-&lt;br /&gt;
        %some implementation here&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please also notice that Prolog predicates should be trapped, as the COM system cannot process Prolog fail or Prolog exception.&lt;br /&gt;
&lt;br /&gt;
==Implement a COM Predicate. Return Memory==&lt;br /&gt;
&lt;br /&gt;
When we create our own COM component or when we implement a callback predicate, we can be asked about a parameter. Such a parameter must be allocated in COM memory.&lt;br /&gt;
&lt;br /&gt;
So, we should allocate COM memory and fill it with proper values.&lt;br /&gt;
&lt;br /&gt;
In the example below the parameter has myDom type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;domains&lt;br /&gt;
    myDom = myDom(integer X, string S).&lt;br /&gt;
clauses&lt;br /&gt;
    someComPredicate(ComParameter) = s_ok :-&lt;br /&gt;
        trap(&lt;br /&gt;
            (&lt;br /&gt;
                myDom(X, S) = somePredicate(),&lt;br /&gt;
                ComParameterPtr = comMemory::taskMemAlloc(sizeofdomain(myDom)),&lt;br /&gt;
                ComS= comMemory::allocString(S),&lt;br /&gt;
                memory::copy(ComParameterPtr,&lt;br /&gt;
                    uncheckedConvert(pointer,myDom(X, ComS)),&lt;br /&gt;
                    sizeofdomain(myDom)),&lt;br /&gt;
                ComParameter= uncheckedConvert(myDom, ComParameterPtr)&lt;br /&gt;
            ),&lt;br /&gt;
          TraceId, processTraceId(TraceId)),&lt;br /&gt;
        !.&lt;br /&gt;
    someComPredicate(uncheckedConvert(myDom, null)) = e_fail.&lt;br /&gt;
&lt;br /&gt;
clauses&lt;br /&gt;
    somePredicate() = Parameter :-&lt;br /&gt;
        %some implementation here&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can notice that inner parameters of structure domains should be handled as well.&lt;br /&gt;
&lt;br /&gt;
Please also notice that Prolog predicates should be trapped, as COM system cannot process Prolog fail or Prolog exception.&lt;br /&gt;
&lt;br /&gt;
==Implement a COM Predicate. In/Out Parameter==&lt;br /&gt;
&lt;br /&gt;
When we create our own COM component or when we implement a callback predicate, we can receive a memory, which can be changed (i.e. [in, out]).&lt;br /&gt;
&lt;br /&gt;
Then we should allocate COM memory, fill it with proper values, and release the replaced COM memory.&lt;br /&gt;
&lt;br /&gt;
In the example below the parameter has myDom type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;domains&lt;br /&gt;
    myDom = myDom(integer X, string S).&lt;br /&gt;
clauses&lt;br /&gt;
    someComPredicate(ComParameter) = s_ok :-&lt;br /&gt;
        trap(&lt;br /&gt;
            (&lt;br /&gt;
                myDom(X, ComS)= ComParameter&lt;br /&gt;
                S = string::createCopy(ComS),&lt;br /&gt;
                myDom(NewX, NewS) = somePredicate(myDom(X, S)),&lt;br /&gt;
                ComParameterPtr= uncheckedConvert(pointer, ComParameter),&lt;br /&gt;
                comMemory::taskMemFree(ComS),&lt;br /&gt;
                NewComS = comMemory::allocString(NewS),&lt;br /&gt;
                memory::copy(ComParameterPtr,&lt;br /&gt;
                    uncheckedConvert(pointer,myDom(NewX, NewComS)),&lt;br /&gt;
                    sizeofdomain(myDom))&lt;br /&gt;
            ),&lt;br /&gt;
            TraceId, processTraceId(TraceId)),&lt;br /&gt;
        !.&lt;br /&gt;
    someComPredicate(_) = e_fail.&lt;br /&gt;
&lt;br /&gt;
clauses&lt;br /&gt;
    somePredicate(Parameter) = NewParameter :-&lt;br /&gt;
        %some implementation here&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please notice the replaced parameter is released after invocation of the Prolog predicate. Hence, an exception in an implementation of somePredicate will not crash the mutable input parameter.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
</feed>