public static int AddIntegers (int a, int b) {
return a + b;
}
}
Let's say I need to use this AddIntegers function from my class. What is it I should do? I first thought of creating a class library in Visual Studio .NET 2003 and compiling it into a DLL, hoping I could use the QM dll function like this:
I am not familiar with C#, and don't know how to export functions as dll functions. But you can create COM dll. I experimented with it a little. Not perfect, but works.
In project properties, set Register for COM Interop to True. Without this, type library is not created. Add IArithmetic interface, and set the Arithmetic class to implement it. Here is the code:
namespace ClassLibrary2
{
public interface IArithmetic
{
int AddIntegers(int a, int b);
}
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Arithmetic :IArithmetic
{
public Arithmetic()
{
//
// TODO: Add constructor logic here
//
}
#region IArithmetic Members
public int AddIntegers(int a, int b)
{
// TODO: Add Arithmetic.AddIntegers implementation
return a+b;
}
#endregion
}
}
In QM, add type library declaration, and compile the macro. Then you can view members when you type a period. Create object of type IArithmetic, and call its member functions.
typelib ClassLibrary2 "C:\Documents and Settings\G\Desktop\ClassLibrary2\bin\Debug\ClassLibrary2.tlb" ;ClassLibrary2.Arithmetic a._create ;;this does not work, because IArithmetic is not default interface (I don't know why) ClassLibrary2.IArithmetic i._create(uuidof(ClassLibrary2.Arithmetic)) out i.AddIntegers(2 4)
Now, how do I create triggers for my macros? I need for one of my macros to start at certain time everyday and another one to watch for a file in certain directory and start once that file gets created. Is this all possible?
I'm still trying to understand the difference between a macro, a function and a member function.
When I run it, I get a type mismatch error in the parameterSet parameter. I've also tried declaring parameter and parameterSet the following way instead and get the same type mismatch error:
type PARAMETER str name, str value
PARAMETER parameter
ARRAY(PARAMETER) parameterSet
Any ideas?
Also, feel free to correct anything in my code or suggest other ways to do things. This is my first time coding in QM and my knowledge is only limited to the few examples I have seen on here, the application help and, most of all, your feedback.
I copyed the exact example listed here. Set the COM DLL interop flag.
If I follow the directions and use the QM TypeLibraryies dialog, I can click "Browser" and add the type library. I can type "i" and access the methods.
Error (RT) in Macro19: 0x80040154, Class not registered
If I tryed to register using Regsvr32 I get a messages about "dllResisterServer" entry point not found. I read on the web that for .net code you should use RegAsm.exe insted of the Regsvr32.
When I use regasm.exe it does get registered. But now when i try to run the macro i now get this
When I create new project, I select Visual C# Projects, Class Library in the New Project dialog. Name project ClassLibrary2. Then set Register for COM interop in project Properties. Add code to Class1.cs. Compile. I see ClassLibrary2.dll and ClassLibrary2.tlb in bin\Debug folder. Add QM code. Run macro. Works well. If type library is specified by path, you even don't have it register with Type Libraries dialog or whatever. Maybe you selected something other than Class Library when creating new project.