Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Default Control Class for Views
Message
 
To
11/04/1998 10:17:31
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00091015
Message ID:
00091354
Views:
37
Hey Myron,

Though I haven't had a chance to place with it yet....THANKS!

I'm sure a lot of people will appreciate you posting that code.

>I have a routine that calls the following program for every view in the DBC. I run this anytime I make any DBC changes. This way my view stay in sync with my tables. It work best with single table views.
>
>-myron kirby-
>myronk@flash.net
>
>---------------------------------------------------------------------------------------------------------
>
>* ==========================================================================
>* Method: y1View(tcView, tcFunc)
>* Description: Sets view table/field properties.
>* Used in creating views.
>* Parameters: tcView = View name
>* tcFunc = Function to perform
>* = [TABLE] - Set view table properties
>* = [FIELD] - Set view field properties
>* Returns: n/a
>* Other: Kirby Utility
>* --------------------------------------------------------------------------
>* Modifications:
>* ==========================================================================
>
>*--Set-Up ............................................................
>LPARAMETER;
> tcView,;
> tcFunc
>
>LOCAL;
> lcFunc ,;
> lnSelect
>
>PRIVATE;
> pcDbc ,;
> pcView ,;
> plWarning ,;
> pnFldCount
>
>pcView = UPPER(ALLTRIM(y1CkParm(tcView))) && View name
>lcFunc = UPPER(ALLTRIM(y1CkParm(tcFunc))) && Function to perform
>
>pnFldCount = 0 && # of flds in view
>lnSelect = SELECT() && Currently selected work area
>pcDbc = SET([DATABASE]) && Database name
>plWarning = .F. && Indicates had warning
>
>
>*--Processing ........................................................
>CLEAR
>
>*--Determine function to perform
>DO CASE
>CASE USED(pcView) = .F. && View must be open
> WAIT WINDOW;
> PROGRAM() + [ -- View must be open.] + CHR(13) +;
> [--> View: ] + pcView
>CASE lcFunc == [TABLE] && Table functions
> =DoPropsTable() && Set view table properties
>CASE lcFunc == [FIELD] && Field functions
> =DoPropsFld() && Set view field properties
>OTHERWISE
> WAIT WINDOW;
> PROGRAM() + [ -- Invalid function requested.] + CHR(13) +;
> [--> View: ] + pcView + CHR(13) +;
> [--> Func: ] + lcFunc
>ENDCASE
>
>
>*--Clean-Up ..........................................................
>IF plWarning = .T. && Had warning, issue warning
> =y1Msg01(;
> [Review the warning messages!],;
> [View Processing -- ] + pcView,;
> [I])
>
>ENDIF && ..IF plWarning = .T.
>
>SELECT (lnSelect) && Restore original work area
>WAIT CLEAR
>CLEAR
>
>RETURN .T.
>* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>* --------------------------------------------------------------------------
>* FUNCTION: DoPropsTable()
>* DESCRIPTION: Set view table properties
>* PARAMETER: n/a
>* RETURNS: n/a
>* --------------------------------------------------------------------------
>
>FUNCTION DoPropsTable
>
>WAIT CLEAR
>WAIT WINDOW NOWAIT;
> [Updating table properties:] + CHR(13) +;
> [--> ] + pcView
>
>=DBSetProp( pcView, [View], [UpdateType], 1 )
>=DBSetProp( pcView, [View], [WhereType], 3 )
>=DBSetProp( pcView, [View], [FetchMemo], .T. )
>=DBSetProp( pcView, [View], [SendUpdates], .T. )
>=DBSetProp( pcView, [View], [UseMemoSize], 255 )
>=DBSetProp( pcView, [View], [FetchSize], 100 )
>=DBSetProp( pcView, [View], [MaxRecords], -1 )
>
>RETURN .T.
>* eof(DoPropsTable) ........................................................
>
>
>* --------------------------------------------------------------------------
>* FUNCTION: DoPropsFld()
>* DESCRIPTION: Set view field properties
>* PARAMETER: n/a
>* RETURNS: n/a
>* --------------------------------------------------------------------------
>
>FUNCTION DoPropsFld
>
>WAIT CLEAR
>WAIT WINDOW NOWAIT;
> [Updating field properties:] + CHR(13) +;
> [--> ] + pcView
>
>SELECT (pcView)
>
>LOCAL ;
> lcFldProp ,;
> lcVFldName,;
> lcTFldName,;
> lnFldCnt ,;
> lnX ,;
> lxPropVal
>
>lnFldCnt = FCOUNT() && Number of fields in view
>
>*--Process each field in the view
>FOR lnX = 1 TO lnFldCnt
> * Update the following field properties
>
> =SetFldProp(lnX, [Updatable], .T.) && Whether field is updatable
> =SetFldProp(lnX, [Comment]) && Field comment property
> =SetFldProp(lnX, [DefaultValue]) && Field default value
> =SetFldProp(lnX, [RuleExpression]) && Field rule expression
> =SetFldProp(lnX, [RuleText]) && Field rule text
>
> *--The following line must be the last property changed
> =SetFldProp(lnX, [UpdateName]) && Update field name
>ENDFOR
>
>RETURN .T.
>* eof(DoPropsFld) ..........................................................
>
>
>* --------------------------------------------------------------------------
>* FUNCTION: SetFldProp(tnVFldNmbr, tcFldProp)
>* DESCRIPTION: Set specific view field properties
>* PARAMETER: tnVFldNmbr = View field number
>* tcFldProp = View field property to update
>* txPropVal = Property value (if not passed, it uses
>* the corresponding property from the table)
>* RETURNS: n/a
>* --------------------------------------------------------------------------
>
>FUNCTION SetFldProp
>
>LPARAMETER;
> tnVFldNmbr,;
> tcFldProp ,;
> txPropVal
>
>LOCAL ;
> lcFldProp ,;
> lcVFldName,;
> lcTFldName,;
> lnParms ,;
> lnVFldNmbr,;
> lxPropVal
>
>lnParms = PARAMETERS() && Number of parameters passed
>lnVFldNmbr = tnVFldNmbr
>lcFldProp = UPPER(ALLTRIM(tcFldProp))
>lxPropVal = txPropVal && Property value
>
>lcVFldName = ALLTRIM(pcView + [.] + FIELD(lnVFldNmbr)) && View fld
>lcTFldName = ALLTRIM(DBGetProp(lcVFldName, [Field], [UpdateName])) && Table fld
>
>DO CASE
>CASE ! ([.] $ lcTFldName) && Do not have qualified table fld name
> plWarning = .T. && Had warning
>
> ? [** NOT SET: Not qualified table field name: ] +;
> pcView +;
> [ -- ] +;
> lcTFldName +;
> [ -- ] +;
> lcFldProp
>
>CASE lcFldProp == [UPDATENAME] && Special process for 'UpdateName'
> lxPropVal = pcDbc + [!] + lcTFldName
>CASE lnParms >= 3 && Property value was passed
> lxPropVal = lxPropVal
>OTHERWISE && Normal routine
> lxPropVal = DBGetProp(lcTFldName, [Field], lcFldProp)
>ENDCASE
>
>IF ! EMPTY(lxPropVal) && Only set is there is a property
> =DBSetProp(lcVFldName, [Field], lcFldProp, lxPropVal)
>
> *!* WAIT WINDOW;
> *!* lcVFldName + [ -- ] + lcTFldName + CHR(13)+;
> *!* lcFldProp + [ == ] +lxPropVal
>ENDIF
>
>RETURN .T.
>* eof(SetFldProp) ..........................................................
>
>
>---------------------------------------------------------------------------------------------------------
>
>
>>Hey Myron,
>>
>>Yeah, that'll work, BUT I'd still like to see them populate automatically. BTW, would you mind listing that code for all the world to see?
>>
>>Thanks....
>>
>>>You can also create a generic utility to automatically sequence thru all the fields in your view and update the view properties from the table properties. Works real well with single table
>>>views. Basically use DBGetProp & DBSetProp.
>>>
>>>-myron kirby-
>>>myronk@flash.net
>>> -------------------------------------------------------------------
>>>>That was added in VFP 5.0. Although I kinda wish that the properties for the fields would automatically be populated for the view, they're not. If I recall, if you've set up all your default values, input mask and so on for your fields, you've got to do it again in the view...yuck!
Jim Duffy
Microsoft MVP
INETA Speaker
TakeNote Technologies
Developer's Choice Award Winner for Best Training Company
Specializing in VB.NET, ASP.NET, VFP, and SQL Server Training and Development
Previous
Reply
Map
View

Click here to load this message in the networking platform