The program is:

! Write a function that compares two string parameters,

! returning one if they are equal and zero if not equal.

! Test your function using the following pairs of string values:

! "abc", "xyz";"aaa", "aaa"; "abc", "abcdef"; "abc", "ABC"

 

DECLARE FUNCTION compare$

SET COLOR "blue"

PRINT "Equal strings have value one, otherwise zero."

DO while more data

READ x$,y$

SET COLOR "red"

PRINT "The strings "; x$ ; " and ";y$; " have value "; compare$ (x$,y$)

LOOP

DATA "abc", "xyz","aaa", "aaa", "abc", "abcdef", "abc", "ABC"

END

 

EXTERNAL function compare$(z$,w$)

IF z$ = w$ then

LET compare$ = "one"

ELSE

LET compare$ = "zero"

END IF

END FUNCTION

The output is:

Equal strings have value one, otherwise zero.

The strings abc and xyz have value zero

The strings aaa and aaa have value one

The strings abc and abcdef have value zero

The strings abc and ABC have value zero