I'm working on a project where I need to check for the occurrence of a string in tables with several thousand values. For speed reasons I would like to include this information directly into the code. In order not to start from scratch I'm looking for code able to do that.
The first Idea that occurred to me was to define a string literal containing the table and to search the table with InStr. As far as it can be told now, I'll only need the information whether strToSearch is contained or not. I think InStr will produce fast code for this kind of search. I use a database elsewhere in the project (Tsunami-DB TrmPro.DLL), but I think it's use would be far slower than the simple string search directly in the RAM:
This will not work, as the complier restricts the input to 256 characters per line.
A workaround could look as shown in the next sample. But: I do not like this idea - this will generate code that needs to be executed at least once when my .DLL is loaded. Considering the size of my tables (look further below) I expect this initialization to be time consuming.
I showed here a sample only. In reality 'searchedString' will be 10'000-20'000 characters and I have several different 'searchedString', totaling to approximately 40'000 characters, but quite different in size (from 200 to the said 10'000-20'000 characters). The input data might change in future and become larger than 64k. Right now I do not expect this to happen for the next 2 years or so and could life with a 64k limit.
I think I'm not the first one with such a problem. Who can refer me to a possible solution?
Walter
The first Idea that occurred to me was to define a string literal containing the table and to search the table with InStr. As far as it can be told now, I'll only need the information whether strToSearch is contained or not. I think InStr will produce fast code for this kind of search. I use a database elsewhere in the project (Tsunami-DB TrmPro.DLL), but I think it's use would be far slower than the simple string search directly in the RAM:
Code:
$searchedString=";0050;0051;0052;0053;0054;0055;0061;0062;0063;0064;0065;0066;0070;0071;0072;0073;0080;0081;0082;0083;0084;0101;0111;0112;0113;0114;0115;0118;0119;0121;0122;0123;0124;0125;0131;0132;0139;0141;0142;0151;0152;0153;0159;016;0201;0202;0203;0204;0205;0206;0207;0211;0212;0213;0214;022;0231;0232;0233;0234;0235;0239;0242;0243;0291;0292;0293;0294;0295;0296;0299;0301;0302;0309;031;0321;0329;0332;0339;034;0351;0352;0353;0359;036;0371;0372;0379;0393;0394;0396;0397;0398;0399;0401;0402;0403;0404;0405;0406;0407;0411;0412;0419;042;043;0441;0442;0443;0444;0449;045;046;0471;0472;0473;0474;0475;0476;0479;0480;0489;0491;0492;0493;0499;050;0511;0519;0521;0522;0523;0524;0525;0529;0532;0539;0581;0589;059;0601;0602;0609;0611;0612;0613;0619;062;0631;0639;064;0650;0651;0652;066;067;" strToSearch = ";0061;" IF InStr(1, $searchedString, strToSearch) > 0 THEN MsgBox "Data found" ELSE MsgBox "Data not found" END IF
A workaround could look as shown in the next sample. But: I do not like this idea - this will generate code that needs to be executed at least once when my .DLL is loaded. Considering the size of my tables (look further below) I expect this initialization to be time consuming.
Code:
searchedString=";0050;0051;0052;0053;0054;0055;0061;0062;0063;0064;0065;0066;0070;0071;0072;0073;0080;0081;0082;0083;0084;0101;0111;0112;0113;0114;0115;0118;0119;0121;0122;0123;0124;0125;0131;0132;0139;0141;" searchedString=searchedString&"0142;0151;0152;0153;0159;016;0201;0202;0203;0204;0205;0206;0207;0211;0212;0213;0214;022;0231;0232;0233;0234;0235;0239;0242;0243;0291;0292;0293;0294;0295;0296;0299;0301;0302;0309;" searchedString=searchedString&"031;0321;0329;0332;0339;034;0351;0352;0353;0359;036;0371;0372;0379;0393;0394;0396;0397;0398;0399;0401;0402;0403;0404;0405;0406;0407;0411;0412;0419;042;043;0441;0442;0443;0444;0449;" searchedString=searchedString&"045;046;0471;0472;0473;0474;0475;0476;0479;0480;0489;0491;0492;0493;0499;050;0511;0519;0521;0522;0523;0524;0525;0529;0532;0539;0581;0589;059;0601;0602;0609;0611;0612;0613;0619;062;" searchedString=searchedString&"0631;0639;064;0650;0651;0652;066;067;" strToSearch = ";0061;" IF InStr(1, searchedString, strToSearch) > 0 THEN MsgBox "Data found" ELSE MsgBox "Data not found" END IF
I think I'm not the first one with such a problem. Who can refer me to a possible solution?
Walter
Comment