qp.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
FINDSTR.PAS
  Example Contents Index                                    Back
 
PROGRAM findstr;
 
{ FINDSTR.PAS illustrates string search functions, including:
 
      Concat    Copy    Delete    Insert    Length    Pos
}
 
CONST
 
    program_name = 'FINDSTR ';
    program_desc = ' demonstrates string-handling routines.';
    str1     : STRING = 'essence';
    str2     : STRING = 'soul';
    sentence : STRING = 'Brevity is the essence of wit.';
    author   : STRING = ' -- William Shakespeare';
    fmt1     : STRING = '---------1---------2---------3---------4';
    fmt2     : STRING = '1234567890123456789012345678901234567890';
    ch       : Char   = 'n';
 
VAR
    result : Integer;
 
BEGIN
 
    Writeln( program_name, program_desc );
    Writeln;
 
    Writeln( 'String to be searched:' );
    Writeln;
    Writeln( '        ', sentence );
    Writeln( '        ', fmt1 );
    Writeln( '        ', fmt2 );
    Writeln( 'String has ', Length( sentence ), ' characters.' );
    Writeln;
    Writeln( 'Function:         Pos' );
    Writeln( 'Search string:    ', ch );
    Writeln( 'Result:           ', ch, ' found at position ',
             Pos( ch, sentence ) );
    Writeln;
    Writeln( 'Search string:    ', str1 );
    result := Pos( str1, sentence );
    Writeln( 'Result:           ', str1, ' found at position ', result );
    Writeln;
    Writeln( 'Function:         Delete' );
    Writeln( 'String to delete: ', str1 );
    Delete( sentence, result, Length( str1 ) );
    Writeln( 'Result:           ', sentence );
    Writeln;
    Writeln( 'Function:         Insert' );
    Writeln( 'String to insert: ', str2 );
    Insert( str2, sentence, result );
    Writeln( 'Result:           ', sentence );
    Writeln( '                  ', fmt1 );
    Writeln( '                  ', fmt2 );
    Writeln;
    Writeln( 'Function:         Copy' );
    Writeln( 'Start and length of substring: 24, 3' );
    Writeln( 'Result:           ', Copy( sentence, 24, 3 ) );
    Writeln;
    Writeln( 'Function:         Concat' );
    Writeln( 'String to append: ', author );
    sentence := Concat (sentence, author );
    Writeln( 'Result:           ', sentence );
    Writeln;
 
END.