This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19
VP Find

VP Find 


 

VP Find ( rangeObj ; searchValue {; searchCondition {; replaceValue}} ) -> Function result 
Parameter Type   Description
rangeObj  Object in Range object
searchValue  Text in Search value
searchCondition  Object in Object containing search condition(s)
replaceValue  Text in Replacement value
Function result  Object in Range object

The VP Find command searches the rangeObj for the searchValue. Optional parameters can be used to refine the search and/or replace any results found.  

In the rangeObj parameter, pass an object containing a range to search.  

The searchValue parameter lets you pass the text to search for within the rangeObj.  

You can pass the optional searchCondition parameter to specify how the search is performed. The following properties are supported:  

 

Property  Type  Description 
afterColumn Longint The number of the column just before the starting column of the search. If the rangeObj is a combined range, the column number given must be from the first range. Default value: -1 (beginning of the rangeObj)
afterRow Longint The number of the row just before the starting row of the search. If the rangeObj is a combined range, the row number given must be from the first range. Default value: -1 (beginning of the rangeObj
all  Boolean 
flags  Longint 
Constant Comment
vk find flag exact match

Specifies that the entire content of the cell must completely match the search value.

vk find flag ignore case

Specifies that capital and lower-case letters are considered the same. Ex: "a" is the same as "A".

vk find flag none

Specifies that no search flags are considered. (default)

vk find flag use wild cards

Specifies that wildcard characters (*,?) can be used in the search string. Wildcard characters can be used in any string comparison to match any number of characters.  

  • *  - For zero or multiple characters. For example, searching for "bl*"  can find "bl", "black", "blue", and "blob".
  • ? - For a single character. For example, searching for "h?t" can find "hot", "hat", and "hit".


These flags can be combined. For example:

order  Longint 
Constant Comment
vk find order by columns

Specifies that the search is performed by columns. Each row of a column is searched before the search continues to the next column. 

vk find order by rows

Specifies that the search is performed by rows. Each column of a row is searched before the search continues to the next row. (default)

target  Longint 
Constant Comment
vk find target formula

Specifies that the search is performed in the cell formula.

vk find target tag

Specifies that the search is performed in the cell tag.

vk find target text

Specifies that the search is performed in the cell text. (default)



These flags can be combined. For example:

 

In the optional replaceValue parameter, you can pass text to take the place of any instance of the text in searchValue found in the rangeObj.

 

Returned Object

The function returns a range object describing each search value that was found or replaced. An empty range object is returned if no results are found.

To find the first cell containing the word "Total": 

 var $range;$result : Object
 
 $range:=VP All("ViewProArea")
 
 $result:=VP Find($range;"Total")

To find "Total" and replace it with "Grand Total":  

 var $range;$condition;$result : Object
 
 $range:=VP All("ViewProArea")
 
 $condition:=New object
 $condition.target:=vk find target text
 $condition.all:=True //Search entire document
 $condition.flags:=vk find flag exact match
 
  // Replace the cells containing only 'Total' in the current sheet with "Grand Total"
 $result:=VP Find($range;"Total";$condition;"Grand Total")
 
  // Check for empty range object 
 If($result.ranges.length=0)
    ALERT("No result found")
 Else
    ALERT($result.ranges.length+" results found")
 End if

 
PROPERTIES 

Product: 4D
Theme: 4D View Pro Language

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v18 R6

 
ARTICLE USAGE

4D View Pro Reference ( 4D v19)