Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursoradapter with field aliases
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01206438
Message ID:
01206635
Views:
22
John and Mike,


Yes I am using text endtext. Actually this on of my FAVORITE commands.

here is my builder so far.
Can anyone advise as to got teh code created into lcInstantiateData into the method "InstantiateData" of the class built at the end of the code
my aselobj stuff does not work. Right now I use _cliptext to paste manually
* Program....:  BUSINESS_BUILDER.PRG
* Version....: 
* Author.....: Peter A. Cortiel 
* Date.......: 03/20/07
* Notice.....: Copyright (c) 2007 ** PCS **, All Rights Reserved.
* Compiler...: Visual FoxPro 09.00.0000.5015 for Windows for Windows
* Abstract...: 
* 			..: 
* Changes....: 
*DODEFAULT() 
#INCLUDE kba.h 


lcInput1 = ALLTRIM(UPPER(INPUTBOX("Name of Update Table (Only one): ","Business_Builder")))
lcInput2 = INPUTBOX("Name of Library: ","Business_Builder")
IF EMPTY(lcInput2 )
	lcInput2 ="modules\vdmsiss.vcx"
ENDIF 
lcQueryName ="q"+lcInput1 +".QPR"
lcClassName ="o_"+lcInput1 
CREATE QUERY (lcQueryName )
** read in the query file:
lcQueryText =FILETOSTR(lcQueryName )

*************************************************************
** Get the select statement :
*************************************************************
lcSelectCmdFull =STRTRAN(STRTRAN(lcQueryText ,", ",",;"+CRLF),CRLF+"  ",CRLF)

x4_1=[]
** now put every field in its own line and every join also:
x4a=ALINES(la1,lcSelectCmdFull)
FOR I = 1 TO x4a
	x4_1= x4_1 + "'"+CHRTRAN( la1[i],",;",",") +" '+;" +crlf
ENDFOR 
lcSelectCmd =SUBSTR(x4_1,1,LEN(x4_1)-4)
*************************************************************


*************************************************************
** Get the KeyFieldList :
*************************************************************
lcKeyFieldList =SUBSTR(UPPER(JUSTSTEM(lcQueryName)),2) +"_ID"


*************************************************************
** Get the UpdateFieldList :
*************************************************************
x5=ALLTRIM( STREXTRACT(lcSelectCmdFull ,"SELECT","FROM "))
x5a=ALINES(la1,x5)
?x5a
x5b=[]
FOR I = 1 TO x5a
	xLine=UPPER(ALLTRIM(la1[i]))
	IF " AS "$xLine
		x1=STREXTRACT(xLine,"", " AS ")
		x2=STREXTRACT(xLine," AS ",",")
		xLine=JUSTSTEM(x1)+"."+x2+",;"

	ENDIF 
	x5b =x5b+ "'"+STRTRAN(GETWORDNUM(xLine,2,"."),";","'+; ")+CRLF
	*x5b = x5b + CHRTRAN( x5c,",;","") + " "+ CHRTRAN(la1[i],";","") 

ENDFOR 
lcUpdateFieldList=SUBSTR(x5b,1,LEN(x5b)-5)


*************************************************************
** Get the From List :
*************************************************************
x6=STRTRAN(ALLTRIM( STREXTRACT(lcSelectCmdFull ,"FROM ;"+CRLF,"ORDER BY",1,3)),";"+CRLF+" ON "," ON ")


*************************************************************
** Get the UpdateNameList :
*************************************************************
x5=ALLTRIM( STREXTRACT(lcSelectCmdFull ,"SELECT","FROM "))
x5a=ALINES(la1,x5)
x5b=[]
FOR I = 1 TO x5a
	xLine=UPPER(ALLTRIM(la1[i]))
	IF " AS "$xLine
		x1=STREXTRACT(xLine,"", " AS ")
		x2=STREXTRACT(xLine," AS ",",")
		xLine=JUSTSTEM(x1)+"."+x2
	ELSE 
		xLine=ALLTRIM(STREXTRACT(xLine,"", ",;"))
	
	ENDIF 
	IF I < x5a
		xLine=JUSTEXT(xline)+" "+xLine+",'+;"
	x5b = x5b + "'"+xLine +CRLF
	ELSE 
		xLine=JUSTEXT(xline)+" "+xLine+"'"
	x5b = x5b + "'"+xLine 
	ENDIF 

ENDFOR 
lcUpdateNameList = SUBSTR(x5b,1,LEN(x5b)-9)+"'"

TEXT TO lcInstantiateData  NOSHOW TEXTMERGE PRETEXT 3 FLAGS 3
	LPARAMETERS tlCursorOnly
	
	DECLARE this.aExtraParam[4]

	this.aExtraParam[1]=;
	<<lcSelectCmd >>


	this.aExtraParam[2]='<<lcKeyFieldList>>'



	this.aExtraParam[3]=;
	<<lcUpdateFieldList>>


	this.aExtraParam[4]=;
	<<lcUpdateNameList>>

	DODEFAULT(tlCursorOnly)

ENDTEXT
_cliptext=lcInstantiateData 



CREATE CLASS (lcClassName) OF (lcInput2 )AS Business FROM ..\kbabase\business\business.vcx NOWAIT


*!*	x=aselobj(la1)
*!*	la1.dstype="VFPCA"
*!*	la1.dataalias=lcInput1
*!*	la1.cursoralias="cur"+lcInput1 
*!*	SUSPEND 
thanks

Peter
Peter Cortiel
Previous
Reply
Map
View

Click here to load this message in the networking platform