Displaying variable values on the VEX IQ LCD Display

Is there a list of all the formatting codes available?

This is one example:
“%f” (float) formatting code for the VEX IQ LCD Display

I specifically need to display the value of a string.

Hi jsan31,

Are you using RobotC or Modkit?

If you are using RobotC, in addition to %f (float) and %d (integer), you can also use %s for strings. For example, this example code is from the RobotC help file:

while(true) // infinite loop:
  string s1 = "ROBOTC"; // create the string named s1, "ROBOTC"
  displayString(3, "%s", s1); // display the string, 's1' on line 3
  sleep(50); // wait 50 milliseconds (helps refresh rate of LCD screen)


  • Art

To add to this, below is a snippet from our string formatting pages in the ROBOTC support docs. I’m currently in the process of adding this to the VEX IQ and VEX Cortex pages (under their respective ‘Display’ pages in the Function Library section(s)) and it should be available for the next build.

		%d or %i
		Signed decimal integer
		Scientific notation (mantise/exponent) using e character
		Scientific notation (mantise/exponent) using E character
		Decimal floating point number
		Signed octal
		String of characters
		Unsigned hexadecimal integer
		Unsigned hexadecimal integer (capital letters)

NOTE on Displaying Digits: When displaying floats, for example, you can tell ROBOTC how many decimals places to display. This is standard across all ‘C’ - like programing languages. For example, if your float is PI (3.14159265), but you only want to dispay “3.14”, your string should contain, “%1.2f”.

The number before the decimal is how many digits before the decimal you wish to display, while the number after the decimal is how many digits after the decimal you wish to display. So “%1.2f” tells us to display one digit before the decimal and two digits after the decimal, with “3.14” as the final result.

The tag can also contain flags, width, .precision and modifiers sub-specifiers, which are optional and follow these specifications:

		Prints a decimal integer
		Prints a decimal integer, at least 6 characters wide
		_ _ _ _ 50
		Prints a floating point number
		Prints a floating point number, at least 6 characters wide
		_ _ _ 50.5
		Prints a floating point number, with at least 2 decimal places
		Prints a floating point number, with at least 6 characters wide and 2 decimal places
		__ 50.50

Note: Underscore ( _ ) character denotes a space.

Code example:

task main()
    int whole = 10;
    float decimal = 3.14;
    string text = "ROBOTC!";

    displayTextLine(0,"Integer: %d", whole);
    displayTextLine(1,"Float: %f", decimal);
    displayTextLine(2,"String: %s", text);
    displayTextLine(3, "Combo: %d, %.4f, %s", whole, decimal, text);