|
 |
asp_components thread: Using a COM Globally
Message #1 by "Murali" <Murali_Natarajan@r...> on Tue, 26 Sep 2000 14:47:05 +0100
|
|
I created a COM component that has a set of customized functions. However,
when I use this COM in my ASP page, I have to code the following whole
nine yards.
<%
Dim Com
Set Com = Server.CreateObject ("Format.Functions")
Get_Name = Com.Format_String(Address_Field)
Set Com = Nothing
%>
Instead of the above code, is there a way to create a component where I
can straightly use Format_String (like any other VB functions, for example
Lcase or UCase) without coding all this ?
Please let me know.
Thank you.
Message #2 by Imar Spaanjaars <Imar@S...> on Tue, 26 Sep 2000 18:18:57 +0200
|
|
Is it the extra coding you are worried about, or the overhead of all this
coding?
If it's only the first, create a function with the same name and put it in
an include file:
Function Format_String(sValueToFormat)
Dim Com
Set Com = Server.CreateObject ("Format.Functions")
Format_String = Com.Format_String(sValueToFormat)
Set Com = Nothing
end function
Then in your ASP page, all you need to do is:
Format_String(Address_Field)
HtH
Imar
At 04:25 PM 9/26/2000 -0700, you wrote:
>I created a COM component that has a set of customized functions. However,
>when I use this COM in my ASP page, I have to code the following whole
>nine yards.
><%
> Dim Com
> Set Com = Server.CreateObject ("Format.Functions")
> Get_Name = Com.Format_String(Address_Field)
> Set Com = Nothing
>%>
>Instead of the above code, is there a way to create a component where I
>can straightly use Format_String (like any other VB functions, for example
>Lcase or UCase) without coding all this ?
>Please let me know.
>
>Thank you.
>
>
Message #3 by "Stephen Haberman" <stephenh@c...> on Tue, 26 Sep 2000 12:15:41 -0500
|
|
I saw an example on 4guysfromrolla.com the other day
(http://www.4guysfromrolla.com/webtech/092500-1.shtml) where they did
something like this. The object was a string builder written in C++ and
they used this code:
Dim strcat
Set strcat = Server.CreateObject("StrCat.Catter")
Dim rs
Set rs = ExecuteSql("SELECT Username FROM Users")
do until rs.EOF
strcat rs(0) & "<br>" & vbCrLf
rs.MoveNext
loop
Dim some_str
some_str = strcat.Dump
Set strcat = nothing
Response.Write some_str
The line that would interest you would be the "strcat rs(0)..." Notice they
don't use a method name...I don't know how exactly this works, but they
mentioned the default method somewhere in the article and I'm thinking that
executes the first method of the objects IDispatch (I'm guessing) interface.
So what you'd want to do is create a C++ object that was both threaded so
you could put it in the application space. Then instead of just putting in
the application, put it in the static objects collection (by using the
<OBJECT tag...I'm not real sure how you do it, but it'd be in the docs
somewhere). When its in the static objects, you don't have to refer to it
as Application("myObject").methodName, instead you can just do
myObject.methodName.
So finally, if you do all this, you should (theoretically) be able to do
retVal = myObject parameter on any page and it would assume the method name
and send it to your object.
If you need sample code for the C++, that example on 4guysfromrolla.com
would be good.
HTH,
Stephen
> -----Original Message-----
> From: Murali [mailto:Murali_Natarajan@r...]
> Sent: Tuesday, September 26, 2000 6:26 PM
> To: ASP components
> Subject: [asp_components] Using a COM Globally
>
>
> I created a COM component that has a set of customized functions. However,
> when I use this COM in my ASP page, I have to code the following whole
> nine yards.
> <%
> Dim Com
> Set Com = Server.CreateObject ("Format.Functions")
> Get_Name = Com.Format_String(Address_Field)
> Set Com = Nothing
> %>
> Instead of the above code, is there a way to create a component where I
> can straightly use Format_String (like any other VB functions, for example
> Lcase or UCase) without coding all this ?
> Please let me know.
>
> Thank you.
>
>
Message #4 by "Devinder Uppal" <uppal@d...> on Tue, 26 Sep 2000 13:47:54 -0500
|
|
I have the same challenge kind of.
In my case, I am worried about the overhead
of the repeated code in 100's of my asp pages.
Any ideas to avoid the overhead, please tell.
thanks
Devinder
----- Original Message -----
From: "Imar Spaanjaars" <Imar@S...>
To: "ASP components" <asp_components@p...>
Sent: Tuesday, September 26, 2000 11:18 AM
Subject: [asp_components] Re: Using a COM Globally
> Is it the extra coding you are worried about, or the overhead of all this
> coding?
>
> If it's only the first, create a function with the same name and put it in
> an include file:
>
> Function Format_String(sValueToFormat)
> Dim Com
> Set Com = Server.CreateObject ("Format.Functions")
> Format_String = Com.Format_String(sValueToFormat)
> Set Com = Nothing
> end function
>
>
> Then in your ASP page, all you need to do is:
>
> Format_String(Address_Field)
>
> HtH
>
> Imar
>
>
> At 04:25 PM 9/26/2000 -0700, you wrote:
> >I created a COM component that has a set of customized functions.
However,
> >when I use this COM in my ASP page, I have to code the following whole
> >nine yards.
> ><%
> > Dim Com
> > Set Com = Server.CreateObject ("Format.Functions")
> > Get_Name = Com.Format_String(Address_Field)
> > Set Com = Nothing
> >%>
> >Instead of the above code, is there a way to create a component where I
> >can straightly use Format_String (like any other VB functions, for
example
> >Lcase or UCase) without coding all this ?
> >Please let me know.
> >
> >Thank you.
> >
> >
>
> ---
> To place your message here, or to sponsor this list, please e-mail
mailto:p2pinfo@w...?subject=MediaPack, remembering to provide contact
details for yourself. We will e-mail you a Media Pack within 24 hours.
>
> You are currently subscribed to asp_components
$subst('Email.Unsub')
> ---)
>
|
|
 |