' Get the word in the supplied string at the specified position. ' ' MyWord$ = GetWord$( Text$, CursorPosition ) FUNCTION GetWord$(BYVAL Work$, BYVAL Xpos AS INTEGER) ' ** Check for valid position IF Xpos > LEN(Work$) OR Xpos < 1 THEN FUNCTION = Work$ EXIT FUNCTION END IF ' ** If at a space, see if we precede a letter, if so get the next ' ** word, otherwise return the space IF ASCII(MID$(Work$, Xpos)) = 32 THEN IF ASCII(MID$(Work$, Xpos)) = 32 THEN FUNCTION = " " EXIT FUNCTION ELSE INCR Xpos END IF END IF ' ** Find the beginning of the word FOR L = Start TO 1 STEP -1 IF ASCII(MID$(Work$, L)) <> 32 THEN ITERATE FOR END IF NEXT L ' ** Find the end of the word FOR R = Start TO LEN(Work$) IF ASCII(MID$(Work$, R)) <> 32 THEN ITERATE FOR END IF NEXT R ' ** Calculate its length Length = R - 1 - L IF Length < 1 THEN EXIT FUNCTION ' ** Return the result FUNCTION = LTRIM$( RTRIM$( MID$(Work$, L+1, Length))) END FUNCTION