예제 #1
0
static void f8_key_prog(int x)
{  
  static char FUNC[75]="2*2  % Press ESC to finish, F1 for help, ENTER to calculate";  
  int npos=1;
  void * pscr;
  get_text(1,20,80,21,&pscr);
  scrcolor(Red,White);   
  goto_xy(1,20); print("CALC : ");
  goto_xy(1,21); print("result=");
  scrcolor(Black,White);
  for(;;)
  { double res;
    int err; 
    int key;
    goto_xy(9,20); key=str_redact(FUNC,npos,70); 
    if(key==KB_ESC) break;
    else if(key==KB_F1)  show_help("n_calc");
    else if(key==KB_ENTER)
    {  goto_xy(8,21); 
       err=calcExpression(FUNC,rd_num,&res);
       goto_xy(9,21);
       if(err) {print("Erorr: %s",errmesstxt(err)); npos=rderrpos;}
       else  print("%E                     ",res); 
    }
  }
  put_text(&pscr);
}
예제 #2
0
static void errorMessage( char * fieldName, char * format, ...)
{ 
   char  dump[200];
   va_list args;
   va_start(args,format);
   vsprintf(dump,format,args);
   va_end(args);

   if (strcmp(dump,"*") == 0)
    sprintf(errorText,"Error in table '%s' line %d field '%s'\nposition %u: %s",
	  tabName,nLine,fieldName,rderrpos,errmesstxt(rderrcode) );
   else
	sprintf(errorText,"Error in table '%s' line %d field '%s' \n %s",
		  tabName,nLine,fieldName,dump);
   if(blind) printf("ERROR:%s\n",errorText); else messanykey(2,10,errorText);
}
예제 #3
0
int initScales(char*sF,char*sR,char * mess)
{  char *ch;
   char *command;
    
   if(scaleLib) dlclose(scaleLib); 
   scaleCC_=NULL;
   
   fout=fopen("scale.c","w");
   if(!fout){ if(mess) sprintf(mess,"can't open file scale.c for writing");  return -1;}
   int pos;
   NX=0;
   fprintf(fout,"#include<math.h>\n");  
   fprintf(fout,"#include\"%s/include/nType.h\"\n",rootDir);
   fprintf(fout,"#define min(x,y) (x<y? x:y)\n");
   fprintf(fout,"#define max(x,y) (x>y? x:y)\n"); 
   fprintf(fout,"extern void ScaleCC(REAL*, double (*calcPV)(char,char*,double*), double*,double*,double*);\n");
   fprintf(fout,"void ScaleCC(REAL*modelVal, double (*calcPV)(char,char*,double*), double *pvect,double *QF,double *QR)\n");
   fprintf(fout,"{ double ");
   pos=ftell(fout);
   fprintf(fout,"         \n");
   fprintf(fout," double Qfactorization;\n");   
   ch=readExpression(sF,rd_num_,act_num_,free);
   if(!ch) 
   { fclose(fout); 
     if(mess)
     { 
       sprintf(mess,"Error in Qfact scale definition: position %d :\n%s", 
                    rderrpos, errmesstxt(rderrcode));
     }
     return rderrpos;    
   } 
   fprintf(fout," *QF= %s;\n",ch);
   fprintf(fout," Qfactorization=%s;\n",ch);  
   ch=readExpression(sR,rd_num_R,act_num_,free);
   
   if(!ch) 
   { fclose(fout); 
     fout=NULL;
     if(mess)
     { 
       sprintf(mess,"Error in Qren scale definition: position %d :\n%s", 
                    rderrpos, errmesstxt(rderrcode));
     }
     return rderrpos;    
   } 
   fprintf(fout," *QR= %s;\n",ch);
      
   fprintf(fout,"}\n");
   fseek(fout,pos,SEEK_SET);
   fprintf(fout,"X[%d];",NX+1);
   fclose(fout);
   free(ch);
   
    command=malloc(strlen(rootDir)+100);
    sprintf(command,". %s/FlagsForSh; $CC $CFLAGS $SHARED -o scale.so scale.c",rootDir);
    system(command);
    free(command);
    scaleLib=dlopen("./scale.so",RTLD_NOW);
    if(!scaleLib)
    {
       if(mess) sprintf(mess,"Can't load shared library for QCD scale"); 
       return -3;
    } 
    scaleCC_=dlsym(scaleLib,"ScaleCC");
    if(!scaleCC_)
    {  
       if(mess) sprintf(mess,"Problem in library scale.so ");
       return -4;
    }
    return 0;
}