decreasing a positive number inside a string

H005444H005444 Member Posts: 10
Hello,

I am looking for a function that does not increase a postive number inside a string (see function INCSTR) but decreases a positive nuwber in a string

e.g. 'year2006' -> 'year2005'

Someone has a good proposition?

Thanks

Comments

  • AlbertvhAlbertvh Member Posts: 516
    Hi
    You could do something like this
    OnRun
    
    DecStr(Text);
    
    DecStr(VAR PText : Text[30])
    
    Text := PText;
    FOR i := 1 TO STRLEN(Text) DO
      IF EVALUATE(Int,FORMAT(Text[i])) THEN BEGIN
        Pos := i;
        i := STRLEN(Text) + 1;
      END;
    Text1 := DELCHR(UPPERCASE(Text),'=','ABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+=|\{}[]":;?/<>,.');
    IF STRLEN(Text1) <> 0 THEN BEGIN
      EVALUATE(Int,Text1);
      Int := Int - 1;
      i := STRLEN(FORMAT(Int));
      Text := INSSTR(DELSTR(Text,Pos,i),FORMAT(Int),Pos);
    END;
    Ptext := Text;
    

    Where i, Int and Pos are type Integer
    Text,Text2 are type text

    Hope this helps :lol: [/b]
Sign In or Register to comment.