Searching For A Sub string in a String

FiveFive Member Posts: 32
edited 2004-02-27 in Navision Attain
Hello All,

I have a problem in that if i have a range of Itemcodes from "1000 to 9000" for example.

Now on a form say a user enters "1170" in a text box.I want to be able to collect all Itemcodes that have "11" as the start of the code.So these would be "1110,1120,1135,1148" etc and it must then populate the relevant fields.

Can this be done?

Here is an attempt by me

IF ItemCode <> '' THEN BEGIN //ItemCode is the source expr'sion of TB
NewItemCode:= ItemCode;
INIT;
NewItemCode:=DELSTR(ItemCode,3,2);
//sam:= STRPOS(ItemCode,NewItemCode); found this by using f1
// Item.SETFILTER("No.",'<=%1',ItemCode); this evrything below 1170
IF Item.FIND('-') THEN
REPEAT
IF FirstPos=SecondPos THEN BEGIN
"Table Entry No.":=NextEntryNo;
"Item No.":=Item."No.";
"Old price":=Item."Unit Cost";
Item.CALCFIELDS(Inventory);
Quantity := Item.Inventory ;
"Person Amending" := USERID;
INSERT;
NextEntryNo:= NextEntryNo +1;
END;
UNTIL Item.NEXT=0;
END;


thanks for the help
Regards
Five :?
Compile and then Recompile ....

Comments

  • rsummersrsummers Member Posts: 9
    Try this:

    IF (COPYSTR(ItemCode,1,2)) = '11' THEN
    WhateverYouWantToDo;

    I don't know if I understand your issue completely but it seems that this should work.
  • rsummersrsummers Member Posts: 9
    I don't think that I completly understood your issue on the last reply. You should be able to use wildcards in filters to see only the ones that start with the first 2 digits of the items. For example

    Item.SETFILTER(Code,'%1',COPYSTR(NewItemCode,1,2) + '*');
    Item.FIND('-');

    This should only get the records whose code starts with the first two digits of the NewItemCode, and filter out the rest. If you don't want the user to release the set filter the use filtergroups to filter out all the other records.
  • FiveFive Member Posts: 32
    Thanks alot ..it worked perfectly..you are a genius :D

    Cheers

    Five
    Compile and then Recompile ....
Sign In or Register to comment.