'_setwindow func'에 해당되는 글 1건

  1. 2021.11.06 Watcom C Library : _setwindow, signal, sin, sinh, sleep

 

 

Watcom C Library Reference : _setwindow, signal, sin, sinh, sleep

 

 

 

 

_setwindow

 

Synopsis : #include <graph.h> 

              short _FAR _setwindow( short invert, double x1, double y1, double x2, double y2 );

 


Description : The _setwindow function defines a window for the window coordinate system. Window coordinates are specified as a user-defined range of values. This allows for consistent pictures regardless of the video mode.

The window is defined as the region with opposite corners established by the points (x1, y1) and (x2, y2). The argument invert specifies the direction of the y-axis. If the value is non-zero, the y values increase from the bottom of the screen to the top, otherwise, the y values increase as you move down the screen.


The window defined by the _setwindow function is displayed in the current viewport. A viewport is defined by the _setviewport function.


By default, the window coordinate system is defined with the point (0.0, 0.0) located at the lower left corner of the screen, and the point (1.0, 1.0) at the upper right corner.

 

 

Returns : The _setwindow function returns a non-zero value when the window is set successfully; otherwise, zero is returned.

 

 

See Also : _setviewport

 


Example :

#include <conio.h> 

#include <graph.h>


void main( )

{
    _setvideomode( _MAXRESMODE );

    draw_house( "Default window" );

    _setwindow( 1, -0.5, -0.5, 1.5, 1.5 );

    draw_house( "Larger window" );

    _setwindow( 1, 0.0, 0.0, 0.5, 1.0);

    draw_house( "Left side" );

    _setvideomode( _DEFAULTMODE );

}

 


draw_house( char *msg )

{
    _clearscreen( _GCLEARSCREEN );

    _outtext( msg );
    rectangle_w( _GBORDER, 0.2, 0.1, 0.8, 0.6 );

    _moveto_w( 0.1, 0.5 );

    _lineto_w( 0.5, 0.9 );

    _lineto_w( 0.9, 0.5 );

    _arc_w( 0.4, 0.5, 0.6, 0.3, 0.6, 0.4, 0.4, 0.4 );

    _rectangle_w( _GBORDER, 0.4, 0.1, 0.6, 0.4 );

    getch( );

}

 

Classification : PC Graphics
Systems : DOS, QNX

 

 

 

 

 

 

 

signal

 

Synopsis : #include <signal.h> 

              void ( *signal (int sig, void (*func) (int)) ) ( int );

 


Description : The signal function is used to specify an action to take place when certain conditions are detected while a program executes. These conditions are defined to be:

 Condition  Meaning
 SIGABRT  abnormal termination, such as caused by the abort function
 SIGBREAK  an interactive attention (CTRL/BREAK on keyboard) is signalled
 SIGFPE  an erroneous floating-point operation occurs (such as division by zero, overflow and underflow)
 SIGILL  illegal instruction encountered
 SIGINT  an interactive attention (CTRL/C on keyboard) is signalled
 SIGSEGV  an illegal memory reference is detected
 SIGTERM  a termination request is sent to the program
 SIGUSR1  OS/2 process flag A via DosFlagProcess
 SIGUSR2  OS/2 process flag B via DosFlagProcess
 SIGUSR3  OS/2 process flag C via DosFlagProcess

 


An action can be specified for each of the conditions, depending upon the value of the func argument:

 Function  When func is a function name, that function will be called equivalently to the following code sequence.
     /* "sig_no" is condition being signalled */
     signal( sig_no, SIG_DFL );
     (*func) ( sig_no );

 The func function may terminate the program by calling the exit or abort functions or call the longjmp function. Because the next signal will be handled with default handling, the program must again call signal if it is desired to handle the next condition of the type that has been signalled.

 After returning from the signal-catching function, the receiving process will resume execution at the point at which it was interrupted.

 The signal catching function is described as follows:
     void func( int sig_no )
     {
         /* body of function */
     }

 Since signal-catching functions are invoked asynchronously with process execution, the type sig-atomic_t may be used to define variables on which an atomic operation (e.g., incrementation, decrementation) may be performed.
 SIG_DFL  This value causes the default action for the condition to occur.
 SIG_IGN  This value causes the indicated condition to be ignored.

 

When a condition is detected, it may be handled by a program, it may be ignored, or it may be handled by the usual default action (often causing an error message to be printed upon the stderr stream followed by program termination).


When the program begins execution, the equivalent of

 signal( SIGABRT, SIG_IGN );
 signal( SIGFPE, SIG_LDFL );
 signal( SIGILL, SIGL_DFL );
 signal( SIGINT, SIG_IGN );
 signal( SIGSEGV, SIG_LDFL );
 signal( SIGTERM, SIG_LDFL );

is executed.


A condition can be generated by a program using the raise function.

 


Returns : A return value of SIG_ERR indicates that the request could not be handled, and errno is set to the value EINVAL. Otherwise, the previous value of func for the indicated condition is returned.

 

 

See Also : raise

 


Example :

#include <signal.h>


sig_atomic_t signal_count;


void MyHandler( int sig_number )
{
    ++signal_count;

}

 


void main( )

{
    signal( SIGFPE, MyHandler );    /* set own handler  */

    signal( SIGABRT, SIG_DFL );    /* Default action     */

    signal( SIGFPE, SIG_IGN );      /* Ignore condition  */

}

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

sin

 

Synopsis : #include <math.h> 

              double sin( double x );

 


Description :  The sin function computes the sine of x (measured in radians). A large magnitude argument may yield a result with little or no significance.

 

 

Returns : The sin function returns the sine value.

 

 

See Also : acos, asin, atan, atan2, cos, tan

 


Example :

#include <stdio.h> 

#include <math.h>


void main( )

{
    printf( "%f\n", sin(.5) );

}

 


produces the following :
0.479426

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

sinh

 

Synopsis : #include <math.h> 

              double sinh( double x );

 


Description : The sinh function computes the hyperbolic sine of x. A range error occurs if the magnitude of x is too large.

 

 

Returns : The sinh function returns the hyperbolic sine value. When the argument is outside the permissible range, the matherr function is called. Unless the default matherr function is replaced, it will set the global variable errno to ERANGE, and print a "RANGE error" diagnostic message using the stderr stream.

 

 

See Also : cosh, tanh, matherr

 


Example :

#include <stdio.h> 

#include <math.h>


void main( )

{
    printf ("%f\n", sinh (.5) );

}

 


produces the following :
0.521095

 

Classification : ANSI
Systems : All

 

 

 

 

 

 

 

sleep

 

Synopsis : #include <dos.h> 

              void sleep( unsigned seconds );

 


Description : The sleep function suspends execution by the specified number of seconds.

 

 

Returns : The sleep function has no return value.

 

 

See Also : delay

 


Example :

/* The following program sleeps for the  number of seconds specified in argv[1]. */

 

#include <stdlib.h>

#include <dos.h>


void main( )

{
    unsigned seconds;

 

    seconds = (unsigned) strtol( argv[1], NULL, 0 );

    sleep( seconds );

}

 

Classification : WATCOM
Systems : All

 

 

 

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

728x90
반응형
Posted by 전화카드
,