String function Pos

edited 6:54PM in FastReport 3.0
I don't know why string function always return 0 (zero).

I wrote next in memo field: [IntToStr(Pos('go home boy','m'))] and returns me 0 instead 5

Comments

  • edited 6:54PM
    rotarp wrote:
    I don't know why string function always return 0 (zero).

    I wrote next in memo field: [IntToStr(Pos('go home boy','m'))] and returns me 0 instead 5

    Substring 'm' must be first parameter of function Pos
    So, the right code will look like
    [IntToStr(Pos('m','go home boy'))] 
    

    and in this case Pos returns 6 (not 5) because first char in string has index=1 (not ZERO).

    from Delphi help you can find out detailed info

    function Pos(Substr: string; S: string): Integer;
    Description

    In Delphi, Pos searches for a substring, Substr, in a string, S. Substr and S are string-type expressions.

    Pos searches for Substr within S and returns an integer value that is the index of the first character of Substr within S. Pos is case-sensitive. If Substr is not found, Pos returns zero.

    The PosEx function is similar to Pos, but provides additional features and can be used in C++ code.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.