Executes commands read from an ascii file as they were typed in the console. Empty lines and lines beginning with # are ignored.
- Parameters
-
fname | Filename of file to read |
args | Arguments to be passed to the script. A search and replace will be done for ${arg} |
- Returns
- -1 if the file couldn't be read and the number of commands for which Process() was callled otherwise
Definition at line 1446 of file Readline.cc.
References buffer, fCommandLog, fLabel, fScript, fScriptDepth, fSection, fStopScript, IsStopped(), ProcessLine(), SetSection(), Stop(), and Tools::Trim().
Referenced by GetUpdatePrompt(), and Process().
1461 const size_t p = name.find_last_of(
':');
1462 if (p!=string::npos)
1464 fLabel = atoi(name.substr(p+1).c_str());
1465 name = name.substr(0, p);
1468 ifstream fin(name.c_str());
1490 while (getline(fin, buffer,
'\n') && !
fStopScript)
1498 if (buffer==
"quit" || buffer==
".q")
1505 for (
auto it=args.begin(); it!=args.end(); it++)
1507 const string find =
"${"+it->first+
"}";
1508 for (
size_t pos=0; (pos=buffer.find(find, pos))!=string::npos; pos+=find.length())
1509 buffer.replace(pos, find.size(), it->second);
1516 fCommandLog <<
"# " <<
Time() <<
" - " << name <<
" (FINISHED[" << fScriptDepth<<
"])" << endl;
1518 if (--fScriptDepth==0)
Adds some functionality to boost::posix_time::ptime for our needs.
std::ofstream fCommandLog
Maximum number of lines in the history file.
virtual void SetSection(int)
static std::string fScript
void ProcessLine(const std::string &str)