From WikiChip
Difference between revisions of "mirc/identifiers/$com"
< mirc‎ | identifiers

Line 1: Line 1:
{{mirc title|$com Identifier}}'''$com''' calls a member of an open COM connection with the specified method and parameter, or returns informations about a currently opened COM
+
{{mirc title|$com Identifier}}'''$com''' calls a member of an open COM connection with the specified method and parameter, or returns informations about a currently opened COM or returns the value of the specified variable name
  
  
Line 5: Line 5:
 
<pre>$com(name,member,method,type1,value1,...,typeN,valueN) - calls a member of an open COM connection with the specified method and parameters, returns 1 if the call succeeds, 0 = fail.
 
<pre>$com(name,member,method,type1,value1,...,typeN,valueN) - calls a member of an open COM connection with the specified method and parameters, returns 1 if the call succeeds, 0 = fail.
  
 +
$com(name/N,varname) - returns the value of the specified variable name
  
 
$com(name/N) - returns the name of the Nth open COM connection or the name of that connection if it's open
 
$com(name/N) - returns the name of the Nth open COM connection or the name of that connection if it's open
Line 11: Line 12:
 
== Paramters ==
 
== Paramters ==
 
* '''name/N''' - The name of the connection or the Nth connection
 
* '''name/N''' - The name of the connection or the Nth connection
 +
* '''varname''' - The name of a variable previously saved
 
* '''member''' - The name of the function of the object
 
* '''member''' - The name of the function of the object
 
* '''method''' - A combination of the following value added together:
 
* '''method''' - A combination of the following value added together:
** '''1''' = DISPATCH_METHOD
 
** '''2''' = DISPATCH_PROPERTYGET
 
** '''4''' = DISPATCH_PROPERTYPUT
 
** '''8''' = DISPATCH_PROPERTYPUTREF
 
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
 
! Value !! Method
 
! Value !! Method
 
|-
 
|-
| 1 || Call a member of an object
+
| 1 || DISPATCH_METHOD - Call a member of an object
 
|-
 
|-
| 2 || Return a value
+
| 2 || DISPATCH_PROPERTYGET - Return a value
 
|-
 
|-
 
| 3 || (1+2) Call a member and return a value *
 
| 3 || (1+2) Call a member and return a value *
 
|-
 
|-
| 4 || Set a property
+
| 4 || DISPATCH_PROPERTYPUT - Set a property
 
|-
 
|-
 
| 5 || (1+4) Set a property with a member call *
 
| 5 || (1+4) Set a property with a member call *
Line 35: Line 33:
 
| 7 || (1+2+4) Set a property and return a value with a member call *
 
| 7 || (1+2+4) Set a property and return a value with a member call *
 
|-
 
|-
| 8 || Set a property by reference
+
| 8 || DISPATCH_PROPERTYPUTREF - Set a property by reference
 
|-
 
|-
 
| 9 || (1+8) Set a property by reference with a member call *
 
| 9 || (1+8) Set a property by reference with a member call *
Line 85: Line 83:
 
|error || This data type indicates a 32-bit error code (DBTYPE_ERROR)
 
|error || This data type indicates a 32-bit error code (DBTYPE_ERROR)
 
|}
 
|}
 +
 +
You can pass a binary variable by prefixing the type of the variable with an '&' sign eg. $com(name,member,method,&bstr &binvar)
  
 
To make a variable by reference, postfix the data type with an asterisk and a variable name, for example: int* pIntOfBeer.
 
To make a variable by reference, postfix the data type with an asterisk and a variable name, for example: int* pIntOfBeer.
  
 
* '''value1''' - the value assigned to the variable type
 
* '''value1''' - the value assigned to the variable type
 +
 +
== Properties ==
 +
When only one parameter is passed to $com (name/N), you can use the following properties:
 +
* '''.progid''' - returns the object name
 +
* '''.result''' - returns the value returned by the COM object member call, you can save this result to a binary variable with $com(name/N,&binvar).result
 +
* '''.error''' - returns the error value, if there were any error
 +
* '''.errortext''' - returns the error description associated with the '''.error''' value
 +
* '''argerr''' - returns the Nth argument that caused the error, if the error were due to an invalid variable type.
 +
* '''.dispatch''' - returns the name of the dispatched pointer if it exist
 +
* '''.unknown''' - returns the name of the unknown pointer if it exist
 +
 +
In the case of retrieving an unknown pointer, mIRC will extend it to a dispatch pointer if it can, allowing you to call it directly via $com().
 +
 +
  
 
== Example ==
 
== Example ==
Echo the value of '''$dlevel''' to the active window:
+
<source lang="mIRC"></source>
<source lang="mIRC">//echo -a Default user level: $dlevel</source>
 
  
 
== Compatibility ==
 
== Compatibility ==
{{mIRC compatibility|4.72}}
+
{{mIRC compatibility|5.9}}
  
 
== See Also ==
 
== See Also ==
* [[List of on events - mIRC|ON Events]]
+
* {{mIRC|$comval}}
* {{mIRC|$clevel}}
+
* {{mIRC|$comerr}}
* {{mIRC|$event}}
+
* {{mIRC|/comopen}}
* {{mIRC|$ulevel}}
+
* {{mIRC|/comclose}}
{{mIRC identifier list}}
 
  
[[Category:mIRC identifiers|dlevel]]
+
[[Category:mIRC identifiers|com]]

Revision as of 08:16, 5 April 2018

$com calls a member of an open COM connection with the specified method and parameter, or returns informations about a currently opened COM or returns the value of the specified variable name


Synopsis

$com(name,member,method,type1,value1,...,typeN,valueN) - calls a member of an open COM connection with the specified method and parameters, returns 1 if the call succeeds, 0 = fail.

$com(name/N,varname) - returns the value of the specified variable name

$com(name/N) - returns the name of the Nth open COM connection or the name of that connection if it's open

Paramters

  • name/N - The name of the connection or the Nth connection
  • varname - The name of a variable previously saved
  • member - The name of the function of the object
  • method - A combination of the following value added together:
Value Method
1 DISPATCH_METHOD - Call a member of an object
2 DISPATCH_PROPERTYGET - Return a value
3 (1+2) Call a member and return a value *
4 DISPATCH_PROPERTYPUT - Set a property
5 (1+4) Set a property with a member call *
6 (2+4) Set a property and return a value *
7 (1+2+4) Set a property and return a value with a member call *
8 DISPATCH_PROPERTYPUTREF - Set a property by reference
9 (1+8) Set a property by reference with a member call *
10 (2+8) Set a property by reference and return a value *
  • type1 - The variable type, can be:
Type Description Values
i1 single byte signed integer 0 to 225
ui1 single byte unsigned integer 0 to 255
i2 two byte signed integer -32768 to 32767
ui2 two byte unsigned integer 0 to 65535
i4 four byte signed integer +/- 2147483647
ui4 Holds unsigned 32-bit (4-byte) integers 0 through 4,294,967,295
int integer -2147483648 to 2147483647
uint unsigned integer 0 to 4294967295
r4 real, 4-byte floating point number 1.17549435E-38 to 3.40282347E+38
r8 double real, 8-byte floating point number 2.2250738585072014E-308 - 1.7976931348623157E+308
cy eight byte curreny number -922337203685477.5625 to 922337203685477.5625
date contains date and time, stored as an 8-byte floating-point number +/-79,228,162,514,264,337,593,543,950,335
decimal Holds signed 128-bit (16-byte) values representing 96-bit (12-byte) integer numbers. +/-79,228,162,514,264,337,593,543,950,335
bool contain any string or numeric representation.
bstr null-terminated unicode character string value. A string can contain from 0 to approximately 2 billion (2^31) Unicode characters.
variant can contain string, date, time, boolean, or numeric values. When used, a data type must follow it: for example: variant int 5
dispatch This data type indicates a pointer to an IDispatch interface on an OLE object (DBTYPE_IDISPATCH).
unknown This data type indicates a pointer to an IUnknown interface on an OLE object (DBTYPE_IUNKNOWN).
error This data type indicates a 32-bit error code (DBTYPE_ERROR)

You can pass a binary variable by prefixing the type of the variable with an '&' sign eg. $com(name,member,method,&bstr &binvar)

To make a variable by reference, postfix the data type with an asterisk and a variable name, for example: int* pIntOfBeer.

  • value1 - the value assigned to the variable type

Properties

When only one parameter is passed to $com (name/N), you can use the following properties:

  • .progid - returns the object name
  • .result - returns the value returned by the COM object member call, you can save this result to a binary variable with $com(name/N,&binvar).result
  • .error - returns the error value, if there were any error
  • .errortext - returns the error description associated with the .error value
  • argerr - returns the Nth argument that caused the error, if the error were due to an invalid variable type.
  • .dispatch - returns the name of the dispatched pointer if it exist
  • .unknown - returns the name of the unknown pointer if it exist

In the case of retrieving an unknown pointer, mIRC will extend it to a dispatch pointer if it can, allowing you to call it directly via $com().


Example

 

Compatibility

Added: mIRC v5.9
Added on: 26 Apr 2001
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See Also