Common Object Model (COM) Dlls.

Just starting out? Need help? Post your questions and find answers here.
FluxCapacitor
New User
New User
Posts: 1
Joined: Fri May 31, 2013 2:21 pm
Location: Cape Town, South Africa

Common Object Model (COM) Dlls.

Post by FluxCapacitor »

High everyone, I'm new here. I've been a Basic programmer for 15+ years - all with MS software.
I want to move to Pure Basic but ...

As well as development in Basic, I manage 3 HTA scripted desktop systems, which all use
my own COM dlls. As I'm sure you know, Javascript, vbscript and powershell cannot
address the winapi directly, only through COM DLLs using CreateObject.
So whether I like it or not, I need a COM dll compile facility.

Does Pure Basic have this capability ? I've searched through the documentation and, bearing in
mind I'm not familiar with the product or it's specific terminology, I can find nothing which
specifically addresses the issue.

Hoping for a positive answer

Flux Capacitor ...
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Common Object Model (COM) Dlls.

Post by Josh »

Hi FluxCapacitor

First of all, PureBasic is not the best decision, if you want to use mainly Com. I'm not sure, what are you looking for. If you want to invoke Com objects, search in the forum for ComatePlus. If you want to create a Com Dll, have a look here.

Further informations see here

Josh
sorry for my bad english
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: Common Object Model (COM) Dlls.

Post by PBExplorer12 »

Josh wrote:Hi FluxCapacitor

First of all, PureBasic is not the best decision, if you want to use mainly Com. I'm not sure, what are you looking for. If you want to invoke Com objects, search in the forum for ComatePlus. If you want to create a Com Dll, have a look here.

Further informations see here

Josh

So, in order to invoke some of the methods in a third-party Com Component, we need to use ComatePlus, or something similar? There is no CreateObject() or something similar in Purebasic? ( I already tried, and PB doesn't understand CreateObject() )
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: Common Object Model (COM) Dlls.

Post by Thorium »

PBExplorer12 wrote: So, in order to invoke some of the methods in a third-party Com Component, we need to use ComatePlus, or something similar? There is no CreateObject() or something similar in Purebasic? ( I already tried, and PB doesn't understand CreateObject() )
PureBasic isnt object oriented, so COM isnt realy in the scope of the language. You can use it by doing all by hand. You have basic support with the interface structure.
Or you use a allready developed system like ComatePlus, which will do all the COM related stuff for you.
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: Common Object Model (COM) Dlls.

Post by PBExplorer12 »

Thorium wrote:
PBExplorer12 wrote: So, in order to invoke some of the methods in a third-party Com Component, we need to use ComatePlus, or something similar? There is no CreateObject() or something similar in Purebasic? ( I already tried, and PB doesn't understand CreateObject() )
PureBasic isnt object oriented, so COM isnt realy in the scope of the language. You can use it by doing all by hand. You have basic support with the interface structure.
Or you use a allready developed system like ComatePlus, which will do all the COM related stuff for you.

Yes, I understand about keeping PureBasic 'pure', in the sense of keeping it procedural.

Unfortunately, I haven't been able to get ComatePlus to make use of some third party Parsing components, that have support for quoted strings. No matter how much pre-manipulation is done to a string - Inserting Chr(34)s or Chr(39)s, escaping quotes, all sorts of tricks - the ComatePlus Invoke() keeps returning the

' one or more arguments are invalid' type of message. Whereas if the function is called from other languages with internal COM support, it works fine.

Anyway, I'm going to try the regular expression route, for this. I'll take a look at ComatePlus for other things.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Common Object Model (COM) Dlls.

Post by Kiffi »

PBExplorer12 wrote:' one or more arguments are invalid' type of message.
please post some code. Perhaps we see, what's going wrong.

Greetings ... Kiffi
Hygge
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: Common Object Model (COM) Dlls.

Post by PBExplorer12 »

Kiffi wrote:
PBExplorer12 wrote:' one or more arguments are invalid' type of message.
please post some code. Perhaps we see, what's going wrong.

Greetings ... Kiffi

Absolutely. Will put something out there, over the weekend. However, although it's clear how to attach an image, I'm not sure how to attach a Zip or dll or ocx file to a thread, for illustration.
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Common Object Model (COM) Dlls.

Post by Demivec »

PBExplorer12 wrote:However, although it's clear how to attach an image, I'm not sure how to attach a Zip or dll or ocx file to a thread, for illustration.
Store the files somewhere offsite (of the forum), i.e. Dropbox, and use:

Image

This is also useful to link to other threads in the forum.
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: Common Object Model (COM) Dlls.

Post by PBExplorer12 »

Demivec wrote:
PBExplorer12 wrote:However, although it's clear how to attach an image, I'm not sure how to attach a Zip or dll or ocx file to a thread, for illustration.
Store the files somewhere offsite (of the forum), i.e. Dropbox, and use:

Image

This is also useful to link to other threads in the forum.

Well, I'm trying to create the simplest ole server, and the simplest Test pb code which will illustrate the COMatePlus issue. But am getting an error, in the COMatePlus.pbi code, that wasn't there before.

When you do a syntax check, it chokes on line 1838,

errorCode = COMatePLUS_CompileSubobjectInvokation(*hStatement, subObject, @parse())


, and returns the error


Bad parameter type: an array is expected.

I don't get it. I copied the .PBIs, directly from a pb project folder, that was compiling fine.
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: Common Object Model (COM) Dlls.

Post by PBExplorer12 »

"
Well, I'm trying to create the simplest ole server, and the simplest Test pb code which will illustrate the COMatePlus issue. But am getting an error, in the COMatePlus.pbi code, that wasn't there before.

When you do a syntax check, it chokes on line 1838,

errorCode = COMatePLUS_CompileSubobjectInvokation(*hStatement, subObject, @parse())


, and returns the error


Bad parameter type: an array is expected.

I don't get it. I copied the .PBIs, directly from a pb project folder, that was compiling fine.[/quote]
"


Never mind. There was a similar post about the same problem, and the advice was to remote the '@'.

Still kinda unusual that the code - WITH the '@' - works fine in the previous module. Whatever, the error is gone now.
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: Common Object Model (COM) Dlls.

Post by PBExplorer12 »

"Store the files somewhere offsite (of the forum), i.e. Dropbox, and use:

...

This is also useful to link to other threads in the forum."


So, in the attached, there are 2 simple projects (a PB and a VB6 version) which make use of the simplified Harbour oleserver hbTokenUdfs.dll.

The idea is to extract the number of tokens from a string, using the Harbour token count function HB_TokenCount().

The PB version generates an error, on every INVOKation:

"One or more arguments are invalid. Possibly a numerical overflow or too many nested objects, -if so, try splitting your method call into two or more subcalls."


the VB6 version takes the string:

sMessage := "Hi, WELcome to FANtasy Island!"

, and correctly returns 3 tokens, representing


sMessage
:=
"Hi, WELcome to FANtasy Island!"



The sample projects are located at
https://dl.dropboxusercontent.com/u/584 ... 130825.zip



The fact that Invoke returns only a Success or Failure value, and NOT the value of the method that's INVOKed, make it more difficult to debug, as you would with another language. But even if you call the INVOKE as a simple proc, then try to get the return value from a Property, you never get to first base, because INVOKE() doesn't seem to work with certain types of string parameters.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Common Object Model (COM) Dlls.

Post by Kiffi »

Code: Select all

sTestString = " what the heck " + "," + "why, you" + "," + "you dirty rat"
Debug sTestString
Debug oOleServerTest\GetIntegerProperty( "GetNumberOfTokens('" + sTestString + "')" )
Debug COMate_GetLastErrorDescription()
HTH

Greetings ... Kiffi
Hygge
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: Common Object Model (COM) Dlls.

Post by PBExplorer12 »

Kiffi wrote:

Code: Select all

sTestString = " what the heck " + "," + "why, you" + "," + "you dirty rat"
Debug sTestString
Debug oOleServerTest\GetIntegerProperty( "GetNumberOfTokens('" + sTestString + "')" )
Debug COMate_GetLastErrorDescription()
HTH

Greetings ... Kiffi

Ah, ok. So the Get...Property() in CoMate methods actually work on the the component's methods, as opposed to just returning attributes.

Very good, thanks.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Common Object Model (COM) Dlls.

Post by Kiffi »

PBExplorer12 wrote:Ah, ok. So the Get...Property() in CoMate methods actually work on the the component's methods, as opposed to just returning attributes.
yes, the same way you do it with VB6:

Code: Select all

nResult = oTokenTest.GetNumberOfTokens(sTestString)             ' Returns 8
Greetings ... Kiffi
Hygge
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: Common Object Model (COM) Dlls.

Post by PBExplorer12 »

"yes, the same way you do it with VB6"

Well, I guess it depends on how you look at it. But I think calling Get Integer/String/etc Property(), with a method name & its parameters as a parameter, looks very different syntactically, from calling the method directly.

Anyway, thanks for the help, Kiffi. Back on track, here.
Post Reply