HP OpenVMS SystemsC Programming Language 
HP C

Previous  Contents  Index 
The <curses.h> header file defines variables and constants useful for implementing Curses (see Table 62).
Name  Type  Description 

curscr  WINDOW *  Window of current screen 
stdscr  WINDOW *  Default window 
LINES  int  Number of lines on the terminal screen 
COLS  int  Number of columns on the terminal screen 
ERR    Flag (0) for failed routines 
OK    Flag (1) for successful routines 
TRUE    Boolean true flag (1) 
FALSE    Boolean false flag (0) 
_BLINK    Parameter for setattr and clrattr 
_BOLD    Parameter for setattr and clrattr 
_REVERSE    Parameter for setattr and clrattr 
_UNDERLINE    Parameter for setattr and clrattr 
For example, you can use the predefined macro ERR to test the success or failure of a Curses function. Example 64 shows how to perform such a test.
Example 64 Curses Predefined Variables 

#include <curses.h> WINDOW *win1, *win2, *win3; main() { initscr(); win1 = newwin(10, 10, 1, 5); . . . if (mvwin(win1, 1, 10) == ERR) addstr("The MVWIN function failed."); . . . endwin(); } 
In Example 64, if the mvwin function fails, the program adds a string to stdscr that explains the outcome. The Curses mvwin function moves the starting position of a window.
In the UNIX system environment, you can use Curses functions to move the cursor across the terminal screen. With other implementations, you can either allow Curses to move the cursor using the move function, or you can specify the origin and the destination of the cursor to the mvcur function, which moves the cursor in a more efficient manner.
In HP C for OpenVMS Systems, the two functions are functionally equivalent and move the cursor with the same efficiency.
Example 65 shows how to use the move and mvcur functions.
Example 65 The Cursor Movement Functions 

#include <curses.h> main() { initscr(); . . . (1) clear(); (2) move(10, 10); (3) move(LINES/2, COLS/2); (4) mvcur(0, COLS1, LINES1, 0); . . . endwin(); } 
Key to Example 65:
The following program example shows the effects of many of the Curses macros and functions. You can find explanations of the individual lines of code, if not selfexplanatory, in the comments to the right of the particular line. Detailed discussions of the functions follow the source code listing.
Example 66 shows the definition and manipulation of one userdefined window and stdscr .
Example 66 stdscr and Occluding Windows 

/* CHAP_6_STDSCR_OCCLUDE.C */ /* This program defines one window: win1. win1 is */ /* located towards the center of the default window */ /* stdscr. When writing to an occluding window (win1) */ /* that is later erased, the writing is erased as well. */ #include <curses.h> /* Include header file. */ WINDOW *win1; /* Define windows. */ main() { char str[80]; /* Variable declaration.*/ initscr(); /* Set up Curses. */ noecho(); /* Turn off echo. */ /* Create window. */ win1 = newwin(10, 20, 10, 10); box(stdscr, '', ''); /* Draw a box around stdscr. */ box(win1, '', ''); /* Draw a box around win1. */ refresh(); /* Display stdscr on screen. */ wrefresh(win1); /* Display win1 on screen. */ (1) getstr(str); /* Pause. Type a few words! */ mvaddstr(22, 1, str); (2) getch(); /* Add string to win1. */ mvwaddstr(win1, 5, 5, "Hello"); wrefresh(win1); /* Add win1 to terminal scr. */ getch(); /* Pause. Press Return. */ delwin(win1); /* Delete win1. */ (3) touchwin(stdscr); /* Refresh all of stdscr. */ getch(); /* Pause. Press Return. */ endwin(); /* Ends session. */ } 
Key to Example 66:
Figure 64 An Example of the getch Macro
Table 71 lists and describes the math functions in the HP C RunTime Library (RTL). For more detailed information on each function, see the Reference Section.
Function  Description 

abs  Returns the absolute value of an integer. 
acos  Returns the arc cosine of its radian argument, in the range [0,pi] radians. 
acosd (ALPHA, I64)  Returns the arc cosine of its radian argument, in the range [0,180] degrees. 
acosh (ALPHA, I64)  Returns the hyperbolic arc cosine of its argument. 
asin  Returns the arc sine of its radian argument in the range [  pi/2,pi/2] radians. 
asind (ALPHA, I64)  Returns the arc sine of its radian argument, in the range [ 90,90 ] degrees. 
asinh (ALPHA, I64)  Returns the hyperbolic arc sine of its argument. 
atan  Returns the arc tangent of its radian argument, in the range [  pi/2,pi/2] radians. 
atand (ALPHA, I64)  Returns the arc tangent of its radian argument, in the range [ 90,90 ] degrees. 
atan2  Returns the arc tangent of y/ x (its two radian arguments), in the range [  pi,pi] radians. 
atand2 (ALPHA, I64)  Returns the arc tangent of y/ x (its two radian arguments), in the range [ 180,180 ] degrees. 
atanh (ALPHA, I64)  Returns the hyperbolic arc tangent of its radian argument. 
cabs  Returns the absolute value of a complex number as: sqrt ( x ^{2} + y ^{2}) . 
cbrt (ALPHA, I64)  Returns the rounded cube root of its argument. 
ceil  Returns the smallest integer greater than or equal to its argument. 
copysign (ALPHA, I64)  Returns its first argument with the same sign as its second. 
cos  Returns the cosine of its radian argument in radians. 
cosd (ALPHA, I64)  Returns the cosine of its radian argument in degrees. 
cosh  Returns the hyperbolic cosine of its argument. 
cot  Returns the cotangent of its radian argument in radians. 
cotd (ALPHA, I64)  Returns the cotangent of its radian argument in degrees. 
drand48 , erand48 , jrand48 , lrand48 , mrand48 , nrand48  Generates uniformly distributed pseudorandom number sequences. Returns 48bit, nonnegative, doubleprecision floatingpoint values. 
erf (ALPHA, I64)  Returns the error function of its argument. 
erfc (ALPHA, I64)  Returns (1.0  erf (x )). 
exp  Returns the base e raised to the power of the argument. 
expm1 (ALPHA, I64)  Returns exp (x )  1. 
fabs  Returns the absolute value of a floatingpoint value. 
finite (ALPHA, I64)  Returns 1 if its argument is a finite number; 0 if not. 
floor  Returns the largest integer less than or equal to its argument. 
fmod  Computes the floatingpoint remainder of its first argument divided by its second. 
fp_class (ALPHA, I64)  Determines the class of IEEE floatingpoint values, returning a constant from the <fp_class.h> header file. 
isnan (ALPHA, I64)  Test for NaN. Returns 1 if its argument is a NaN; 0 if not. 
j0, j1, jn (ALPHA, I64)  Computes Bessel functions of the first kind. 
frexp  Calculates the fractional and exponent parts of a floatingpoint value. 
hypot  Returns the square root of the sum of the squares of two arguments. 
initstate  Initializes random number generators. 
labs  Returns the absolute value of an integer as a long int . 
lcong48  Initializes a 48bit uniformly distributed pseudorandom number sequence. 
lgamma (ALPHA, I64)  Computes the logarithm of the gamma function. 
llabs, qabs (ALPHA, I64)  Returns the absolute value of an __int64 integer. 
ldexp  Returns its first argument multiplied by 2 raised to the power of its second argument. 
ldiv, div  Returns the quotient and remainder after the division of their arguments. 
lldiv, qdiv (ALPHA, I64)  Returns the quotient and remainder after the division of their arguments. 
log2 (ALPHA, I64) , log, log10  Returns the logarithm of their arguments. 
log1p (ALPHA, I64)  Computes ln(1+ x) accurately. 
logb (ALPHA, I64)  Returns the radixindependent exponent of its argument. 
nextafter (ALPHA, I64)  Returns the next machinerepresentable number following x in the direction of y. 
nint (ALPHA, I64)  Returns the nearest integral value to the argument. 
modf  Returns the positive fractional part of its first argument and assigns the integral part to the object whose address is specified by the second argument. 
pow  Returns the first argument raised to the power of the second. 
rand, srand  Returns pseudorandom numbers in the range 0 to 2 ^{31}1 . 
random , srandom  Generates pseudorandom numbers in a more random sequence. 
rint (ALPHA, I64)  Rounds its argument to an integral value according to the current IEEE rounding direction specified by the user. 
scalb (ALPHA, I64)  Returns the exponent of a floatingpoint number. 
seed48 , srand48  Initializes a 48bit random number generator. 
setstate  Restarts, and changes random number generators. 
sin  Returns the sine of its radian argument in radians. 
sind (ALPHA, I64)  Returns the sine of its radian argument in degrees. 
sinh  Returns the hyperbolic sine of its argument. 
sqrt  Returns the square root of its argument. 
tan  Returns the tangent of its radian argument in radians. 
tand (ALPHA, I64)  Returns the tangent of its radian argument in degrees. 
tanh  Returns the hyperbolic tangent of its argument. 
trunc (ALPHA, I64)  Truncates its argument to an integral value. 
unordered (ALPHA, I64)  Returns 1 if either or both of its arguments is a NaN; 0, if not. 
y0, y1, yn (ALPHA, I64)  Computes Bessel functions of the second kind. 
Additional math routine variants are supported for HP C on OpenVMS Alpha and I64 systems only. They are defined in <math.h> and are float and long double variants of the routines listed in Table 71.
Float variants take float arguments and return float values. Their names have an f suffix. For example:
float cosf (float x); float tandf (float x); 
Long double variants take long double arguments and return long double values. Their names have an l suffix. For example:
long double cosl (long double x); long double tandl (long double x); 
All math routine variants are included in the Reference Section of this manual.
Note that for programs compiled without /L_DOUBLE=64 (that is, compiled with the default /L_DOUBLE=128), the long double variants of these HP C RTL math routines map to the X_FLOAT entry points documented in the HP Portable Mathematics Library (HPML) manual.
Previous  Next  Contents  Index 