bool ZilchInterface::LoadScriptFromFile(Zilch::Project & project, const std::string & fileName) { TraceFunction("Loading '" + fileName + "'"); bool success = project.AddCodeFromFile(fileName.c_str()); ErrorIf(!success, std::string("AddCodeFromFile - Failed to add script: '" + fileName + "'").c_str()); return success; }
void ZilchInterface::AddScriptFromFile(const std::string & fileName) { // Look for duplicate for (auto& script : Scripts) { if (script.Name == fileName) return; } TraceFunction("Added '" + fileName + "'"); // Open the file std::ifstream file(fileName); if (file) { // Read the string std::string code((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>())); // Close the file file.close(); // Create the struct ScriptInfo script(fileName, code); // Add it Scripts.push_back(script); } }
void ZilchInterface::AddScript(const std::string & title, const std::string & code) { // Look for duplicate for (auto& script : Scripts) { if (script.Name == title) return; } TraceFunction("Added '" + title + "'"); // Create the struct ScriptInfo script(title, code); // Add it Scripts.push_back(script); }
//--------------------------------------------------------------------------- void TPolFuncFrame::SetPoint(const TGraphElem *Elem, int X, int Y) { if(const TPolFunc *Func = dynamic_cast<const TPolFunc*>(Elem)) { TTraceType TraceType; switch(ComboBox1->ItemIndex) { case 0: TraceType = ttTrace; break; case 1: TraceType = ttIntersection; break; case 2: TraceType = ttXAxis; break; case 3: TraceType = ttYAxis; break; case 4: TraceType = ttExtremeX; break; case 5: TraceType = ttExtremeY; break; } double t = TraceFunction(Func, TraceType, X, Y, Form1->Data, Form1->Draw); if(_isnan(t)) Edit1->Text = ""; else Edit1->Text = RoundToStr(t, ComboBox1->ItemIndex == 0 ? Property.RoundTo : std::max(8, Property.RoundTo)); } }
bool ZilchInterface::LoadScriptFromString(Zilch::Project & project, const std::string & origin, const std::string & code) { TraceFunction("Loading '" + origin + "'"); project.AddCodeFromString(code.c_str(), origin.c_str()); return true; }
void ZilchInterface::AddLibrary(const Zilch::LibraryRef & library) { TraceFunction("Adding library"); Dependencies.push_back(library); }