[thelist] Interfacing an unknown com object from ASP (long)

David.Cantrell at Gunter.AF.mil David.Cantrell at Gunter.AF.mil
Tue Aug 20 09:58:01 CDT 2002


[snip]
>intCardCheck objKort.CardCheck ( 1, "1", 20, "4552xxxxxxxxxxxx", 50, 5,
>0,"" ,"" ,"" ,"" ,"" )
...
>Their programmer says that in Delphi he would pass all the values as I
>demonstrated in the first example and pass pointers for the return values.
>I've never heard of doing this in ASP. The programmer, for the record, has
>never worked with ASP before!
[/snip]

This is a piece of cake, don't worry about it. :)

Functions can return multiple values as long as you provide pointers to the
values. This guy is probably a C programmer at heart I'm guessing, since
this sounds like a C idiom. Not to say it can't or shouldn't be done in
other languages, just that I identify it mostly with C, because C deals so
much with pointers.

Checkit:

	dim FirstPointer
	dim SecondPointer
	dim ThirdPointer
	dim FourthPointer
	dim FifthPointer

	intCardCheck = objKort.CardCheck( 1, "1", 20, "4552xxxxxxxxxxxx",
50, 5, 0, FirstPointer, SecondPointer, ThirdPointer, FourthPointer,
FifthPointer )

	response.write "First: " & FirstPointer
	response.write "Second: " & SecondPointer
	response.write "Third: " & ThirdPointer
	response.write "Fourth: " & FourthPointer
	response.write "Fifth: " & FifthPointer

See? Cake!

For the record your variables are pointers to memory locations, hence the
pointer reference.

Now of course if some of the returns are objects or arrays instead of
scalars you'll have to treat them differently, but the API should document
all of the return values for you.

[snip]
>Am I missing something? Is there another way of using a com object in ASP
>than I have mentioned above? Has anyone else come across a problem like
this
>before? What am I missing to get at the return values?
[/snip]

The alternative as I understand it would look like this skeleton class:

	Class Kort
		Public Property CardDetails
		Public Property Amount
		...
		Public FirstPointer 'bad name but you get the idea
		...
		Public Function Check()
			Check = CardCheck( CardDetails, Amount, ....,
FirstPointer, ... )
		End Function
		Public Function CardCheck( CardDetails, Amount, ...,
FirstPointer, ... )
			.. do all the funky checking in here ..
		End Function
	End Class

Effectively giving you both APIs.

Otherwise you are stuck with the API they give you. Ain't lock-in great? :)

-dave



More information about the thelist mailing list