Normal Topic XLU won't work when parentheses in the ext key? (Read 1807 times)
hlatz
Member
*
Offline


No personal text

Posts: 7
Location: Adelaide, Australia
Joined: Feb 1st, 2004
XLU won't work when parentheses in the ext key?
Feb 9th, 2004 at 1:23pm
Print Post Print Post  
I'm slowly converting my Q&A5 application. Spent the weekend stressing out about why some of my @xlookups worked and others didn't. I think I've finally found the problem.

Some background - My application is an academic dress hiring system used by my voluntary work organisation. Each academic hood has a "type" e.g. "Science", "Arts". Those for universities other than our home base (Adelaide University) have the university name included in parentheses, e.g. "Science (Flinders)". The Q&A application used field restrictions to present the users with a list of valid "type"s, so for Sesame I'm changing these bits to use @xlookups.

I have a file containing all the "type"s along with the 2-character code (which I called "typekey") that the program needs to use for each "type". I have an @xuserselect statement that presents the user with the list of "type"s available, and then I use an @xlookup to find the "typekey".

var vtypekey as string
vtypekey=@xlookup("data\stocktypes.db", Type, "Stocktypesform!Type", "Typekey")

All weekend my testing (writeln statements galore) showed that the program was following the correct sequence, was successfully recording the "type"s, but it seemed that it was only successfully finding a "typekey" for Adelaide uni "type"s.

Finally, tonight, I tested it on an Adelaide uni type that contained parentheses - e.g. "App Sc (Ag)". The xlu didn't work for that either!  Shocked In fact, it's now apparent that the xlu only works properly when "Stocktypesform!Type" doesn't contain parentheses.

Was this intentional or is it a bug? Is any sort of bracketing allowable in the ext key string? Can I use a dash at least, e.g. "App Sc - Ag"? I would have thought that a string is a string, regardless of what characters it contains (except I'd imagine that a double quote might confuse things).

I had already found that I had to get rid of all of the "&" signs that I had in my ext selection element strings in order for the xuserselect statement to accurately display the "type"s to select from, but it was happy enough to display the parentheses.

I can't find any mention in the X-family part of the manual of non-allowable characters in search strings.

I'd prefer to keep the parentheses if at all possible. Any suggestions?

Heather Latz
(from sunny Australia)
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XLU won't work when parentheses in the ext key
Reply #1 - Feb 9th, 2004 at 2:22pm
Print Post Print Post  
In the example above you are using:

var vtypekey as string
vtypekey=@xlookup("data\stocktypes.db", Type, "Stocktypesform!Type", "Typekey")

To match "App Sc (Ag)" what do you have in "Type"?

I just build a version of Customers.db with "Paris (Ohio)" in the City field of the first record. I then built a version of Gems.db with a @XLookup in the LE Exit code of the description:

var str as string
str = @XLookup("Customers.db", "Par..", "City", "City")
writeln(str)

the result comes back for "Paris (Ohio)". In other words, I suspect that the problem is not what you have in "Stocktypesform!Type" - but what you have in "Type". In an XLookup, the key string is subject to the same rules as a search spec.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
hlatz
Member
*
Offline


No personal text

Posts: 7
Location: Adelaide, Australia
Joined: Feb 1st, 2004
Re: XLU won't work when parentheses in the ext key
Reply #2 - Feb 10th, 2004 at 8:39am
Print Post Print Post  
The value of Type would be "App Sc (Ag)" in that example. The value of Type is set during an xuserselect process, which happily presents me a list of the 57 different values for Type whether or not they have parentheses. After I select a value for Type the program moves to the @xlookup statement (which looks back at the file that it already looked at for the @xuserselect).

During all my testing I have had writelns for Type both before and after the xlookup (see below) and the string is exactly as it's supposed to be, i.e. it's exactly what I selected in the xuserselect whether or not the value contains parentheses. When Type doesn't have any parentheses the xlookup successfully finds a match and returns the correct value for Typekey, but when Type does contain parentheses Typekey is left blank or empty.

Code for setting Type (on element entry):
if (Type = "" or Type = " ") then
Type = @xuserselect("data\stocktypes.db", "Stocktypesform!Type")

Code for setting vtypekey (including all the writelns) on exit from another element:
if (Type<>"" and Type<>" ") then
{
writeln("vtypekey before xlu " + vtypekey)
writeln("Type before xlu " + Type)
vtypekey=@xlookup("data\stocktypes.db", Type, "Stocktypesform!Type", "Typekey")
writeln("vtypekey after xlu " + vtypekey)
writeln("Type after xlu " + Type)

Thanks
Heather
  
Back to top
 
IP Logged
 
hlatz
Member
*
Offline


No personal text

Posts: 7
Location: Adelaide, Australia
Joined: Feb 1st, 2004
Re: XLU won't work when parentheses in the ext key
Reply #3 - Feb 15th, 2004 at 4:14am
Print Post Print Post  
Mark

I have done some more testing on this and a now even more certain that Sesame can't handle search strings that contain "(". In the example you set up above, I suspect that if you had used "Paris (.." as your search string instead of "Par.." the xlookup would not have worked.

This is what I've found when using hardcoded strings in the xlookup. (Note that in my real application I will not be able to use hardcoded strings - this is just for experimentation.)

My Stocktypes db has a record with the hood type "App Sc(Engineering)".
When I use "App Sc.." in the Xlookup statement the program successfully matches the string and correctly sets the value of vtypekey.
When I use "App Sc(.." or "App Sc(Engineering)" in the Xlookup statement vtypekey is left blank.

To investigate this further I opened the Stocktypes db and just tried to do some ordinary searches, typing strings into the Hood Type field and pressing F10. When I entered "App Sc.." into that field and pressed F10, Sesame found the record. When I typed "App Sc(.." or "App Sc(Engineering)" no matching records were found.

Hopefully, you will find the same problem if you search for "Paris (.." or "Paris (Ohio)" instead of "Par..".

If so, does this mean this is a bug, or is there a list of characters that will upset a Sesame search, even though they are just included in text strings?

Heather
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: XLU won't work when parentheses in the ext key
Reply #4 - Feb 15th, 2004 at 5:28am
Print Post Print Post  
Quote:
I have done some more testing on this and a now even more certain that Sesame can't handle search strings that contain "(". In the example you set up above, I suspect that if you had used "Paris (.." as your search string instead of "Par.." the xlookup would not have worked.


In order to search special character such as "(" you will have to use it as literal character. So your search string should be

Paris  \(..

This will force search to use "(" as literal character and not treat it as being used in syntax.

You may also use this in code in search as follows:

{@in (LE Name, "Paris (") > 0) }

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XLU won't work when parentheses in the ext key
Reply #5 - Feb 15th, 2004 at 3:48pm
Print Post Print Post  
Quote:
...or is there a list of characters that will upset a Sesame search, even though they are just included in text strings?


On Sesame, the "key string" is not an ordinary "text string". It uses the retrieve spec syntax. If you need to test a "key string" against the external data - you can do so using an retrieve spec in that database.

That being said, I created a Customers.db with "Malvern (Ohio)" and "Los Angeles (Ohio)" in the City LE. I then built an @XLookup in Gems.db:

//----------------
var str as string

str = @Xlookup("Customers.db", "Malvern (Ohio)", "City", "City")
writeln(str)
//----------------

It produced twelve "Malvern (Ohio)"s in the writeln window, one for each Gem_Types record. If I use:

//----------------
var str as string

str = @Xlookup("Customers.db", "Malvern (..", "City", "City")
writeln(str)
//----------------

It matches no records. But if I use:

//----------------
var str as string

str = @Xlookup("Customers.db", "Malvern (..)", "City", "City")
writeln(str)
//----------------

It matches "Malvern (Ohio)" without a hitch. This is exactly the same behavior I get if I build the same search specs in the City LE of Customers.db directly.

When you ask as to what characters "are not allowed" - the rules are the same as for a search spec. It isn't a question of what is allow, so much as question as to what characters have "special meaning" to a the search - essentially they are commands, like ".." meaning wildcard or range. These would include:

From Q&A:
..
<
>
[]
;
>=
<=
=
\
~
&
/
min
max

From Regular Expressions, we literalize (put a "\" in front of):
*
^
$

From Regular Expressions, we accept:
(
)

Parenthesis, in a search spec allows the grouping of operators, because:

(XX="1" and YY="2") or (WW="3" and ZZ=4")

is different from:

XX="1" and (YY="2" or (WW="3" and ZZ="4"))
  

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


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: XLU won't work when parentheses in the ext key
Reply #6 - Feb 15th, 2004 at 5:00pm
Print Post Print Post  
Hello Mark.

Thanks for the list of "special characters".

I had asked about Regular Expressions during the beta testing and was told that it might be available in later releases.  I could find no mention of RegEx in any of the  PDF manuals, but you are making reference to their usage here. 

1.  Where can we find the guidelines for RegEx with Sesame.?  We now see that this applies to Retrieve Specs and LU functions.  Are there other areas where this should be a concern?  This is a powerful tool that I have been hoping to have available.

2.  Searching for "Paris (" was acceptable in Q&A.  But the same formula will not produce the same results in Sesame.  If you are using some RegEx tools in Search Specs and/or LU functions, then that means that existing Q&A Retrieve Specs and LU functions need to be reviewed for possible changes to provide the same results.

This list of special characters will make it easier to identify translation issues.  But we will also have to provide special training for users doing a record retrieve, explaining how to use those special characters.

Thanks for the list in your last posting.  Will have to do some experiments with using RegEx in Sesame.

For those who want more information about Regular Expressions, I would strongly suggest "Mastering Regular Expressions" by Jeffrey Friedl, O'Reilly Press, 2nd Edition, 2002, about $30.  Be sure to get the 2nd edition, much more current than the first.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XLU won't work when parentheses in the ext key
Reply #7 - Feb 15th, 2004 at 5:15pm
Print Post Print Post  
Because there is a great deal of overlap between regex and Q&A in the the symbols, not in the meanings, we have to filter out most of the regex symbols the user might place in a search. This would include all of the symbols also used by Q&A, and:

*
^
$

We do not filter out the parenthesis.

I would like to support regex as much as possible. This would make us *much* easier to use for people unaccustomed to Q&A's very syntax. But it will have to wait until a later release.
  

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


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: XLU won't work when parentheses in the ext key
Reply #8 - Feb 15th, 2004 at 6:00pm
Print Post Print Post  
Perhaps a choice to use Q&A syntax or Posix syntax when selecting Serach mode? 

Perhaps mirrored LU functions for Posix syntax?
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
hlatz
Member
*
Offline


No personal text

Posts: 7
Location: Adelaide, Australia
Joined: Feb 1st, 2004
Re: XLU won't work when parentheses in the ext key
Reply #9 - Feb 16th, 2004 at 9:27am
Print Post Print Post  
Gosh, I don't understand any of that regex or posix stuff. But it seems that with my original xlookup string (where the key being searched for is a variable called Type, whose value may or may not have parentheses), then I will either:
(a) have to do some string manipulations to insert a "\" before any parenthesis character before doing the xlookup; or
(b) get rid of all of the parentheses in my data?

[I can't understand why the "Malvern (Ohio)" example worked when my "App Sc(Engineering)" example didn't. Maybe the space before the "(" makes a difference.]

Heather
  
Back to top
 
IP Logged