Concept Explanation: Function Libraries

Printer-friendly version

Some functions require more than one parameter. The way you can how many parameters is needed is by looking at the documentation. The first source of information is the Function Library within RobotC. This will generate when you compile a program. RobotC will also hide some of the more advanced functions from this list. To see them you need to change your menu level.

While you can go to Super User for a complete list, you might be overwhelmed by the number of functions available to you. Once you have the proper menu level set, you can find the function in the library and hover your mouse over it for a brief example. Let's try this for your next function.

-- nxtDisplayString --
  • Function Syntax: nxtDisplayString( nLineNumber , sFormatString );

  • Usage: Display a string (2nd parameter) on the specified (1st parameter) line of the NXT LCD.

To better decode this tooltip, we also need an example of the function in use.


  1. nxtDisplayString(1,"Hello World");

If you match up the example with the tooltip, you can then see what parameters are controlling this function. When looking at the parameters in the tooltip, the first letter of the parameter determines the data type. "n" is for integers, and "s" is for strings. The rest of the text in the label is a hint on what that parameter controls. When working with unknown functions, you may have to experiment to figure out how a function works.

When we talk about using a function, we add simple notes on how to use it. For this function, the first parameter is labeled "nLineNumber". This means that the first parameter must be an integer and will designate what line the command will display on. The second parameter is labeled "sFormatString". This means the second parameter must be a string which is what the function will put on the screen. The other parameters, "param1" and "param2", are optional and are only used in certain situations. We'll come back to this in later lessons.

If you still need help with using a particular function, there are a number of communities online that can help. We mention this because there is not a good repository of function definitions available at this time. The function library can help you get started, but is not your only resource.