none
START_TERMINATOR RRS feed

  • 问题

  • Hi,

    I am reading code that someone else wrote.  It starts with "START_TERMINATOR" followed by code and "END_TERMINATOR"

    What is this and how are we supposed to figure out what this is?  I tried putting  an "if" switch before the start of the code to turn on and off the code within the terminators.  But this did not work.  Is there any way to turn on or off the code?

    Thanks

    Here is the code...

    START_TERMINATOR
    // Convert DBF to CSV assuming no submodel output

    {
      xstring dbNamePrefix;
      xstring dbFileName;
      DBTable db;

      dbNamePrefix = columnOutputFileName();
      const int NumTables = 3;  // Number of tables to be converted

    // list of output table names here (if one does not exist, MoSes will quit without processing the rest):
      const xstring dbSuffix [NumTables] = {"~MAIN~LIAB~UL",
              "~MAIN~CORP",
                 "~MAIN~ASSET"}; 

    // Loop through Convert process for each output table
      for (int i=0; i < NumTables; i++)
      {
     dbFileName = dbNamePrefix + dbSuffix[i];  // set filename
        db.open(dbFileName + ".dbf", true);
        if (db.isOpen())    
       {       
      int i, j, colCount;      
      xstring csvName;      
      ofstream f;      
      DBColumn col;      
            
      csvName = dbFileName + ".csv";      
      f.open(csvName);      
            
      // Set base and precision      
      f.setf(ios::fixed);      
      f.precision(6);      
            
      // write header      
      colCount = db.columnCount();      
      for (i=1; i<colCount; ++i)      
      {      
       col = db.getColumn(i);     
       f << col.getName() << ",";     
      }      
      col = db.getColumn(i);      
      f << col.getName() << endl;      
            
      // print field and one by one due to trimming and precision      
      db.goToRecord(1);      
            
      for (i=1; i<=db.recordCount(); ++i)      
      {      
       for (j=1;j<colCount; ++j)     
       {     
        col = db.getColumn(j);    
        if( col.getType() == NUMBER_TYPE )    
         f << col.asDouble();   
        else    
         f << col.asString().strip(2);   
        f << ",";    
       }     
            
       col = db.getColumn(j);     
       if( col.getType() == NUMBER_TYPE )     
        f << col.asDouble();    
       else     
        f << col.asString().strip(2);    
       f << endl;;     
            
       db.moveNext();     
      }      
            
      f.close();      
      db.close();      
      log_strm << "DBF output file converted to CSV:  " << dbFileName << endl;
     }
     else
       log_strm << "Did not find DBF output file for conversion to CSV:  " << dbFileName << endl;

      }  // end convert dbFileName (next i)
    }        
    END_TERMINATOR

    • 已移动 Jesse Jiang 2012年6月18日 4:42 (发件人:Visual C++ General)
    2012年6月6日 17:45

全部回复

  • They are macros. Right click on the macro name in the IDE and select Go to definition from the context menu.

    http://blog.voidnish.com

    2012年6月6日 18:01
  • Unfortunately all the code is not opened in C++ compiler.  So I don't have an IDE enviornment.

    Is there a way to create a switch to skip this code though?  I noticed that if I did...

    if(x == y){

    START_TERMINATOR... code

    END_TERMINATOR

    }

    To skip the macro does not work.  It still goes through the macro.

    Thanks

    2012年6月6日 19:23
  • Well you need to find out what those macros are defined as. They can be defined to be nothing or they could be an if-check or they could do more complex logic. If your IDE does not support definition lookup, do a solution-wide search to see what those macros are defined as.

    http://blog.voidnish.com

    2012年6月7日 14:57
  • So you are saying, based on the macro definition, an if statment before the macro might now work?  Meaning it might go into the terminator statement even if the "if" statement is false?

    like...

    if(x==y) { START_TERMINATOR ... code ,,, END_TERMINATOR}

    Thanks

    2012年6月7日 19:01
  • Hi Jeffs_Programs,

    According to your reply, you may not use Microsoft Visual Studio to complier your project and you have some questions about the third party macro: START_TERMINATOR, I suggest you post it on the third party forum. Here we only discuss general C++ questions and problems when using Visual Studio, so I will change your thread type to general discussion.

    Thank you for your understanding.

    Regards,

    Elegentin


    If your question has been solved, please mark the answers and close the post. If not, please feel free to post your questions. With regards.


    2012年6月12日 7:56
  • Waht do you mean by "does not work"?  Are you saying you still get compiler diagnostics?  If so, that is expected.  The if statement is an execution time decision.  It has no effect on the compiler which still must compile the code between the braces (in case the if evaluates to true during execution).

    If you want to bypass compiling the code completely, use

    #if 0
    START_TERMINATOR
    ... code
    END_TERMINATOR
    #endif

    2012年6月12日 16:03