Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jeff Stone
  
 
 
 Jeff Stone
 Tags
Subject: Build Com Problem
Thread ID: 112596 Message ID: 112596 # Views: 9 # Ratings: 0
Version: Visual FoxPro 8 Category: Active X Controls & OLE Automation
Date: Friday, November 10, 2006 12:51:52 AM         
   


Hi Everyone,

I wrote a simple single-threaded COM .dll several years ago which I was successfully able to build with VFP 6.0. I was recently asked to add an additional function. When I tried to build the COM with VFP 8.0, I got a 'class definition FPIMPORT not found' message where FPIMPORT is the class I define in the .prg as an OLEPUBLIC. Curious as to whether this was a version 8 problem, I reinstalled VFP 6.0 on my machine and got the same error message.

To make matters more confusing, I unmothballed my old machine on which the code was originally built, and naturally, the new code builds fine!

It would seem to me that I've got an installation problem on my current machine but after uninstalling and reinstalling VFP 8 and 6, I still cannot get a clean build.

Any ideas? I've pasted my code below.

TIA

Jeff
*********************************************************
DEFINE CLASS fpimport AS Relation OLEPUBLIC

TAXDIR = ""
TEMPLTDIR = ""
cCurrentPath = ""
mTOTCAPPMT = 0
mNETCAPPMT = 0
mEXSCAPPMT = 0

FUNCTION SetCentury
  set century on    &&just as a precaution
ENDFUNC

FUNCTION InitDirs
  THIS.TAXDIR = gete("TAXDIR")
  THIS.TEMPLTDIR = gete("TEMPLTDIR")
  if len(rtrim(THIS.TEMPLTDIR)) = 0
    THIS.TEMPLTDIR = "D:\TEMPLATE\"   &&for jeff
  endif
  if len(rtrim(THIS.TAXDIR)) < 5
    THIS.TAXDIR = "E:\BONY\"
  endif
ENDFUNC


FUNCTION SetCurrentPath
LPARAMETERS lcPath
lcOldPath = SYS(5) + CURDIR()
IF !EMPTY(lcPath)
   cd (lcPath)
   THIS.cCurrentPath = SYS(5) + CURDIR()
ELSE
   THIS.cCurrentPath = lcOldPath
ENDIF
RETURN lcOldPath
ENDFUNC

FUNCTION UseFile
LPARAMETERS lcname, laliasname
&&messagebox("0 use file "+lcname)
if !file(lcname)
 return 'N'
endif
select 0
***check structure of template to make sure selected file is up-to-date
filetype = right(lcname,3)
templtfl = THIS.TEMPLTDIR+filetype+"_flds"
use (templtfl)
sum field_len to xrecsize
xrecsize = xrecsize + 1    &&add 1 for mark for deletion field
use (lcname) alias (laliasname)

if type("clsg_delay") # "U"  &&The field exists and the file already holds a good value for clsg_delay
  good_clsg_delay = .T.      &&We have to do this because when the delay_mths go down to zero, the value of clsg_delay will
else                         &&be reset to 0 and that is bad.  We will populate the clsg_delay only the first time we update it
  good_clsg_delay = .F.
endif

if (good_clsg_delay = .T.)
  sum clsg_delay to x
  sum delay_mths to y for (upper(coll_type)!='D' .or. io_dlymths > 0)
  if (x = 0 .and. y > 0)
    good_clsg_delay = .F. && if (x) all of them are 0 and (y) they should not be, it could be a fresh file
  endif
  go top
endif

if recsize() <> xrecsize .or. (good_clsg_delay = .F. .and. upper(filetype) = "CLD") &&update file format if necessary
  copy to temp
  &&use (templtfl)
  &&copy struct to (lcname)
  create (lcname) from (templtfl)   && changed this since it didn't seem to be working correctly with the fpt file
  &&messagebox("1 Updating file structure for "+lcname)
  use (lcname) alias (laliasname)
  append from temp
  go top

  if (good_clsg_delay = .F.)
    if upper(filetype) = "CLD" &&added 3/18/05 JAS
     locate for clsg_delay = 0
     &&messagebox("2 Updating file structure for "+lcname)
     if .not. eof()
       if upper(substr(lcname,6,3)) # 'CLS'
         dealage = val(substr(lcname,6,3))
       else
         dealage = 0
       endif
       replace all clsg_delay with iif((upper(coll_type)!='D' .or. io_dlymths > 0) .and. delay_mths > 0, delay_mths + dealage, 0)
     endif
    endif
    go top
  endif
  use (lcname) alias (laliasname)
  delete file temp.dbf
endif
return 'Y'
ENDFUNC


****this function is not used by the C programs
FUNCTION UseFile1
LPARAMETERS lcname, lfiletype, laliasname
if !file(lcname)
 return 'N'
endif
select 0
***check structure of template to make sure selected file is up-to-date
&&filetype = right(lcname,3) ---changed this AS 9/19/2003
templtfl = THIS.TEMPLTDIR+lfiletype+"_flds"
use (templtfl)
sum field_len to xrecsize
xrecsize = xrecsize + 1    &&add 1 for mark for deletion field
use (lcname) alias (laliasname)
if recsize() <> xrecsize            &&update file format if necessary
  copy to temp
  &&use (templtfl)
  &&copy struct to (lcname)
  create (lcname) from (templtfl)   && changed this since it didn't seem to be working correctly with the fpt file
  &&messagebox("Updating file structure for "+lcname)
  use (lcname) alias (laliasname)
  append from temp
  go top
  delete file temp.dbf
endif
return 'Y'
ENDFUNC

FUNCTION CreateFile
LPARAMETERS lcname, lfiletype, laliasname
select 0
source = THIS.TEMPLTDIR+lfiletype+"_flds"
create (lcname) from (source)
use (lcname) alias (laliasname)
ENDFUNC


FUNCTION Get
LPARAMETERS laliasname, lcfieldname
select (laliasname)
RETURN eval(lcfieldname)
ENDFUNC

FUNCTION GetDate
LPARAMETERS laliasname, lcfieldname
select (laliasname)
RETURN dtoc(eval(lcfieldname))
ENDFUNC

FUNCTION Put
LPARAMETERS laliasname, lcfieldname, fldvalue
select (laliasname)
replace (lcfieldname) with fldvalue
ENDFUNC

FUNCTION PutDate
LPARAMETERS laliasname, lcfieldname, fldvalue
select (laliasname)
replace (lcfieldname) with ctod(fldvalue)
ENDFUNC

FUNCTION SkipRec
LPARAMETERS laliasname, numskip
select (laliasname)
skip numskip
**messagebox(laliasname+str(recno(),5))
if eof() .or. bof()
 RETURN "Y"
else
 RETURN "N"
endif
ENDFUNC

FUNCTION CloseFile
LPARAMETERS laliasname
select (laliasname)
use
ENDFUNC

FUNCTION GoToTop
LPARAMETERS laliasname
select (laliasname)
goto top
ENDFUNC

FUNCTION NewRecord
APPEND BLANK
ENDFUNC

FUNCTION GetRecordNum
LPARAMETERS laliasname
select (laliasname)
RETURN RECNO()
ENDFUNC

FUNCTION Zap
Set Safety Off
Zap
ENDFUNC

FUNCTION UseFileNoCheck
LPARAMETERS laliasname
select (laliasname)
ENDFUNC

FUNCTION Export_To_Excel
LPARAMETERS laliasname, lfilename, lperiod
select (laliasname)
copy to (lfilename) type xl5 for period = lperiod
ENDFUNC

FUNCTION OpenFile
LPARAMETERS lcname, laliasname
if !file(lcname)
 return 'N'
endif
select 0
use (lcname) alias (laliasname)
ENDFUNC

FUNCTION IsDeleted
if deleted()
    RETURN 1
else
    RETURN 0
endif
ENDFUNC

FUNCTION Sort
LPARAMETERS laliasname, lcfieldname, ltempname
select (laliasname)
index on &lcfieldname to (ltempname)
&&index on LOAN_ID to (ltempname)
copy to (ltempname)
zap
append from (ltempname)
close all
ENDFUNC

FUNCTION Erase
LPARAMETERS lcname
erase (lcname)
ENDFUNC

****************************************************
***cap related functions are below******************
**note: a reference file (ref) is being used to ensure no problems aligning with deal's capfile
**      with the aggregate caplist file
FUNCTION FPOpenCap_and_ref_dbfs
LPARAMETERS lcname  &&only 5 char deal name as files are static
lcname = substr(lcname,1,5)
lcapname = lcname + 'cap.dbf'
lrefname = lcname + 'ref.dbf'
if !file(lcapname) .or. !file(lrefname)
 return '1'
endif

select 0
filetype = 'cap'
templtfl = THIS.TEMPLTDIR+filetype+"_flds"
use (templtfl)
sum field_len to xrecsize
xrecsize = xrecsize + 1    &&add 1 for mark for deletion field
use (lcapname) alias capfile  &&file is assumed to be indexed with .CDX file on str of PAYMENTNUM & DEALCONNUM
SET ORDER to tag pmt_cntrct

if recsize() <> xrecsize     &&update file format if necessary
  copy to temp
  create (lcapname) from (templtfl)
  use (lcapname) alias capfile
  INDEX ON STR(paymentnum,3)+STR(dealconnum,2) tag pmt_cntrct
  SET ORDER to tag pmt_cntrct
  append from temp
  go top
  delete file temp.dbf
endif

select 0
filetype = 'ref'
templtfl = THIS.TEMPLTDIR+filetype+"_flds"
use (templtfl)
sum field_len to xrecsize
xrecsize = xrecsize + 1    &&add 1 for mark for deletion field
use (lrefname) alias reffile &&file is assumed to be indexed with .CDX file on str of DEALCONNUM
SET ORDER to tag cntractnum

if recsize() <> xrecsize     &&update file format if necessary
  copy to temp
  create (lrefname) from (templtfl)
  use (lrefname) alias reffile
  INDEX ON dealconnum tag cntractnum
  SET ORDER to tag cntractnum
  append from temp
  go top
  delete file temp.dbf
endif

select 0
caplist = THIS.TAXDIR+"Caplist.dbf"
if !file(caplist)
 return '2'
endif
use (caplist) alias caplist
SET ORDER to tag refnum

*select capfile    this doesn't seem to work for some reason...  thus will do direct seek btw files
*set relation to DEALCONNUM into reffile
*select reffile
*set relation to REF_NUMBER into caplist

return 'Y'
ENDFUNC

FUNCTION FPposition_cap_record
LPARAMETERS lperiod, lcontract_num
 select capfile
 seek str(lperiod,3)+str(lcontract_num,2)
 if eof()
   return '1'
 ENDIF
 SELECT reffile
 SEEK lcontract_num
 if eof()
   return '2'
 ENDIF
 SELECT caplist
 SEEK upper(reffile->ref_number)
 if eof()
   return '3'
 ENDIF
 select capfile
 return 'Y'
ENDFUNC


FUNCTION FPcalc_cap_value
LPARAMETERS dbegcertbal, icap_code, iactpmttst
local cap_libor, cap_days
if iactpmttst <= 0  &&we're processing an actual payment
  if abs(dbegcertbal - capfile->begcertbal) > 0.90  &&begcertbal in capfile doesn't match passed value
    return -999.99
  endif
  m->cap_libor = capfile->act_libor
  m->cap_days  = capfile->act_days
  m->cap_days1 = capfile->act_days1
else
  m->cap_libor = capfile->proj_libor
  m->cap_days  = capfile->proj_days
  m->cap_days1 = capfile->proj_days1
endif


if icap_code = 1 &&calc Total cap pmt
 evalstmt = caplist->totcapcalc
 evalrslt = &evalstmt
 THIS.mTOTCAPPMT = evalrslt
endif
if icap_code = 2 &&calc Net cap pmt
 evalstmt = caplist->netcapcalc
 evalrslt = &evalstmt
 THIS.mNETCAPPMT = evalrslt
endif
if icap_code = 3 &&calc excess cap pmt
 evalstmt = caplist->exscapcalc
 evalrslt = &evalstmt
 THIS.mEXSCAPPMT = evalrslt
endif
return evalrslt
ENDFUNC

FUNCTION FPget_cap_value
LPARAMETERS icap_code
if icap_code = 1 &&calc Total cap pmt
 return capfile->actcappmt
endif
if icap_code = 2 &&calc Net cap pmt
 return capfile->netcappmt
endif
if icap_code = 3 &&calc excess cap pmt
 return capfile->exscappmt
endif
return -1
ENDFUNC

****************************************************
FUNCTION fpopen_loss_accel_dbf
LPARAMETERS lcname

xfile = substr(lcname,1,5)+"acc.dbf"
if !file(xfile)
 return 0
endif
select 0
use (xfile) alias accelloss
if reccount() = 0
 return 999    &&no loss records yet
endif
return payperiod &&return payperiod from first record so we know when first loss is to be applied
ENDFUNC

FUNCTION fpget_accel_loss
LPARAMETERS lrec
select accelloss
if reccount() < lrec   &&check to make sure selected record exists
  return -1.0
endif
goto lrec
return accel_loss
ENDFUNC

****************************************************

ENDDEFINE


ENTIRE THREAD

Build Com Problem Posted by Jeff Stone @ 11/10/2006 12:51:52 AM
RE: Build Com Problem Posted by Ken Murphy @ 11/10/2006 1:22:00 AM
RE: Build Com Problem Posted by Jeff Stone @ 11/10/2006 3:54:28 AM
RE: Build Com Problem Posted by Ken Murphy @ 11/10/2006 4:04:52 AM
RE: Build Com Problem Posted by Sweaty Broham @ 11/10/2006 4:41:45 AM
RE: Build Com Problem Posted by Salwan Ravi @ 12/1/2006 12:30:26 PM
RE: Build Com Problem Posted by Barbara Peisch @ 12/3/2006 1:52:58 AM
RE: Build Com Problem Posted by Salwan Ravi @ 12/6/2006 2:17:34 PM