Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debugging a VFP DLL 1

Status
Not open for further replies.

grahamrhind

Technical User
Jul 8, 2003
99
A1
I'm trying to create my first VFP 6 DLL. I'm created a project (grctools) with a class (grctools) and a method (jobcodes). The code in the method is:

Code:
LPARAMETERS m.fieldcontents, m.countrycode, m.case
use lu\jobcodes
_ftemp = m.fieldcontents
m.found=.f.
_TEMP = upper(ALLTRIM(m.fieldcontents))+'  '
locate for title=_temp and coun_code=m.countrycode
if found()
	do while title=_temp and coun_code=m.countrycode
		_UPPER = ALLTRIM(ucorrect)
		_MIXED = ALLTRIM(mcorrect)
		IF m.case = 1
			IF RAT(alltrim(_TEMP),upper(_FTEMP))=1 
				_FTEMP=STRTRAN(upper(_FTEMP),alltrim(_TEMP),_UPPER+'  ')
				m.found=.t.
			ENDIF
		ELSE
			IF RAT(alltrim(_TEMP),upper(_FTEMP))=1 
				_FTEMP=STRTRAN(upper(_FTEMP),alltrim(_TEMP),_MIXED+'  ')
				m.found=.t.
			ENDIF
		ENDIF
		if m.found=.t.
			exit
		else
			cont
		endif
	enddo
	RETURN _FTEMP
ENDIF
RETURN _FTEMP
[\code]

I have tested this code in a prg, where it works correctly.

The PRG I'm testing to call the DLL contains:

[code]
close all
clear all
PUBLIC _ftemp
_ftemp='.'

oTemp=CREATEOBJECT("grctools.grctools")
oTemp.jobcodes('CEO','USA',2)
? _ftemp
[\code]

This returns always whatever I define as _ftemp in this file.  I know the dll is being read because in initial attempts it was giving error messages in my code, which I corrected.  I can't work out why a PRG of the code gives the correct result and accessing the DLL doesn't.  I haven't been able to find a way of using the debugger for the dll.  Any tips?

Thanks!
 
What Baseclass did you use for the OLE class, did you add OLEPUBLIC? If it's a SESSION, you may have a different _ftemp inside the COM-Object.

Modify your testcode to

? oTemp.jobcodes('CEO','USA',2),
too see what the procedure returns.

Bye, Olaf.
 
Hi Olaf,

OLEPUBLIC was added.

Adding the ? returns the correct result! Thanks!
 
Well, to add:

You get the right value back, because the procedure RETURNs it, but it does not change your public var.

The OLE object has it's own Memory for variables, it defines it's own _ftemp at the line _ftemp = m.fieldcontents. And that's also independent of the base class used for the COM class.

You should define some of the variables LOCAL inside the COM server procedure to clarify this, so nobody expects those code to change any PUBLIC vars defined outside of the COM server dll, such as _TEMP and _MIXED.

Bye, Olaf.
 
Further to this thread, can anybody help me understand how I can return more than one variable from a dll method? Thus, in a method which splits the postal code from the rest of an address, I have code like this:

oTemp=CREATEOBJECT("grctools.grctools")
_ftemp=oTemp.mpc('1000 VV AMSTERDAM','NET',2)

I want to return both the variable _ftemp (the string after the postal code has been removed) and also a new variable which contains the postal code. Given what Olaf wrote above, I can't work out how to do that.
Thanks in advance!
 
Send an additional variable into your mpc method by reference and change it's value inside your mpc method to the postal code...something like:

Loca lcPostalCode
lcPostalCode = ""
oTemp=CREATEOBJECT("grctools.grctools")
_ftemp=oTemp.mpc('1000 VV AMSTERDAM','NET',2,@lcPostalCode)
?lcPostalCode && check to see what we got back

...by sending the variable in by reference any changes you make to it inside the mpc method will affect the variable's actual value. So assign "55333" to the variable inside your mpc method and you will indeed get the value back so to speak. This way of returning additional values will allow you to, in essence, return as many values from your methods as you want. Arrays can even be used.

boyd.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top