Wiki Home

Vue Snk


Namespace: WIN_COM_API
* program: VueSnk.prg - synchronizes properties of view fields with the props of the fields in the base tables
* by: CarlKarsten

lcApp = "\vfe6\dev\yadd\"
lcDbc = "yadd"

xVueSnk( lcApp + "data\" + lcDbc + ".dbc", "Caption" )

return
*************************************************************************
function xVueSnk( tcPnmDbc, tcProp )

* Syncronize a views property with its base table, based on the update prop.

local ;
	lnVues, laVues(1), lcVue

activate screen
clear

open database (tcPnmDbc)

lnVues = aDbObjects( laVues, "view" )
for each lcVue in laVues
	lOneVue( lcVue, tcProp )
endfor

close database

return
*************************************************************************
function lOneVue( tcVue, tcProp )
* Process one View

local ;
	lnFldNo

use (tcVue) nodata

for lnFldNo = 1 to fcount()
	lOneFld( tcVue, field( lnFldNo ), tcProp )
endfor

return
*************************************************************************
function lOneFld( tcVue, tcFld, tcProp )
* Process one Field

local ;
	lcUpdNam, ;
	lcBasCap

lcUpdNam = dbGetProp( tcVue + "." + tcFld, "field", "UpdateName" )

* This is the only way I could figure out if we can get to the base field.
if "." $ lcUpdNam

	if "!" $ lcUpdNam
		lcUpdNam = substr( lcUpdNam, at( "!", lcUpdNam ) + 1 )
	endif
	lSnkOne( lcUpdNam, tcVue, tcFld, tcProp )

endif

return
*************************************************************************
function lSnkOne( tcUpdNam, tcVue, tcFld, tcProp )

local lcBasVal

* Get the property value of the field the view field would update
lcBasVal = dbGetProp( tcUpdNam, "field", tcProp )
* Set the view field's property
llSet = dbSetProp( tcVue + "." + tcFld, "field", tcProp, lcBasVal )
assert llSet

? tcVue, tcFld, tcUpdNam, tcProp, lcBasVal

return
*************************************************************************
*************************************************************************

Category Code Samples
( Topic last updated: 2000.04.09 07:12:48 PM )