/* $VER: CompareTexts.ced 1.1 ENG (16-Aug-2000) by A.Greve
**
** Description see CompareTextsStart.ced
*/

OPTIONS RESULTS													/* We need results          */

STATUS PIXELTOPEDGE
actview = RESULT
DO FOREVER														/* Search first View        */
	NEXT VIEW
	STATUS PIXELTOPEDGE
	newview = RESULT
	IF newview <= actview THEN LEAVE							/* ...found !               */
END
STATUS NUMLINES													/* Get number of lines...   */
lines1 = RESULT
NEXT VIEW
STATUS NUMLINES													/* ...of both files         */
lines2 = RESULT
PREVIOUS VIEW

DO FOREVER
	GETLINE
	theline1 = RESULT
	NEXT VIEW
	GETLINE
	theline2 = RESULT
	IF theline1 == theline2 THEN DO								/* Both lines identical ?   */
		STATUS CURSORLINE
		IF RESULT = lines2 THEN DO								/* End of file 2 ?          */
			OKAY1 'Reached end of file 2 !'
			EXIT(0)
		END
		DOWN
		PREVIOUS VIEW
		STATUS CURSORLINE
		IF RESULT = lines1 THEN DO								/* End of file 1 ?          */
			OKAY1 'Reached end of file 1 !'
			EXIT(0)
		END
		DOWN
	END
	ELSE DO														/* Lines not identical      */
		lastpos = MIN(LENGTH(theline1),LENGTH(theline2))		/* Length of shorter line   */
		DO i = 1 TO lastpos										/* Compare char by char     */
			IF SUBSTR(theline1,i,1) ~= SUBSTR(theline2,i,1) THEN
				LEAVE											/* Found position -> leave  */
		END
		CEDTOFRONT
		PREVIOUS VIEW											/* Cursor in file 1 on...   */
		STATUS CURSORLINE
		linenum = RESULT + 1
		LL linenum i											/* ...differing column      */
		EXIT(0)
	END
	LASTKEY
	IF (RESULT ~= -1) & (WORD(RESULT, 1) < 128) THEN DO			/* Key pressed -> end       */
		CEDTOFRONT
		PREVIOUS VIEW
		DM '*** User-Break ***'
		EXIT(0)
	END
END

