public boolean setComment(int ordinal, String comment) throws IndexOutOfBoundsException {

		StackComponentWrapper comp = getComponent(ordinal);
		String oldComment = comp.getComment();

		if (comment != null) {
			comment = comment.trim();
			if (comment.length() == 0) {
				comment = null;
			}
		}
		if (comment == null) {
			if (oldComment == null) {
				return false;
			}
		}
		else if (comment.equals(oldComment)) {
			return false;
		}

		if (!canDefineComponent(comp.getDataType(), comp.getLength(), comp.getFieldName(),
			comment)) {
			// NOTE: It is unclear if we should clear component here if it previously existed
			clearComponent(ordinal);
		}
		else if (comp.isUndefined()) {
			replace(comp.getOrdinal(), DataType.DEFAULT, 1, null, comment);
		}
		else {
			// Set comment while preserving possible partial storage serialization
			String partialSerializedStorage = comp.getPartialStorageSerialization(true);
			comment = StringUtils.join(partialSerializedStorage, comment);
			comp.dtc.setComment(comment);
		}
		return true;
	}
Sets the comment at the specified ordinal.

@param ordinal the ordinal
@param comment the new comment.
@return true if comment change was successful, else false
@throws IndexOutOfBoundsException if specified ordinal is out of range
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackFrameDataType.java