A volte, quando si inizializza un documento 4D View Pro, è necessario trovare alcuni valori o tag al suo interno e sostituirli con i dati emessi da 4D. Ora è un gioco da ragazzi con il comando VP Find . Grazie a questo comando, è possibile trovare dati, una formula o un tag e sostituirli nell’intero foglio o solo in una parte specifica di esso!
Scopriamo come.
Il comando VP Find consente di cercare un valore di testo all’interno di un intervallo designato nel testo, nelle formule o nei tag di un documento 4D View Pro.
Ad esempio, se si desidera eseguire una ricerca sensibile alle maiuscole e alle minuscole per la prima occorrenza della parola “Totale” nel testo delle celle:
$range:=VP All("ViewProArea")
// find the first cell that contains the word 'Total' in the current sheet
$result :=VP Find($range; "Totale")
// Make the cell background yellow for the found cells
VP SET CELL STYLE ($result; New object("backColor"; "yellow"))
Ora è possibile affinare la ricerca per trovare tutte le celle contenenti “Totale” utilizzando la proprietà all :
$range:=VP All("ViewProArea")
$condition :=New object
// Search in all values in the range
$condition .all:=True
// Find all cells containing the word 'Total' in the current sheet
$result :=VP Find($range; "Total"; $condition)
// Make the cell background yellow for the found cells
VP SET CELL STYLE ($result; New object("backColor"; "yellow"))
- Se si desidera eseguire una ricerca per “Totale” senza tenere conto del caso, è sufficiente modificare la proprietà flags :
$range$result:=VP All("ViewProArea")
$condition :=New object
// Search the entire sheet
$condition .all:=True
// Search cells containing the word "Total" without considering the case
$condition .flags:=vk find flag ignore case
// Find all cells containing only the word 'Total' in the current sheet
:=VP Find($range; "Total"; $condition)
// Make the cell background yellow for the found cells
VP SET CELL STYLE ($result; New object("backColor"; "yellow"))
- Se si desidera sostituire tutte le parole trovate “Total” con “4D”, aggiungere un parametro con il testo di sostituzione:
$range$result:=VP All("ViewProArea")
$condition :=New object
// Search the entire sheet
$condition .all:=True
// Search cells containing the word "Total" without considering the case
$condition .flags:=vk find flag ignore case
// Replace text in all cells containing only 'Total' with "4D"
:=VP Find($range; "Total"; $condition; "4D")
// Make the cell background yellow for the found cells
VP SET CELL STYLE ($result; New object("backColor"; "yellow"))
Naturalmente, queste sono solo alcune delle possibilità offerte dal comando VP Find del comando.
Per saperne di più, come trovare i valori con i caratteri jolly, cercare nelle formule e molto altro, consultare il Centro documentazione.