# ViewCtl

> Source: https://manual.pvxplus.com/views-system/views-definition-object/viewctl

**ViewCtl** is the main interface object. The following alphabetically arranged list of properties and methods belongs to the **ViewCtl** object:

|  |  |  |  |
| --- | --- | --- | --- |
|  | **[AddDataGroup](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark7)** | **[GetDataSource( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark33)** | **[RemoveFromDataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark59)** |
|  | **[AddDataSource( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark8)** | **[GetDataSourceIDs$(](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark34) )** | **[RemoveItem( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark60)** |
|  | **[AddItem( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark9)** | **[GetGroupID$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark35)** | **[RemoveLink( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark61)** |
|  | **[AddLink( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark10)** | **[GetImportList$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark36)** | **[Save( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark62)** |
|  | **[AddView( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark11)** | **[GetItem( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark37)** | **[SetCloseLogic( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark63)** |
|  | **[AssignToDataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark12)** | **[GetItemCount( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark38)** | **[SetCondition( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark64)** |
|  | **[ChangeDataGroupDescription( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark13)** | **[GetLink( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark39)** | **[SetDescription( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark65)** |
|  | **[CheckDuplicateDescription$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark14)** | **[GetNextKeyID$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark40)** | **[SetDescription$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark66)** |
|  | **[Clear( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark15)** | **[GetType$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark41)** | **[SetDirectory( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark67)** |
|  | **[ClearGroups( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark16)** | **[GetView( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark42)** | **[SetExecutionLogic( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark68)** |
|  | **[CloseLogic$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark17)** | **[GetViewCount( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark43)** | **[SetFilter( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark69)** |
|  | **[CloseLogicType$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark18)** | **[Import( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark44)** | **[SetImport( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark70)** |
|  | **[Copy( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark19)** | **[InitLogic$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark45)** | **[SetInitLogic( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark71)** |
|  | **[CopyDataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark20)** | **[InitLogicType$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark46)** | **[SetInternalKeyCode( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark72)** |
|  | **[DataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark21)** | **[InternalKeyCode$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark47)** | **[SetLogicObject( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark73)** |
|  | **[DataSource( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark22)** | **[List$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark48)** | **[SetUnassignedMessage( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark74)** |
|  | **[Delete( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark23)** | **[ListByGroup$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark49)** | **[TranslatePath$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark75)** |
|  | **[DeleteDataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark24)** | **[ListGroupMembers$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark50)** | **[UnassignedMessage$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark76)** |
|  | **[DeleteFromDataGroup$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark25)** | **[ListMemberGroups$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark51)** | **[UserLogic](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark77)** |
|  | **[Disable( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark26)** | **[Load( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark52)** | **[VError](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark78)** |
|  | **[ExecutionLogic$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark27)** | **[LoadDataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark53)** | **[VError$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark79)** |
|  | **[ExecutionLogicType$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark28)** | **[LogicObject$](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark54)** | **[ViewDef( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark80)** |
|  | **[Export( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark29)** | **[OpenLink( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark55)** | **[ViewMessage$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark81)** |
|  | **[FindOrphans( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark30)** | **[Print( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark56)** | **[ViewsDirectory$( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark82)** |
|  | **[GetDataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark31)** | **[Remove( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark57)** | **[WriteDataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark83)** |
|  | **[GetDataGroupCount( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark32)** | **[RemoveDataGroup( )](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark58)** |  |

Full descriptions of all **[ViewCtl Properties](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#viewctl_properties)** and **[ViewCtl Methods](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#viewctl_methods)** (grouped according to functionality) are provided below.

For descriptions of the different individual objects, see **[ViewDef](https://manual.pvxplus.com/views-system/views-definition-object/viewdef)**, **[ViewItem](https://manual.pvxplus.com/views-system/views-definition-object/viewitem)**, **[DataGroup](https://manual.pvxplus.com/views-system/views-definition-object/datagroup)**, **[DataSource](https://manual.pvxplus.com/views-system/views-definition-object/datasource)**, **[DS_Item](https://manual.pvxplus.com/views-system/views-definition-object/ds-item)** and **[DS_Link](https://manual.pvxplus.com/views-system/views-definition-object/ds-link)**.

## ViewCtl Properties

The following table lists the properties of the **ViewCtl** object, as well as groups of subordinate objects:

| **Property** | **Description** |
| --- | --- |
| **CloseLogic$** | Logic to be executed prior to exiting the Views System. See **[Logic Procedures](https://manual.pvxplus.com/views-system/logic-procedures/overview)**. |
| **CloseLogicType$** | Same as for **InitLogicType$**. |
| **ExecutionLogic$** | Logic to be executed prior to retrieving data. See **[Logic Procedures](https://manual.pvxplus.com/views-system/logic-procedures/overview)**. |
| **ExecutionLogicType$** | Same as for **InitLogicType$**. |
| **InitLogic$** | Logic to be executed upon entering the Views System. Reference based on **InitLogicType$**.  <br>  <br>If type C, **InitLogic$** contains *program;entrypoint*.  <br>  <br>If type X, **InitLogic$** contains PxPlus statement(s) to be executed. String, 128 characters.<br>See **[Logic Procedures](https://manual.pvxplus.com/views-system/logic-procedures/overview)**. |
| **InitLogicType$** | Single character string indicating logic type:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| C \| Call \|<br>\| X \| Execute \|<br>\| I or blank \| Ignore ***(Default)*** \| |
| **InternalKeyCode$** | Internal key code to be used as the three-character prefix for internal ID values for new views, data sources, items, links and groups.<br>If the given code is not three characters long, it will be left justified and padded on the right with spaces. Default value is 000. Use **SetInternalKeyCode(** **)** method to set. |
| **LogicObject$** | Object specified to supply logic references. See **[Logic Procedures](https://manual.pvxplus.com/views-system/logic-procedures/overview)**. |
| **UnassignedMessage$** | Message to be used for the default data group to which views and data sources belonging to no data group are assigned. Use **SetUnassignedMessage(** **)** method to set. |
| **UserLogic** | Object identifier for **LogicObject$**. |
| **VError** | Code number indicating the type of error that caused a method to fail.<br>For code details, use the **VError$( )** method or see **[VError Codes](https://manual.pvxplus.com/views-system/views-definition-object/verror-codes)**. |
| **ViewMessage$** | String to be prefixed to a view description; e.g. "View:". |
| **ViewsDirectory$** | Directory in which to access the Views definition files (*pvxview.\**). If blank, normal search rules will apply. Read only. Set using **SetViewsDirectory(** **)**. |
| ***The following are local object Groups*** (**\*obj/group**) ***that define lists of related objects:*** |  |
| **DataGroup** | Standard group list of **DataGroup** objects. One object for each data group to which the views and data sources in memory belong. |
| **DataSource** | Standard group list of **DataSource** objects, including the primary and related data sources. |
| **ViewDef** | Standard group list of **ViewDef** objects. One object for each view. |

## ViewCtl Methods

The tables below group different **ViewCtl** methods according to their functionality. Use the following links to jump to a particular group of methods:

|  |  |
| --- | --- |
|  | [Loading and Manipulating Definitions in Memory](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark1) |
|  | [Saving Definitions](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark2) |
|  | [Direct Access to Definition Files (Update Methods)](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark3) |
|  | [Direct Access to Definition Files (Retrieval Methods)](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark4) |
|  | [Export and Import Methods](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark5) |
|  | [Miscellaneous Methods](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#Mark6) |

***Loading and Manipulating Definitions in Memory***

These load and manipulate the **ViewCtl** object and its subordinate objects in memory. They do not affect the *pvxview.\** definition files. To commit any changes to the definition files, invoke the **Save( )** method.

| **Method** | **Description** |
| --- | --- |
| AddDataGroup(*GrpDesc$***)** | Create/name new group definition. |
| AddDataSource(*SrcType$***,** *SrcName$***\[,** *ExprFlg$* **\])** | Create a **DataSource** object and initialize its properties with information based on the source.  <br>  <br>Source type indicator:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| L \| PxPlus file identified by logical name \|<br>\| P \| PxPlus file identified by path name or prefix file reference to an external database table (PxPlus SQL ODBC Driver, ADO, Oracle, MySQL or DB2) \|<br>\| O \| Custom data source object \|<br>\| T \| External database table \|<br>*SrcName$* will vary depending on *SrcType$*: logical file name (L), PxPlus file name/path or prefix file reference to an external database table (P), object name;tableID (O), or (T) open string for the database table composed of the database file tag (\[ODB\], \[DB2\], \[OCI\]) followed by *DSN; table_name;**KEY***= *KeyDef* \[; *other_connection_strings* \]:   <br>  <br> \[ODB\]Northwind;Customers;KEY=Custo merID;KEY=CompanyName   <br>  <br>If the database is located on a WindX client, the \[WDX\] tag may be prefixed to *SrcName$*.  <br>  <br>*ExprFlg$* indicates whether *SrcName$* contains an expression that must be evaluated. ""(*null*) indicates that *SrcName$* contains fixed value *(default)* and an "=" indicates an expression to be evaluated. No **DS_Item** or **DS_Link** objects are created. |
| AddItem(*SrcObjID* **\|** *SrcDesc$***\[,** *ColName$* **\|** " **\*** " **\])** | Add a new **DS_Item** object to the specified data source. If a column name (no trailing "$") is specified, the object is initialized with information derived from the data source driver. If an \**asterisk* is supplied, all columns in the source will be added. |
| AddItem(*VuObjID* **\|** *VuDesc$***,** *ItemPath$***)** | Add a new **ViewItem** to the specified view, based on the item path. The sequence of the **ViewItem** objects will be adjusted automatically to ensure they are grouped by their linkage path. |
| AddLink(*PSrcDesc$***,** *LSrcDesc$***,** *kno$***,** *KeyDef$*)   <br>AddLink(*PSrcObjID*, *LSrcObjID*, *kno$***,** *KeyDef$***)** | Create a new **DS_Link** object based on the specified parent data source and link source.  <br>  <br>*kno$* is the key number, and *KeyDef$* is the Key expression to read the linked data source. |
| AddView(*DS_Desc$* **\|** *SrcObjID*) | Create a **ViewDef** object based on the specified data source. If the data source is not currently in memory, it gets loaded. |
| AssignToDataGroup(*Desc$***,** *DataGroup$*)   <br>AssignToDataGroup(*SrcObjID*, *GrpObjID*) | Assign specified view or data source to a data group. |
| CheckDuplicateDescription$(*ObjID*, *Desc$***)** | Checks if the description of the view, data source, item, link, or data group has already been used and returns an alternate unused description using a numeric suffix; e.g. Client(2). |
| **Clear(** **)** | Re-initialize the **ViewCtl** definition and delete all subordinate objects created by it. (Does not change **ViewsDirectory$( )** or **InternalKeyCode$**.) |
| Clear(*SrcObjID*) | Re-initialize the specified **ViewDef** or **DataSource** object and delete all subordinate objects. |
| **ClearGroups( )** | Removes all **DataGroup** objects. |
| GetDataGroup(*GroupDesc$* **\|** *idx*) | Return the object identifier for the specified **DataGroup** object. |
| **GetDataGroupCount( )** | Return the number of **DataGroup** objects. |
| GetDataSource(*DS_Desc$* **\|** *idx*) | Return the object identifier for the specified **DataSource** object. |
| **GetDataSourceCount( )** | Return the number of **DataSource** objects. |
| GetItem(*ObjID*, *idx*) | Return the **ViewItem** or **DS_Item** object identifier. |
| GetItem(*SrcObjID*, *ItemName$* **\|** *ItemDesc$***)** | Return the **ViewItem** object identifier of the item with the given name or description. |
| GetItem(*VuObjID*, *ItemPath$* **\|** *ColumnName$***)** | Return the **ViewItem** object identifier of the view item which has the given path or column name (no trailing "$"). |
| GetItem(*ItemPath$***)** | Return the **ViewItem** object identifier for the item. |
| GetItemCount(*ObjID*) | Return the number of **ViewItem** or **DS_Item** objects in the specified **ViewDef** or **DataSource** object. |
| GetLink(*SrcObjID*, *idx*)  <br>GetLink(*SrcObjID*, *LnkDesc$*)  <br>GetLink(*LinkPath$***)** | Return the **DS_Link** object identifier. |
| GetView(*ViewDesc$* **\|** *idx*) | Return the object identifier for the specified **ViewDef** object. |
| **GetViewCount( )** | Return the number of **ViewDef** objects. |
| Load(*Name$***)** | Create a **ViewDef** or **DataSource** object and load it using information from the views definition files. Also creates and loads all related items, links and groups.<br>Note:  <br>If a view is loaded that has items referencing fields from linked files that do not exist on the system, the items will not be loaded and no error will be generated. |
| LoadDataGroup(*GrpDesc$***)** | Create a **DataGroup** object and load with information from the views definition files. |
| OpenLink(*ObjID* **\|** *LinkPath$***)** | Load the data source used in the link. |
| Remove(*Name$***)** | Remove the specified **ViewDef** or **DataSource** object and subordinate objects from memory.  <br>  <br>In the case of **DataSource** objects, the following are also removed:  <br>  <br> \- Any **ViewDef** objects using the **DataSource** as its primary data source.  <br> \- Any **ViewItem** objects referencing the data source items.  <br> \- Any **DS_Link** objects using the object as its source. |
| RemoveDataGroup(*GrpDesc$* **\|** *idx*) | Remove the specified **DataGroup** object from memory. |
| RemoveFromDataGroup(*Desc$***,** *GrpDesc$*)  <br>RemoveFromDataGroup(*SrcObjID*, *GrpObjID*) | Remove the specified view or data source from a data group. |
| RemoveItem(*ObjID*, *idx*)  <br>RemoveItem(*SrcObjID*, *ItemDesc$* **\|** *ItemName$***)**  <br>RemoveItem(*VuObjID*, *ItemPath$* **\|** *ColName$***)** | Remove a **ViewItem** or **DS_Item** object.   <br>  <br>In the case of removal of a **DS_Item** object, any **ViewItem** objects referencing the item will also be removed. |
| RemoveLink(*SrcObjID*, *LinkDesc$* **\|** *idx*) | Remove a **DS_Link** object. Also removes any **ViewItem** objects referencing the link. |
| SetCloseLogic(*Type$, Logic$***)** | Set **CloseLogic$**. |
| SetCloseLogic(*SrcObjID, Type$, Logic$***)** | Set closing logic for a **ViewDef** or **DataSource** object. |
| SetCondition(*VuObjID*, *ItmPath$***,** *Code*, *Case* **\[,** *v1$...v8$*\])  <br>SetCondition(*VuObjID*, *Column$***,** *Code*, *Case* **\[,** *v1$*...*v8$***\])** | Set a filter condition at the view item level.   <br>  <br>*ItmPath$/Column$* (no trailing $) - Used to identify the view item.<br>\|  \|  \|  \|<br>\| --- \| --- \| --- \|<br>\| *Code -* Condition indicator code: \|  \|  \|<br>\| 1 \| Equal to \<Value1> \|  \|<br>\| 2 \| Not equal to \<Value1> \|  \|<br>\| 3 \| Less than \<Value1> \|  \|<br>\| 4 \| Greater than \<Value1> \|  \|<br>\| 5 \| Less than or equal to \<Value1> \|  \|<br>\| 6 \| Greater than or equal to \<Value1> \|  \|<br>\| 7 \| Between \<Value1> and \<Value2> inclusive \|  \|<br>\| 8 \| Between \<Value1> and \<Value2> exclusive \|  \|<br>\| 9 \| Any of \<Value1>,\<Value1>, …\<Value1> \|  \|<br>\| 10 \| None of \<Value1>,\<Value1>, …\<Value1> \|  \|<br>\| 11 \| Contains \<Value1> \|  \|<br>\| 12 \| Starts with \<Value1> \|  \|<br>\| *Case -* Case sensitivity indicator: \|  \|  \|<br>\| 0 \| Not case sensitive \|  \|<br>\| 1 \| Case sensitive \|  \|<br>*v1$...v8$* - Values to be used in comparison. Pass numeric values as string arguments.<br>Note:  <br>View item-level filters are analyzed at run time to optimize data retrieval by determining key ranges for reading records. |
| SetDescription(*ObjID*, *Description$***)** | Set the *Description$* property of any **ViewCtl** subordinate object. Checks for duplicate descriptions in the views definition files and in memory. Fails if the description is a duplicate. |
| SetDescription$(*ObjID*, *Description$***)** | Set the *Description$* property of any **ViewCtl** subordinate object. Checks for duplicate descriptions in the views definition files and in memory. If the description is a duplicate, a unique description will be created and set using the **CheckDuplicateDescription** **$( )** method. The value of *Description$* will be returned. |
| SetDirectory(*Directory$***)** | Set the directory in which the views definition files are located and open them. Will add a trailing delimiter to the **ViewDirectory$** property if omitted. Also clears the **ViewCtl** object of all subordinate objects. |
| SetExecutionLogic(*Type$, Logic$***)** | Set **ExecutionLogic$**. |
| SetFilter(*VuObjID*, *Condition$***)** | Set the filter to be applied at the view level.<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Condition$* \| A free-form PxPlus expression that can be evaluated as true (**1**) or false (**0**). Variables used in the condition must be the column names assigned to the view items. The condition may be a simple condition or a complex condition using **AND** and **OR** logical operators:  <br>  <br> CustType$="C" OR CustBalance>1000 \|<br>Note:   <br>View-level filters are not analyzed at run time to optimize data retrieval by determining key ranges for reading records. If the filter you are setting could be used for optimization purposes, see if you can set a similar condition at the view item level using the SetCondition( ) method. |
| SetInitLogic(*Type$, Logic$* **\[,** *A$* **\])** | Set **InitLogic$**. Set A$ to "A" to apply immediately. |
| SetInitLogic(*SrcObjID, Type$, Logic$***)** | Set initialization logic for a **ViewDef** or **DataSource** object. |
| SetInternalKeyCode(*Code$***)** | Set the internal key code to be used as the three-character prefix for internal ID values for new views, data sources, items, links and groups. If the given code is not three characters long, it will be left justified and padded on the right with spaces. ***Default*** value is 000. |
| SetLogicObject(*ObjID, ObjNm$***)** | Set logic object for a **ViewDef** or **DataSource** object. |
| SetLogicObject(*ObjNm$* \[, *A$* \]**)** | Set **LogicObject$**. Set A$ to A to apply immediately. |
| SetUnassignedMessage(*Message$***)** | Set the message to be used for the default data group to which views and data sources belonging to no data group are assigned. |
| TranslatePath$(*Path$* \[,*PathType$***\])** | Translates an **ItemPath$** or **LinkPath$** from the descriptive format to the format using object identifiers, used by the **ViewDef** and **ViewItem** objects.<br>\|  \|  \|  \|<br>\| --- \| --- \| --- \|<br>\| *Path$* \| Descriptive path \|  \|<br>\| *PathType$* \| Indicates the type of path: \|  \|<br>\|  \| I or *null* \| Path is an **ItemPath$** **(*Default*)** \|<br>\|  \| L \| Path is a **LinkPath$** \|<br>Returns a string composed of **DS_Link** and **DS_Item** object identifiers.<br>Note:   <br>This method will open all links (i.e. load the related data sources) used in the path. |

*LinkPath$* - *PrimarySourceDesc$* +SEP \[+ *LinkDesc$* +SEP...\]
*ItemPath$* - *PrimarySourceDesc$* +SEP \[+ *LinkDesc$* +SEP...\]+ *DS_ItemDesc$* (or *DS_ItemName$*)

***Saving Definitions***

The **Save( )** method commits the definition held in memory by the **ViewCtl** object to the *pvxview.\** definition files. It resolves **UpdateStamp$** fields, as well as the internal identifiers in memory, for any new objects created using an **Add *xxx*( )** method. (Internal identifiers are the internal keys used by the views definition files.)

| **Method** | **Description** |
| --- | --- |
| Save(\[*ObjID*\]) | Commit the definition in memory to the views definition files. Save the definition of the specified view, data source or group, as well as any subordinate items, links and groupings.   <br>  <br>If an object identifier is not specified, save *all* view and data source definitions in memory, including their subordinate items, links and groupings. |
| GetNextKeyID$(*Channel*) | Return the next available internal ID for the specified file (used internally by the **Save(** **)** method). |

***Direct Access to Definition Files (Update Methods)***

The following **ViewCtl** methods directly update the pvxview.\* definition files without affecting any view definitions currently in memory:

| **Method** | **Description** |
| --- | --- |
| ChangeDataGroupDescription(*Old$, New$***)** | Change the description of an existing group.<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Old$* \| Group description to be changed. \|<br>\| *New$* \| New description to be assigned. \| |
| Copy(*Name$, NewName$* \[, *Group$*\]**)** | Copy view or data source definition (header, items and optional group assignments, if *Group$* is specified).<br>Note:  <br>When a view is copied, the password is not copied. |
| CopyDataGroup(*FromGrp$*, *ToGrp$* \[, *Flag$*\]**)** | Copy members from one data group to another. If the group being copied to does not exist, it will be created.<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Flag$* \| Indicator to clear members from the receiving group before copying. \|<br>\| "" *null* \| Do not clear the existing group members. ***(Default)*** \|<br>\| C \| Clear existing group members. \| |
| Delete(*ViewDesc$* \| *DS_Desc$***)**<br>Delete(*InternalID$, Type$***)** | Deletes a view or data source definition. Can also be based on *InternalID* (i.e. *Src_ID$*) and *Type$* ("D" = Data source, "V" = View).   <br>  <br>***Views:***  <br> \- Header record from pvxview.src  <br> \- View items from pvxview.vue  <br> \- Group assignments from pvxview.gpd  <br> \- Record from providex.ddf  <br>  <br>***Data Sources:***   <br> \- Header record from pvxview.src  <br> \- Data source elements  <br> \- Link references  <br> \- Group assignments from pvxview.gpd  <br> \- *Does not delete views references to data source* |
| DeleteDataGroup(*GroupDesc$***)** | Delete the specified group definition. If any views or data sources are "orphaned" by the deletion of the group, they will be placed in the default or unassigned group. |
| DeleteFromDataGroup$(*GrpDesc$*, *Desc$***)** | Delete the specified view or data source from the data group. |
| Disable(*DS_Desc$***)** | Flag the data source as disabled: Set SRC_TYPE$ field in *pvxview.src* header to "D" and delete group assignments from *pvxview.gpd*. Does not remove items or link/view references. |
| **FindOrphans(** **)** | Find views and data sources that do not belong to a data group and put them in the default data group. |
| WriteDataGroup(*GrpDesc$*, *SrcList$* \[, *Flag$*\]**)** | Add the views and data sources in the list to the group.<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *ScrList$* \| List of view and data source descriptions separated by SEP \|<br>\| *Flag$* \| Indicator to clear existing group relationships first \|<br>\| " " *null* \| Do not clear existing group relationships \|<br>\| C \| Clear existing group relationships \| |

***Direct Access to Definition Files (Retrieval Methods)***

The following **ViewCtl** methods retrieve information directly from the *pvxview.\** definition files without regard for any view definition currently in memory:

| **Method** | **Description** |
| --- | --- |
| GetDataSourceIDs$(*ViewDesc$***)** | Returns a SEP-separated string containing the internal ID's of all data sources referenced in the view specified by *ViewDesc$*, or a null string if an error occurs.  <br>  <br>If the view references a link whose link record is missing, then the ID for the data source associated with the missing link is listed as "00000000". |
| GetGroupID$(*GrpDesc$***)** | Returns the internal ID (*Grp_ID$*) of the specified group. Useful for determining if a group exists. Returns "" (null) if the group does not exist. |
| GetType$(*Desc$***)** | Returns the *SourceType$* of the specified view or data source. |
| **List$(** )  <br>List$(*Type$*,\[*Bmp1$* \[*Bmp2$*\]\]**)** | Returns a $00$ separated list of views and/or data sources in alphabetic order.<br>The *Type$* indicator will determine what is returned:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| A \| Views and data sources ***(Default)*** \|<br>\| D \| Data sources \|<br>\| V \| Views \|<br>\| G \| Groups \|<br>Bitmap references are:  <br>  <br> *Bmp1$* = Bitmap for data source (e.g. "!File" ), or views (e.g. "!Grid" ) if *Type$* ="V"  <br> *Bmp2$* = Bitmap for views (e.g. "!Grid" ) if *Type$* ="A"  <br>  <br>If bitmap references are included, the format for each item in the return value will be:  <br>  <br> Bmp$+SEP+Description$+$00$  <br>  <br>The return value is suitable for display in a List Box. |
| **ListByGroup$(**\[*Type$*\])  <br>ListByGroup$(*Type$*, *B1$*, *B2$* \[, *B3$*\])  <br>ListByGroup$(*Type$*, *B1$*, *B2$*, *B3$*,"*S*"**)** | Returns a list of views and/or data sources sorted by data group. The *Type$* indicator will determine what is returned:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| A \| All views and data sources ***(Default)*** \|<br>\| D \| All data sources \|<br>\| V \| All views \|<br>Normally, data groups with no items will be suppressed, unless the "S" flag is included. If no bitmap references are included, format of the items will be: *DataGroupDesc$+* SEP *+View\|DataSourceDesc$+* $00$.  <br>  <br>Bitmap references are:  <br>  <br> *B1$* = Bitmap for the group level (e.g. "{!Files}" )  <br> *B2$* = Bitmap for data sources (e.g. "{!File}" ) or views if *Type$* ="V"  <br> *B3$* = Bitmap for views (e.g. "{!Grid}" ) if *Type$* ="A"  <br>  <br>Format of each item in the return value with bitmaps: *Bmp$* + *GrpDesc$* + SEP + *View\|DataSourceDesc$* + $00$. The return value is suitable for display in a Tree view control. |
| ListGroupMembers$(*GrpDesc$* \[,\[*LB_Type$*\])  <br>ListGroupMembers$(*D$*, *LBT$, B1$, B2$, B3$***)** | Returns a list of views and data sources which belong to the specified group.<br>The *LB_Type$* indicator determines how the output will be formatted:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| L \| Formatted for List Boxes ***(Default)*** \|<br>\| T \| Formatted for Tree View controls \|<br>If no bitmap references are included, the format of individual items in the return value will be:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| ***List Box:*** \| *View* \\| *DataSourceDesc$* + $00$ \|<br>\| ***Tree View:*** \| *DataGroupDesc$* + SEP + *View* \\| *DataSourceDesc$* + $00$ \|<br>Bitmap references are:  <br>  <br> *B1$* = Bitmap for the group level (e.g. "!Files" for List Boxes and "{!Files}" for Tree Views)  <br> *B2$* = Bitmap for data sources (e.g. "!File" for List Boxes and "{!File}" for Tree Views)  <br> *B3$* = Bitmap for views (e.g. "!Grid" for List Boxes and "{!Grid}" for Tree Views)  <br>  <br>Format of each item in the return value with bitmaps:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| ***List Box:*** \| *B2$* \\| *B3$* + *View* \\| *DataSourceDesc$* + $00$ \|<br>\| ***Tree View:*** \| First entry: *B1$* + *GrpDesc$* + $00$  <br>Other entries: *B2$* \\| *B3$* + *GrpDesc$* + SEP + *Desc$* + $00$ \| |
| ListMemberGroups$(*MemberDesc$***)** | Return a SEP-separated list of groups to which a specified data source or view belongs. |
| Print(*Type$* \[, *Desc$* \[,"*V*"\]\[, *Opt$*\]\]**)** | Print view and/or data source definitions to the printer or PxPlus Viewer. If the outputting to the printer, "\*winprt\*;Asis" is used to output directly to the Windows default printer without invoking the printer dialogue box.  <br>  <br>*Type$* will determine what type of definition is printed:<br>\|  \|  \|  \|  \|<br>\| --- \| --- \| --- \| --- \|<br>\| A \| Data sources and views \|  \|  \|<br>\| D \| Data sources \|  \|  \|<br>\| V \| Views \|  \|  \|<br>\| G \| Groups \|  \|  \|<br>\| *Desc$* \| Determines which definition is printed. If omitted or "" *null*, all definitions of the specified type are output. \|  \|  \|<br>\| *V* \| Outputs to the PxPlus Viewer rather than to the printer. If omitted, the default destination is the Windows default printer. \|  \|  \|<br>\| *Opt$* \| Provides printer options: *Normal, Asis **(Default)*** and *Default*. \|  \|  \|<br>\|  \|  \|  \|  \| |

***Export and Import Methods***

**ViewCtl** export and import processing is accomplished using the methods described in the following table:

| **Method** | **Description** |
| --- | --- |
| Export(*Channel* \[, *SourceList$*\]**)** | Export the specified definitions to a specially formatted text file.   <br>  <br>*Channel* is the open channel to the serial file to which the exported definitions will be written.  <br>  <br>*SourceList$* provides a list of data sources and views to be included in the export file. List entries are separated by $00$.   <br>  <br>If *SourceList$* is omitted or blank, the default is to include all definitions. The application must open/close the export text file, as well as purge it, if desired. When exporting, the text file must also be locked, unless the **['LU'](https://manual.pvxplus.com/parameters/lu)** parameter is set. |
| ***The following methods handle importing definitions:*** |  |
| GetImportList$(*Channel* \[, *Code$*\]**)** | Return a SEP-separated list of the data sources and views included in the exported file. The optional code will determine what source types will be included in the list:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| A \| All ***(Default)***; i.e. data sources and views \|<br>\| D \| Data sources only \|<br>\| V \| Views only \| |
| SetImport(*SrcDesc$*, *MergeOpt*) | Specify a definition to be imported (must exist in the exported file). (Used in conjunction with Import( )).   <br>  <br>*SrcDesc$* is the data source or view description to be imported (must exist in the exported file).  <br>  <br>*MergeOpt* provides options for dealing with definitions that exist in both source/destination files, as follows:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| 0 \| Skip the definition \|<br>\| 1 \| Replace the contents of the destination definition with those of the source \|<br>\| 2 \| Merge the contents of the two definitions, with precedence given to the source \| |
| Import(*Channel*) | Import the data source and view definitions specified previously using the **SetImport( )** method, or all the definitions if none have been specified by **SetImport( )**. In the latter case, merge option 1 (*replace*) will be used.  <br>  <br>*Channel* is the open channel to an exported file. |

***Miscellaneous Methods***

Other **ViewCtl** methods are described as follows:

| **Method** | **Description** |
| --- | --- |
| **VError$(**\[*ErrorCode*\]**)** | Return a description of the last view error to occur (based on the contents of the **VError** property) or of the specified *ErrorCode*. See **[VError Codes](https://manual.pvxplus.com/views-system/views-definition-object/verror-codes)**.<br>The format of the error description is as follows:  <br>  <br>**Views Error** *#nnnn* **-** *ClassName: Method( ) Error Description*  <br>  <br>***Example:***  <br>  <br> Views Error #1234 - ViewCtl: GetView( )   <br> View not found |
