next up previous contents index
Next: Menus Up: Getting input from the Previous: Getting input from the   Contents   Index


Entering variables

This section describes more user-friendly alternatives to the standard C library routine scanf. For simple variables, CCATSL provides the routines ReadIntCL, ReadDoubleCL, and ReadStringCL which open a dialog box, prompt the user and return the input.


ReadIntCL, ReadDoubleCL and ReadStringCL

These routines open a dialog box, prompt the user, and return the value entered, by returning a variable of an appropriate type: (ints for ReadIntCL, doubles for ReadDoubleCL and char*s for ReadStringCL) (see here for information about strings and char* variables.) The routines have almost identical syntax so we will just describe ReadIntCL below:

  int ReadIntCL ( char *p,
  int default);

  p The prompt.
  default The value to use as default.

The return value is the value entered by the user For example:

  
int n;
double d;
char *name;    /* will hold a string   */

n=ReadIntCL("Enter n ",10);                    /* Read in an int   */
d=ReadDoubleCL("Enter the stepsize ",0.0001);  /* Read in a double */
name=ReadStringCL("Enter your name ","");      /* Read in a string */


next up previous contents index
Next: Menus Up: Getting input from the Previous: Getting input from the   Contents   Index
CATAM admin 2010-02-23