private String applyEquate(Instruction instruction, int opIndex, int subOpIndex) {
		if (instruction == null || opIndex == -1) {
			return null;
		}

		Scalar scalar = grabMatchingScalar(instruction, opIndex, subOpIndex);
		if (scalar == null) {
			return null;
		}

		String equateName = action.convertToString(program, scalar, false);
		if (equateName.isEmpty()) {
			return null;
		}

		// Check for same named equate with different value.
		EquateTable equateTable = program.getEquateTable();
		Equate eqt = equateTable.getEquate(equateName);
		if (eqt != null && valuesAreDifferent(eqt, scalar)) {
			return "Couldn't convert to " + equateName + ". " + "Equate named " + equateName +
				" already exists with value of " + eqt.getValue() + ".";
		}

		Address address = instruction.getAddress();
		List<Equate> equates = equateTable.getEquates(address, opIndex);

		// First, clear any existing equates with the same value
		for (Equate equate : equates) {
			if (!valuesAreDifferent(equate, scalar)) {
				// Clears matching equates 
				ClearEquateCmd cmd = new ClearEquateCmd(equate.getName(), address, opIndex);
				cmd.applyTo(program);
			}
		}

		// check if default hex scalar format applies
		if (action.getFormatChoice() == FormatSettingsDefinition.HEX) {
			if (scalar.getSignedValue() >= 0 || action.isSignedChoice() == scalar.isSigned()) {
				return null;
			}
		}

		// Then, add the new equate
		SetEquateCmd cmd = new SetEquateCmd(equateName, address, opIndex, scalar.getValue());
		if (!cmd.applyTo(program)) {
			return "Couldn't convert to " + equateName + ". " + cmd.getStatusMsg();
		}

		return null;
	}
Constructor for the command to convert scalars and data to the user chosen format. The
command will work at a single address or over a selection in the case where the current
location refers to an instruction.  
<br>
Data convert only supports signed/unsigned and defined FormatSettingsDefinitions
on data whose data type is based upon the AbstractIntegerDataType.

@param action The action to pull information from
@param context The action context
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/equate/ConvertCommand.java