Other useful functions in the command interpreter

9.1 Memory management

The library contains some functions which can be used to create and delete easily arrays. The types of variables are the same as for objects (cf. section 5):

Type 0 : integers

Type 1 : simple precision real numbers

Type 2 : double precision real numbers

Type 3 : simple precision complex numbers with usual coordinates

Type 4 : double precision complex numbers with usual coordinates

Type 5 : simple precision complex numbers with polar coordinates

Type 6 : double precision complex numbers with polar coordinates

(the way complex numbers are represented is explained in section 10). The functions avalaible to create arrays are the following :

int*          int_alloc1 (int);
int**        int_alloc2 (int, int);
int***       int_alloc3 (int, int, int);
int****     int_alloc4 (int, int, int, int);
float*          float_alloc1 (int);
float**        float_alloc2 (int, int);
float***       float_alloc3 (int, int, int);
float****     float_alloc4 (int, int, int, int);
double*          double_alloc1 (int);
double**        double_alloc2 (int, int);
double***       double_alloc3 (int, int, int);
double****     double_alloc4 (int, int, int, int);
fcomplex*        fcomplex_alloc1 (int);
fcomplex**       fcomplex_alloc2 (int, int);
fcomplex***     fcomplex_alloc3 (int, int, int);
fcomplex****    fcomplex_alloc4 (int, int, int, int);
dcomplex*        dcomplex_alloc1 (int);
dcomplex**      dcomplex_alloc2 (int, int);
dcomplex***     dcomplex_alloc3 (int, int, int);
dcomplex****   dcomplex_alloc4 (int, int, int, int);
fpolaire*          fpolaire_alloc1 (int);
fpolaire**        fpolaire_alloc2 (int, int);
fpolaire***       fpolaire_alloc3 (int, int, int);
fpolaire****     fpolaire_alloc4 (int, int, int, int);
dpolaire*          dpolaire_alloc1 (int);
dpolaire**        dpolaire_alloc2 (int, int);
dpolaire***       dpolaire_alloc3 (int, int, int);
dpolaire****     dpolaire_alloc4 (int, int, int, int);

The types  fcomplex , dcomplex , fpolaire , dpolaire   represent complex numbers (cf. section 10). The number in the name of the function gives the number of dimensions of the created array. The parameters are the dimensions (which must be positive) (the indices which are allowed in such an array can vary between 0 and the given dimensions). For example

float    ***xx;

xx = float_alloc3(2,4,3);

will create a 3-dimensional array. The indices allowed for the first dimension can be 0, 1, or 2, and so on. There is a unique function to delete all such arrays. It is the macro XFREE .

XFREE(xx);

will free the memory used to store the array  xx .

It is possible to create arrays with more than 4 dimensions, using the function

memm*   memm_alloc (int*, int, int);

(the structure memm is defined in the file  interp.h ). To create an array with  n  dimensions we need an array  d  which contains the dimensions of the array : d[0] ,..., d[n-1] must be positive numbers. Then we create a  memm  structure :

memm* M;

M = memm_alloc(d, n, type);

where type is the type of variables of the array (an integer between 0 and 6). To get the array we use then member  ad  of the structure   M[0] . For example, if it is an array of double precision real numbers with 5 dimensions (i.e n =5  and  type =2) we have

double    *****xx;

xx = (double*****) M[0].ad;
 
 
 



9.2 Other functions

Most of these functions correspond to commands. They are of the following type

int  func(int argc, char * argv[]);

where  argc  is the number of arguments (including the name of the command) and  argv[]  the arguments. It is possible to call these functions (to simulate the execution of the corresponding commands). The list of commands is given in section 8.
 



int   add_objet(int argc, char * argv[]);

This function corresponds to the command  add .



int   assign_membre (int argc, char * argv[]);

This function corresponds to the command  assign .



char*   ch_copy (char *);

This function returns a copy of its argument (and allocates memory for this).



int   Cmult_objet (int argc, char * argv[]);

This function corresponds to the command  cmultiply .



int   copie_objet (int argc, char * argv[]);

This function corresponds to the command  copy .



int   convert_int (char *);

This function sends the argument to the expression evaluator and returns its evaluation casted to an int (see section 6).



double   convert_float (char *);

This function sends the argument to the expression evaluator and returns the evaluation (see section 6).



int   delcom (int argc, char * argv[]);

This function corresponds to the command  delcom .



int   deldon (int argc, char * argv[]);

This function corresponds to the command  deldat .



int   delprog_cmd (int argc, char * argv[]);

This function corresponds to the command  delprog .



int   delres (int argc, char * argv[]);

This function corresponds to the command  delres .



int   desassign_membre (int argc, char * argv[]);

This function corresponds to the command  desassign .



int   detruit_obj (int argc, char * argv[]);

This function corresponds to the command  destroy .



void   error_mess (int);

This function prints the message whose number is the argument. These messages are defined in the initialization file (cf. section 2).



int   init_obj (int);

This function deletes all the objects of the type given in argument.



int   init_str (int);

This function deletes all the structures of the type given in argument.



int   load_cmd (int argc, char * argv[]);

This function corresponds to the command  load .



int   mult_objet (int argc, char * argv[]);

This function corresponds to the command  multiply .



int   obj_create (int argc, char * argv[]);

This function corresponds to the commands creating objects (cf. section 5).



void   print (char *, ...);

This function is a version of  printf  (only the flags  %d , %f  and  %s  are supported) with the following modifications : if the interpreter is running silently (for example inside a silent program or after the command  silence ... ) nothing will be printed. Moreover if a monitor file has been defined this function will also print in this file.



void   read_char (char *);

This function can be used instead of  scanf  to read input (character strings). It will behave like  scanf  if the interperter is used in an interactive way, but differently if it is running a program (cf. section 3.6.3).



void   read_float (float *);

This function can be used instead of  scanf  to read input (floating point numbers). It will behave like  scanf  if the interperter is used in an interactive way, but differently if it is running a program (cf. section 3.6.3).



void   read_int (int *);

This function can be used instead of  scanf  to read input (integers). It will behave like  scanf  if the interperter is used in an interactive way, but differently if it is running a program (cf. section 3.6.3).



int   restore_cmd (int argc, char * argv[]);

This function corresponds to the command  restore .



int   S_convert_int (char *);

This function is used to manipulate hidden variables of the expression evaluator (cf. section 6).



int   S_convert_float (char *);

This function is used to manipulate hidden variables of the expression evaluator (cf. section 6).



int   shell_cmd (int argc, char * argv[]);

This function corresponds to the command  shell .



int   sketch_obj (char *, int *);

This function is used to manipulate objects (cf.  section 5.3).



int   sketch_obj_restr (char *, int *, int);

This function is used to manipulate objects (cf.  section5.3).



int   sketch_struc (int, int, char *, int *);

This function is used to manipulate structures (cf.  section 5.9).



int   struc_create (int argc, char * argv[]);

This function corresponds to the commands creating structures (cf.  section 5.9).



int   sub_objet (int argc, char * argv[]);

This function corresponds to the command  substract .



int   svg_cmd (int argc, char * argv[]);

This function corresponds to the command  svg .



int   undef_cmd (int argc, char * argv[]);

This function corresponds to the command  undef .



 
 
 

Main page
Chapters   1   2   3   4   5   6   7   8    9    10   11