compile subroutine record_lock( TableVar, TableName, Row )

$insert logical
declare subroutine msg
declare function  send_info

Tries = 0
Locked = false$

LOOP
	LOCK TableVar, Row THEN
		Locked = true$
	END ELSE
		Tries += 1
	END
		
UNTIL Locked OR Tries >= 500
REPEAT

IF NOT(Locked) THEN
	IF STATUS() THEN
	   ErrMsg = "Record ":Row:" in File ":TableName:" is locked by your station"
	END ELSE
	   ErrMsg =  "Record ":Row:" in File ":TableName:" is locked by another station"
	END
	MSG(ErrMsg)
END

RETURN
