//================================================================================ void test_ops(const string& absFilePath) //================================================================================ { //==== parse file content output << "parsing file: " << absFilePath << endl; // StStruct* pou = 0; FunctionBlock* pou = 0; // Function* pou = 0; string SourceFile; BOOL grFile = FALSE; CString extension = CString(absFilePath.c_str()).Right(4); if (extension.Right(4).CompareNoCase(".4gr") == 0) { grFile = TRUE; ExtractHeader(absFilePath, SourceFile); } else { SourceFile = absFilePath; } //=== read file content string buf; readFileContent(SourceFile, buf); string err = parse_string(buf, &pou); StringPos insertPos; bool sectionExists; pou->getVarInsertPos("VAR_INPUT", "", insertPos, sectionExists); // pou->getVarInsertPos("STRUCT", "", insertPos, sectionExists); string varDecl = " NewVar : DINT;\n"; string varDeclSect = "\nVAR_INPUT\n" + varDecl + "END_VAR"; // string varDeclSect = "\nSTRUCT\n" + varDecl + "END_VAR"; if ( sectionExists ) { buf.insert(insertPos, varDecl); } else { buf.insert(insertPos, varDeclSect); } output << buf << endl; if (grFile == TRUE) { string MHFile = "c:\\modifiedHeader.txt"; ofstream modifiedHeader(MHFile.c_str()); modifiedHeader << buf << endl; modifiedHeader.close(); MergeHeader(absFilePath, MHFile, TRUE); } delete pou; }
void DVFrame::SetDataLen( int len ) { Frame::SetDataLen( len ); ExtractHeader(); }