Hot Topic (More than 10 Replies) [Solved] searching a string array (Read 1212 times)
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
[Solved] searching a string array
Dec 21st, 2007 at 11:32pm
Print Post Print Post  
Solution: In functions that accept "retrieve specs" like @SearchStringArray(), special characters may need to be escaped with a backslash to work properly, just as they would in a Retrieve Spec

please help me!!!

i have a string array that contins the following:
Code
Select All
T02058=1;T2021016=1;T2021016=10;T2021022=1;T2021022=10;T2021030=1;T2021030=10;T2021031=1;T2021031=10;T2021032=1;T2021032=10;T2021073=1;T2021073=10;T2021080=1;T2021080=10;T2021082=1;T2021082=10;T2021095=1;T2021095=10;T20210=1;T20210=10;T2021106=1;T2021106=10;T2021107=1;T2021107=10;T2021123=1;T2021123=10;T2021124=1;T2021124=10;T2021125=1;T2021125=10;T2021126=1;T2021126=10;T2021127=1;T2021127=10;T2021128=1;T2021128=10;T2021129=1;T2021129=10;T2021130=1;T2021130=10;T2021131=1;T2021131=10;T2021132=1;T2021132=10;T2021133=1;T2021133=10;T2021134=1;T2021134=10;T2021135=1;T2021135=10;T2021136=1;T2021136=10;T20211=1;T20211=10;T20212=1;T20212=10;T202149=1;T202149=10;T20214=1;T20214=10;T202156=1;T202156=10;T202157=1;T202157=10;T202160=1;T202160=10;T202163=1;T202171=1;T202171=10;T202172=1;T202172=10;T20217=1;T20217=10;T202184=1;T202184=10;T202185=1;T202185=10;T202193=1;T202193=10;T2022001=1;T2022001=10;T2022002=1;T2022002=10;T2022004=1;T2022004=10;T2022005=1;T2022005=10;T2022006=1;T2022006=10;T2022007=1;T2022007=10;T2022008=1;T2022008=10;T2022010=1;T2022010=10;T2022011=1;T2022011=10;T2022022=1;T2022022=10;T2022031=1;T2022031=10;T2022032=1;T2022032=10;T2022033=1;T2022033=10;T2022038=1;T2022038=10;T2022040=1;T2022040=10;T2022041=1;T2022041=10;T2022042=1;T2022042=10;T2022043=1;T2022043=10;T2022047=1;T2022047=10;T2022048=1;T2022048=10;T2022049=1;T2022049=10;T2022055=1;T2022055=10;T2022056=1;T2022056=10;T2022060=1;T2022060=10;T2022061=1;T2022061=10;T2022062=1;T2022062=10;T2022070=1;T2022070=10;T2022071=1;T2022071=10;T2022075=1;T2022075=10;T2022076=1;T2022076=10;T2022090=1;T2022090=10;T202231=1;T202231=10;T202235=1;T202235=10;T202244=1;T202244=10 



and i want to search for a specific combination like:
T2021016=1 and T2021016=10

i used the following code to get this one:
Code
Select All
var vArtikelSubDaten as string
var vArtikelSubDaten1 as string
var vSucheSub as string
var vArtNr as String
var vPos as int

vArtNr = "T2021016"

vArtikelSubDaten = @XLookupAll("10lager.db", "T..", "Art_EAN!ArtNr", "ArtNr")  //produces the upper stringarray
vArtikelSubdaten1 = @SortStringArray(vArtikelSubdaten,0)

vSucheSub = @SearchStringArray(vArtikelSubDaten1,vArtNr+"=..")
writeln(vSucheSub) 



i have tried a lott of combinations of code but no one would work!
maybe i can't see the error any more because of to much trying and erroring

but when i try it with other data (without the equal and the char's behind) it works e.g.
Code
Select All
T20210;T2021016;T2021022;T2021030;T2021031;T2021032;T2021073;T2021080;T2021082;T2021095;T20211;T2021106;T2021107;T2021123;T2021124;T2021125;T2021126;T2021127;T2021128;T2021129;T2021130;T2021131;T2021132;T2021133;T2021134;T2021135;T2021136;T20212;T20214;T202149;T202156;T202157;T202160;T202163;T20217;T202171;T202172;T202184;T202185;T202193;T2022001;T2022002;T2022004;T2022005;T2022006;T2022007;T2022008;T2022010;T2022011;T2022022;T2022031;T2022032;T2022033;T2022038;T2022040;T2022041;T2022042;T2022043;T2022047;T2022048;T2022049;T2022055;T2022056;T2022060;T2022061;T2022062;T2022070;T2022071;T2022075;T2022076;T2022090;T202231;T202235;T202244;T202249;T20225;T202277;T202280;T202292;T202317;T202333;T202338;T202339;T202340;T202347;T202351;T202363;T2023630;T2023631;T2023632;T202376;T202420;T202431;T202432;T202465;T202475;T202476;T202488;T202489;T202492;T202493;T2025;T202524;T202552;T202553;T202558;T20258;T2026;T202615;T202616;T202628;T202629;T202643;T202644;T20268;T202692;T202697;T2027201;T2027208;T2027209;T2027210;T2027211;T2027214;T2027215;T2027218;T2027219;T2027221;T202723;T2027252;T20273;T202767;T202768;T20278;T202789;T202790;T202797;T202798;T202799;T2028;T202800;T202801;T202805;T202807;T20281;T20282;T202827;T202834;T202835;T202837;T202838;T20284;T202840;T20285;T202854;T202855;T20286;T202865;T202867;T202868;T20287;T2028711;T2028721;T2028751;T20288;T20289;T202891;T2029;T202907;T202908;T202924;T202925;T202932;T202933;T202934;T202943;T202955;T202958;T202966;T202977;T202978;T202989;T202990;T202MO10;T202MO6;T202ON10;T202ON8;T2121055;T2121062;T2121063;T2122102;T2122103;T2122114;T2122115;T2122116;T21221301;T2122131;T21221400;T21221410;T2122142;T21221805;T21221806;T21221820;T212314;T212404;T212405;T212406;T212445;T212446;T2125408;T2125420;T212860;T212861;T2128641;T212911;T212917;T212928;T212929;T212930;T212964;T21298;T212988;T2221004;T2221005;T2221006;T2221007;T2221008;T2221034;T2221035;T2221036;T2221037;T2221039;T2221041;T2221047;T2221048;T2221049;T2221072;T2221096;T2221097;T2221103;T2221105;T2221108;T2221117;T2221121;T2221122;T222194;T2222570;T2222571;T2222577;T2222581;T222278;T222283;T2222907
 



Code
Select All
vArtikelDaten = @XLookupAll("10lager.db", "T..", "Artikeldatei!InternNr", "Internnr")
vArtikeldaten = @SortStringArray(vArtikelDaten,0)
vArtNr = "t20210"
vSuche = @SearchStringArray(vArtikelDaten,vArtNr+"..")
writeln(vsuche)
 



-sebastian
« Last Edit: Dec 22nd, 2007 at 1:56am by Hammer »  
Back to top
ICQ ICQ  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: searching a string array
Reply #1 - Dec 22nd, 2007 at 1:06am
Print Post Print Post  
Wase,

The equal sign is a special character in a search. Try backslashing it. Like so:

vSucheSub = @SearchStringArray(vArtikelSubDaten1,vArtNr+"\=..")
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: searching a string array
Reply #2 - Dec 22nd, 2007 at 1:12am
Print Post Print Post  
i tried to replace the equal with a "A" and the same happend!

shoud i try to replace the equal with a "\" or should i try to search the same array just with the backslash in front?

-sebastian
  
Back to top
ICQ ICQ  
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: searching a string array
Reply #3 - Dec 22nd, 2007 at 1:21am
Print Post Print Post  
just tried and works fine with the backslash like you discribed!!

but why does it not work if i replace the equal with a "A" or some other character?
i don't understand it i think i have tried about 20 or more different combinations of code to get the result i want.
  
Back to top
ICQ ICQ  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: searching a string array
Reply #4 - Dec 22nd, 2007 at 1:21am
Print Post Print Post  
Leave the string array alone. Use the @SearchStringArray line I gave you. Note the \ before the = . This is the same thing you would do in a Retrieve Spec. The backslash tells Sesame to search for a literal = instead of interpreting it as a special search character.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: searching a string array
Reply #5 - Dec 22nd, 2007 at 1:24am
Print Post Print Post  
does this also work in v1.4? because i need to use this version because the 2.0 version of my program is not ready jet.
  
Back to top
ICQ ICQ  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: searching a string array
Reply #6 - Dec 22nd, 2007 at 1:33am
Print Post Print Post  
wase wrote on Dec 22nd, 2007 at 1:24am:
does this also work in v1.4? because i need to use this version because the 2.0 version of my program is not ready jet.

I just tried it in 1.1.4. Works fine.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: searching a string array
Reply #7 - Dec 22nd, 2007 at 1:37am
Print Post Print Post  
at first thanks for the help!!!!!

but im a person who wants to know all (espacialy when something don't work)

just one more question: why does this not work when i replace the equal with a other char (i tried a lot e.g.: $, A, &...)

-sebastian
  
Back to top
ICQ ICQ  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: searching a string array
Reply #8 - Dec 22nd, 2007 at 1:41am
Print Post Print Post  
wase wrote on Dec 22nd, 2007 at 1:37am:
but im a person who wants to know all (espacialy when something don't work)

just one more question: why does this not work when i replace the equal with a other char (i tried a lot e.g.: $, A, &...)

I'm not sure which equal signs you replaced or what you tried to do after doing so, so I'm not sure how to answer you.

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: [solved] searching a string array
Reply #9 - Dec 22nd, 2007 at 1:45am
Print Post Print Post  
i replaced the equal in the xlu: replace(vArtikelSubDaten,"=","$")

and then i seached for: searchstringarray(vArtikelSubDaten,vArtNr+"$..")

i tried some other combinations but no one worked

-sebastian
  
Back to top
ICQ ICQ  
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: [solved] searching a string array
Reply #10 - Dec 22nd, 2007 at 1:49am
Print Post Print Post  
but i'm so happy that this works i can't say in the other way i would have to correct aboaut 300 records of data manualy!!!

i just put the code in my application and it works realy fine

thank you so much!!!

-sebastian
  
Back to top
ICQ ICQ  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [solved] searching a string array
Reply #11 - Dec 22nd, 2007 at 1:53am
Print Post Print Post  
I'm glad it works.

BTW: Let me handle the red pens and the marking things solved, OK?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: [Solved] searching a string array
Reply #12 - Dec 22nd, 2007 at 1:58am
Print Post Print Post  
ok then solve the thing your way does not matter to me

im just happy!!

-sebastian
  
Back to top
ICQ ICQ  
IP Logged