home *** CD-ROM | disk | FTP | other *** search
- * Program.: SOFT-CUT.PRG
- * Author..: Kevin Jay Shepherd & Luis A. Castro
- * Date....: 06/26/84
- * Notice..: Copyright 1984, Ashton-Tate, All Rights Reserved
- * Version.: dBASE II, version 2.4x
- * Notes...: Segments a sentence at word boundaries.
- *
- SET TALK OFF
- ERASE
- @ 2, 0 SAY "SEGMENT A SENTENCE AT WORD BOUNDARIES"
- @ 2,72 SAY DATE()
- @ 3, 0 SAY "========================================"
- @ 3,40 SAY "========================================"
- ACCEPT "Enter first word " TO firstword
- ACCEPT "Enter the sentence " TO sentence
- IF firstword = " " .OR. sentence = " "
- SET TALK ON
- RETURN
- ENDIF
- INPUT "Enter desired column width " TO maxwidth
- IF maxwidth < 10
- SET TALK ON
- RETURN
- ENDIF
- *
- * ---Initialize memory variables.
- STORE 1 TO startpos
- STORE maxwidth TO maxpos, backpos
- STORE " " TO spacing
- * ---Initialize the left margin spaces for
- * ---the second and any subsequent lines.
- STORE $( STR( 0, LEN( firstword ) + 1 ),;
- 1, LEN( firstword ) ) + spacing TO indent
- * ---Initialize the first macro string.
- STORE [? firstword + spacing + ] +;
- [$( sentence, startpos, maxpos - 1 )] TO Macro
- STORE F TO finished
- ?
- * ---Now, segment the character string at word boundaries.
- DO WHILE .NOT. finished .AND. backpos >= startpos
- IF $( sentence, backpos, 1 ) = " "
- &Macro
- * ---Re-initialize macro string to indent with blanks.
- STORE [? indent + ] +;
- [$( sentence, startpos, maxpos - 1 )] TO Macro
- * ---Reset the pointers to the next segment.
- STORE maxwidth TO maxpos
- STORE backpos + 1 TO startpos
- STORE backpos + maxwidth TO backpos
- IF backpos > LEN( TRIM( sentence ) )
- * ---The end of the sentence has been encountered.
- * ---Reset back pointer to the length of the sentence.
- STORE LEN( TRIM( sentence ) ) TO backpos
- STORE T TO finished
- ENDIF
- ELSE
- STORE maxpos - 1 TO maxpos
- STORE backpos - 1 TO backpos
- ENDIF
- ENDDO
- * ---Print the last segment.
- IF backpos < startpos
- * ---A word in the sentence was longer than the width.
- ? "THE FOLLOWING WORD IS TOO LONG FOR THE SELECTED WIDTH:"
- ? $( sentence, startpos )
- CANCEL
- ELSE
- * ---Print the last portion of the sentence.
- ? indent + $( sentence, startpos )
- ENDIF
- *
- CLEAR
- SET TALK ON
- RETURN
- * EOF: SOFT-CUT.PRG