dpaul 09-10-2001, 01:07 PM I am trying to write a program using multiple modems. I need events for each of the modems. I am using a component from SaxComm. The problem I am having is that I have to have an individual Comm object for each modem, but the number of modems will be changing frequently. I cannot figure out how to dynamically declare comm objects in my code. The WithEvents statement would work if it would let you make it an array. Is there any way to get around that, or something else I haven't thought of?? Thanks for any help you can give.
-Dan
BillSoo 09-10-2001, 01:13 PM Can you make the saxcomm object a control array?
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
dpaul 09-10-2001, 01:16 PM This is what is in the help file for the component...
Although a comm object can interface with any communications port in your system that Windows can access, you cannot use the same comm object to access two comm ports simultaneously. To obtain simultaneous access, you must create a new comm object for each port.
The way you create a comm object depends on the programming language and class library you’re using. You can create as many comm objects in your application as you like; you need one comm object for each port you want to control simultaneously.
BillSoo 09-10-2001, 01:21 PM Can you do something like put a saxcomm object on your form with an INDEX property of 0 (to make it into a control array).
Then in code somewhere, simply add new saxcomm objects like:
Load Saxcomm1(1)
Load Saxcomm1(2)
Load Saxcomm1(3)
...
etc.
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
dpaul 09-10-2001, 01:26 PM I will try it. Thanks for your help!
Thinker 09-10-2001, 02:09 PM The problem you have already discovered is the withevents. This can't
be used with arrays. You can create enough individual object variables
to hold the maximum number of modems you will have to deal with.
Then, at run-time, only create and initialize the ones you need.
I think therefore I am... sometimes right. images/icons/wink.gif
BillSoo 09-10-2001, 02:24 PM True, but if he creates a "prototype" comm object at design time as his index 0 element of the control array, he can put the event code there so he doesn't need "with events"....
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Thinker 09-10-2001, 02:35 PM I was under the impression that it was a component from a DLL. If it is
an actual control, then yes, this is the way to go.
I think therefore I am... sometimes right. images/icons/wink.gif
BillSoo 09-10-2001, 02:39 PM Ahh, I see. I seem to recall that Saxcomm is a drop in replacement for the mscomm control. It supports all of the MScomm events and properties and adds support for file transfer protocols like zmodem.
I vaguely remember trying a demo version of it a long time ago...
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Thinker 09-10-2001, 03:22 PM I just found their web site and it has both a control and object library.
And it does say the control is a drop in replacement for the mscomm
control so the control array should work fine.
I think therefore I am... sometimes right. images/icons/wink.gif
aprice 08-23-2002, 05:00 PM I have recently finished a serial comm server using the SaxComm Object and doing exactly what you are attempting. TO be honest, it was easier for me to create a User Control referencing the SaxComm object in the project. This way it can be used like the MSComm object on your form, as an invisible object during runtime. Place the control on your form, the copy and paste another, creating your control array. Remove the pasted control (index 1) and you have your initial control to begin with. WithEvents will work fine becuase they events are referenced with the index of the control raising the events. Hope this helps, although the answer was probably already posted....
Flyguy 08-24-2002, 05:25 AM Maybe you didn't notice but you replied to a thread which is almost 11 months old. ;)
aprice 08-25-2002, 06:38 AM Actually, no, I didn't notice it, thanks for pointing it out. But at the same time, I figure the reason threads as old as 11 months are left in the forum is so that if anyone is looking for a possible solution for their problem, they can view all threads, including those not recent.
Sorry if I posted a useless reply.
Thinker 08-25-2002, 09:00 AM That is correct aprice. The only problem is, you just reiterated
what had already been said. The final concensus was to use a
control array. Well, at least people will know that someone else
agrees with that assessment.
Our position on old threads is subject to moderator judgement,
but in general, we don't like old threads to be reopened. I tend
to let it go if the poster adds some new solution that I haven't
ever seen, or is asking a similar question, and the context of the
thread makes it much easier to understand the question.
aprice 08-25-2002, 01:21 PM My mistake. I looked at the forum legend and noticed a closed thread image which I didn't see in that thread. And my response was just to re-affirm the reply saying it should work by giving an example of it actually in practice. I'll make sure to read the posting rules more thoroughly.
Thanks for the tip....
|