CONVERTSTR with variable length strings

juanborrasjuanborras Member Posts: 35
Hi there!

DOes anybody how to make a string substitution like in CONVERTSTR but using different length strings?

Thanks
Juan

Comments

  • lakshmivallurulakshmivalluru Member Posts: 168
    not on top of my head...but u can split the sentence into words and save them in an array, replace the word you want to and concatenate the words back into a sentence.
    LR
  • juanborrasjuanborras Member Posts: 35
    Ok, I see what you say... let me try

    Thanks
  • RobertMoRobertMo Member Posts: 484
    This is what you are probably looking for..
    PROCEDURE TextReplace@1000000005(ltInput@1000000002 : Text[1024];ltWhat@1000000001 : Text[1024];ltWith@1000000000 : Text[1024]) ltOutput : Text[1024];
        VAR
          liInputLen@1000000005 : Integer;
          liWhatLen@1000000004 : Integer;
          liFindFirst@1000000003 : Integer;
        BEGIN
          // TextReplace function finds all ocurences of 'ltWhat' in string 'ltInput' and replaces them with 'ltWith'.
          // Function returns 'ltOutput'.
          liInputLen := STRLEN(ltInput);
          liWhatLen := STRLEN(ltWhat);
    
          // check, if ltInput and ltWhat are not empty strings
          IF (liInputLen > 0) AND (liWhatLen > 0) THEN BEGIN
             liFindFirst := STRPOS(ltInput, ltWhat);
             WHILE (liFindFirst > 0) DO BEGIN
                ltOutput := ltOutput + COPYSTR(ltInput, 1, liFindFirst - 1);
                ltOutput := ltOutput + ltWith;
                ltInput := DELSTR(ltInput,1,liFindFirst + liWhatLen - 1);
                liFindFirst := STRPOS(ltInput, ltWhat);
             END;
             ltOutput := ltOutput + ltInput;
          END ELSE BEGIN
             ltOutput := ltInput;
          END;
        END;
    
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • juanborrasjuanborras Member Posts: 35
    Hi!

    yes! that's what I'm looking for, thanks a lot!

    Juan
  • mootsoomootsoo Member Posts: 70
    Hey all!
    i need some help, i hope someone will help me.
    i want to convert date to string, in xml port. my data type is text but it takes date.
    there is error : "text := date"
    and i want to convert date to text.
    is it possible?

    tnx all!
    bye my work, bye navision
  • garakgarak Member Posts: 3,263
    To convert Date to Text u can use:
    TextVariable := format(dateVariable);
    

    To convert a regular Date Expression from Text to date you can use evaluate
    evaluate(dateVariable,TextVariable);
    

    Regards
    Do you make it right, it works too!
  • mootsoomootsoo Member Posts: 70
    WOW, thanks!
    bye my work, bye navision
  • garakgarak Member Posts: 3,263
    Please and welcome
    Do you make it right, it works too!
Sign In or Register to comment.