I love to eliminate errors in programs

One more mistake away. The program now correctly detects whether it is in a function or sub

Variables that are outside a function are now formatted correctly

New function added

`FUNCTION Is_Function_or_Sub(BYREF s AS STRING) AS INTEGER`

STATIC X AS LONG

LOCAL s1 AS STRING

LOCAL pbword AS STRING

LOCAL termstr AS STRING

LOCAL i AS INTEGER

s1 = UCASE$(LTRIM$(s))

IF LEFT$(s1, 9) = "FUNCTION " THEN

IF x = 1 THEN EXIT IF

FOR i = 9 TO LEN(s)

termstr = MID$(s, i, 1)

IF termstr = "=" THEN

EXIT FOR

ELSEIF termstr <> " " THEN

x = 1

EXIT FOR

END IF

NEXT i

EXIT IF

ELSEIF LEFT$(s1, 4) = "SUB " THEN

IF x = 0 THEN x = 1

EXIT IF

ELSEIF LEFT$(s1, 4) = "END " THEN

IF X = 1 THEN

findPBWord s, 4, pbword, termstr

pbword = UCASE$(pbword)

IF pbword = "FUNCTION" OR pbword = "SUB" THEN x = 0

END IF

END IF

FUNCTION = X

END FUNCTION

regards Peter