   * SQUARE ROOT COMMAND FILE (JOHN HATHAWAY 8/5/82)
   * HANDLES ANY NUMBER GREATER THAN 0
   *
   * Modified by Roger Brown for dBASE II RCP/M demo.
   *

SET TALK OFF 
* NEEDS A DATABASE OPEN
USE SQRT
SET INTE OFF
SET COLON OFF
STORE "Y" TO YN
ERASE
STORE "Square Root demo by John Hathaway" TO HDNG
STORE (WIDE-LEN(HDNG))/2 TO PA1
@ 3,PA1 SAY HDNG
STORE F TO MSG20
DO WHILE YN = "Y"
	STORE 0 TO IN
	@ 8,10 SAY "Input a number between 0 and 100 : "
	@ 8,45 GET IN PICT "##"
	READ
	IF MSG20
		@ 20,0
	ENDIF
	IF IN = 0
		@ 20,10 SAY "The square root of zero ? - don't be silly..."
		STORE T TO MSG20
		LOOP
	ELSE
		IF IN < 1
			@ 20,10 SAY "Greater than 0 and less than 100 please..."
			STORE T TO MSG20
			LOOP
		ELSE
			STORE F TO MSG20
		ENDIF
	ENDIF
 	STORE 0 TO a
	STORE in*.5 TO out
	STORE 0 TO z5

	    * YOU CAN INCREASE OR DECREASE NUMBER OF LOOPS HERE TO
	    * CHANGE ACCURACY.  I'VE FOUND 7 TO BE ADEQUATE

        DO WHILE a<7 
            STORE (in/out-out)*.5 TO w5
            STORE out+w5 TO out
            STORE w5 TO z5
            STORE a+1 TO a
        ENDDO
	@ 12,10 SAY "The square root of  "
	@ 12,29 SAY IN USING "##"
	@ 12,32 SAY " is "
	@ 12,37 SAY OUT 
	@ 16,10 SAY "Want to try another ? (Y/N)"
	@ 16,38 GET YN PICT "!"
	READ
ENDDO
DO DEMOCHC

