Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substituting a string in a "IN" formula

Status
Not open for further replies.

heyinlangley

Programmer
Oct 6, 2000
10
0
0
CA
I'm trying to write a formula whereby I can substitute the contents of an IN statement. Let me illustrate:

This works:

Store_id in [1, 2, 3]

But, would like the 1, 2, 3 to be replaced with a variable along these lines:

global stringvar test;
test := '1, 2, 3';
store_id in [test];

Does anyone know if this can be done?
 
You need to use a:
global stringvar array test[3]:= ["1","2","3"];

store_id in test

I hope this helps you.
Cheers
Paul
 
Hi,
OR try:

stringVar IDstr = "1,2,3"

StoreID in "[" + IDstr + "]"



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks Turkbear, I hadn't seen that before, but after testing, it doesn't work the way intended.
For example:

stringvar strvar1 := "bike,cab,bus";
stringvar strvar2 := "ike";
strvar2 in "[" + strvar1 + "]";

Returns True when it should return False since ike is not one of the elements, but the three letters "ike" are in order in the following string "[bike,cab,bus]" which is why it interprets it as true.

To correctly convert a string "bike,cab,bus" into three separate elements, and compare it against another string do the following:

stringvar array strvar1 := split("bike,cab,bus",",");
stringvar strvar2 := "bike";
strvar2 in strvar1;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top