double ChFunction_Jscript::Get_y (double x) { double ret = 0; // no function: shortcut! if (*this->js_command == 0) return 0.0; // <<<<< // set the x value for the function Set_Variable("x", x); // The standard evaluation of this object won't report errors! // (error reporter will work only if the user does ::Set_Command() ) int m_old_repmode = ChGLOBALS_JS().chjsEngine->chjs_reporter_mode; //if (this->js_error) ChGLOBALS_JS().chjsEngine->chjs_SetReporterMode(0); // NO REPORT! // >>>> EVALUATION // if not yet compiled, compile it! // int ok = ChGLOBALS_JS().chjsEngine->chjs_Eval(this->js_command, &ret); if (!ok) this->js_error = TRUE; else this->js_error = FALSE; //if (this->js_error) ChGLOBALS_JS().chjsEngine->chjs_SetReporterMode(m_old_repmode); // Restore rerror reporter return ret; }
// // void Read_ConfigFile // - // // if the error tally comes up // with any errors it will have // to create a default variable, sorry // void Read_ConfigFile(FILE *f) { char c; char buffer[256]; int c_index = 0; int res=0; char var[80]; int float_flag = 0; int lines_read = 0; while (!feof(f)) { c = fgetc(f); switch(c) { case '#': while(1) { c = fgetc(f); if (c == '\n') break; } // end of the while break; case '[': c_index = 0; while(1) { c = fgetc(f); if (c == ']') break; buffer[c_index] = c; c_index++; if (c == '\n') { lines_read++; break; } // end of if } // end of the while // null terminate the command buffer[c_index]='\0'; res = Process_ConfigFile(buffer); // now add the variable with the value // c = fgetc(f); // get the equals c_index = 0; float_flag = 0; while(1) { c = fgetc(f); // we found a float if (c == 'f') { float_flag = 1; break; } // end of the if // break on a ';' if (c == ';') break; var[c_index] = c; c_index++; if (c == '\n') break; } // end of the while var[c_index] = '\0'; // the final step, send in a // variable Set_Variable(res,var,float_flag); break; default:break; }; // end switch } // end of the while } // end of the function