This function searches for
The function will return the closest match, using option =0 or =1, but Lookup() does not support wildcard characters.
If vref contains numeric values,
double Lookup(string str$, vector<string> vs[, vector vref, int option, int Case])
If vref contains string values,
string Lookup(string str$, vector<string> vs[, vector<string> vref, int option, int Case])$
If search a numeric vector vd,
double Lookup(double dd, vector vd[, vector vref, int option, int Case])
str
vs
dd
vd
vref
option
Case
If str is found in vs, returns a value in vector vref of the same row index.
If option = 2, and str is not found, returns an empty string or missing value.
If option = 0 and str is not found, returns the value corresponding to the nearest smaller value of str. If no smaller value of str exists, returns missing value (numeric) or empty string (string).
If option = 1 and str is not found, returns the value corresponding to the nearest larger value of str. If no larger value of str exists, returns missing value (numeric) or empty string (string).
Search elements in Periodic Table Book1 and give the corresponding atomic weight:
/Lookup_ex1.png?v=41817)
Or with Book1 above active, use LabTalk Script to search symbol and output corresponding Name:
range symbol=col(D); range name=1!col(C); string str1$ = Lookup("Li", symbol, name)$; str1$=; // will output Lithium
Book1 searches each numeric C value in column B and returns the row index of the finding since the 3rd argument is not specified. 4th argument controls how to find the nearest value: default =nearest value, 0 = nearest value smaller than the specified value, 1 = nearest value larger than the specified value.
Book2 searches each numeric C value in column B and returns the matching A value.
/Lookup_ex2.png?v=42276)
Note: There is index() function to find row index of specified value in data but the data must be strictly monotonic. Skipping 3rd argument to find row index is only supported since Origin 2026.
Labtalk script to search a number in column B and return the row index:
range vd = col(B); Lookup(0.2, col(B))=; // nearest (default) Lookup(0.2, col(B), , 0)=; // nearest smaller Lookup(0.2, col(B), , 1)=; // nearest larger
Labtalk script to search a number in column B and return the corresponding A:
Lookup(0.2, col(B), col(A))=; // A at matched row