Normal Topic Using @XLookupSourceListAll() with ";" in data (Read 719 times)
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Using @XLookupSourceListAll() with ";" in data
Feb 25th, 2006 at 9:49pm
Print Post Print Post  
I am using @XLookupSourceListAll to get data from 12 fields from a handful of records. The problem is that some of the data contains semicolons, which of course is the default string array separator. This causes a problem when using @AccessStringArray. The semicolons in the data cause the number of elements in the string array to be different than expected.

I've tried to use SetStringArraySeparator("|") to change the separator before executing @XLookupSourceListAll(). This allows me to use the new separator while specifying the sourcelist , but the data returned still uses semicolons to separate the fields.

How can I change the semicolons that @XLookupSourceListAll returns without changing the ones in my data?

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Using @XLookupSourceListAll() with ";" in data
Reply #1 - Feb 25th, 2006 at 10:52pm
Print Post Print Post  
The "X" commands compile the data on the server, and don't take client settings (like the string array separator setting) into account. I may change it so that it is one of the parameters sent from the client to the server when string array "X" commands are called.

In the meantime, there are two approaches that might serve you. You could filter the data in the external application, replacing the ';' with a known character that is less likely to appear, then replacing that character with the semicolon before the data is displayed on the client. This can be done on data entry on that app, and a mass update can repair the existing data.

If that is out of the question, or too inconvenient, you can place a field in that external database that contains a known and unlikely value. Then when you call the "X" source list command, "brace" the fields that may contain a semicolon between (or at least followed by) the field with the known value. That way if you run into a extra semicolon between the start of the field and the known value, you know that it is part of the data.

I'll see if I can get the client's choice for string array separator over to the server (in a way that does not upset the other clients!)
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Using @XLookupSourceListAll() with ";" in data
Reply #2 - Feb 25th, 2006 at 11:13pm
Print Post Print Post  
Thanks for the reply, Mark.

For now, I have worked around it with a combination of @XLookupSourceListAll for the data that I know won't have a semicolon in it,  and multiple XLookups for the data that probalbly will have a semicolon.

I was trying to make the programming more efficient by having just one external lookup (@XLookupSorceListAll), rather than muliple XLookups.

I can see why you would have trouble changing the separator on the server side. If you can make it work, that would be great. But if it causes too much overhead to control it among multiple clients, it probably isn't worth the trouble.

I do have a solution - it just may not be as efficient as it possibly could be. Even with multiple XLookups, it seems to be working pretty quick.

Thanks again.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Using @XLookupSourceListAll() with ";" in data
Reply #3 - Feb 26th, 2006 at 12:19am
Print Post Print Post  
Carl,

While you might not need it, here is an example of the second idea outlined above:

Code
Select All
ar aa as string
var bb as string
var cc as int

aa = @XLookupSourceList(@fn, "..", "Company", "KEY;one;First;one;Last;one;Company;one;City")
SetStringArraySeparator("|")
// strip away extraneous semicolons
for cc = 1 to 5
	bb = @AccessStringArray(aa, cc)
	if(cc = 1)
	{
		bb = @Left(bb, @Len(bb) - 1)
	}
	else if(cc = 5)
	{
		bb = @Right(bb, @Len(bb) - 1)
	}
	else
	{
		bb = @Mid(bb, 2, @Len(bb) - 2)
	}
	writeln(bb)  // write out the resulting string
next
 



The LE "one", of always contains a "|".
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Using @XLookupSourceListAll() with ";" in data
Reply #4 - Feb 26th, 2006 at 5:03am
Print Post Print Post  
Mark,

Ahhhh... I see what you mean now.

A picture is worth a thousand words. I never thought of using a field more than once in the sourcelist, and wasn't quite sure how your technique would be done.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged