Ignore:
Timestamp:
Apr 29, 2008, 6:30:38 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
dac5c5
Parents:
661288
Message:

config::Load..() now get filename instead of pointer to file, bugfix for switch structure in command line parsin
g.

Load..() functions RetrieveConfigPath() - the path that is given for the config file on the command line - and p
ut it into config::configpath. This is necessary to allow later for a sensible storage path under fragmentation, as the old with defaultpath from the file was stupid, if the given path was wrong (whereas the config path always exists).
Switch structure in parsing the command line options needed to make better use of the already present flag in or
der to know when to just save and stop and when to continue to the interactive menu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/builder.cpp

    r661288 rf5306f  
    748748  char *ConfigFileName = NULL;
    749749  char *ElementsFileName = NULL;
    750   int flag = 1;
     750  int flag = 0;
    751751  int Z;
    752752  int j, axis, count, faktor;
     
    773773          case 'H':
    774774          case '?':
     775            flag=2;
    775776            cout << "MoleCuilder suite" << endl << "==================" << endl << endl;
    776777            cout << "Usage: " << argv[0] << "[-{acepsthH?vfrp}] [further arguments] [config file]" << endl;
     
    785786            cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
    786787            cout << "\t-v/-V\t\tGives version information." << endl;
    787             return 0;
     788            cout << "Note: config files must not begin with '-' !" << endl;
    788789            break;
    789790          case 'v':
    790791          case 'V':
     792            flag=2;
    791793            cout << argv[0] << " " << VERSIONSTRING << endl;
    792794            cout << "Build your own molecule position set." << endl;
    793             return 0;
    794795            break;
    795796          case 'e':
     
    827828        }
    828829      } else {
     830        test.close();
    829831        ConfigFileName = argv[argc-1];
    830832        cout << Verbose(1) << "Specified config file found, parsing ...";
    831         switch (configuration.TestSyntax(&test, periode, mol)) {
     833        switch (configuration.TestSyntax(ConfigFileName, periode, mol)) {
    832834          case 1:
    833835            cout << "new syntax." << endl;
    834             configuration.Load(&test, periode, mol);
     836            configuration.Load(ConfigFileName, periode, mol);
    835837            config_present = present;
    836838            break;
    837839          case 0:
    838840            cout << "old syntax." << endl;
    839             configuration.LoadOld(&test, periode, mol);
     841            configuration.LoadOld(ConfigFileName, periode, mol);
    840842            config_present = present;
    841843            break;
     
    844846            config_present = empty;
    845847       }
    846         test.close();
    847848      }
    848849    } else
     
    856857          switch(argv[argptr-1][1]) {
    857858            case 'p':
     859              flag = 1;
    858860              cout << Verbose(1) << "Parsing xyz file for new atoms." << endl;
    859861              if (!mol->AddXYZFile(argv[argptr++]))
     
    871873            switch(argv[argptr-1][1]) {
    872874              case 't':
     875                flag = 1;
    873876                cout << Verbose(1) << "Translating all ions to new origin." << endl;
    874877                for (int i=0;i<3;i++)
     
    878881                break;
    879882              case 'a':
     883                flag = 1;
    880884                cout << Verbose(1) << "Adding new atom." << endl;
    881885                first = new atom;
     
    894898                break;
    895899              case 's':
     900                flag = 1;
    896901                j = -1;
    897902                cout << Verbose(1) << "Scaling all ion positions by factor." << endl;
     
    914919                break;
    915920              case 'c':
     921                flag = 1;
    916922                j = -1;
    917923                cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
     
    930936                break;
    931937              case 'r':
     938                flag = 1;
    932939                cout << Verbose(1) << "Converting config file from supposed old to new syntax." << endl;
    933940                break;
    934941              case 'f':
    935942                int i,j;
    936                 flag = 0;
     943                flag = 1;
    937944                if (argc > argptr+3) {
    938945                  cout << Verbose(0) << "Creating connection matrix..." << endl;
     
    9981005          } else argptr++;
    9991006        } while (argptr < (argc-1));
    1000     if (flag)
     1007    if (flag == 1)  // 1 means save and exit
    10011008      SaveConfig(ConfigFileName, &configuration, periode, mol);
    1002     delete(mol);
    1003     delete(periode);
    1004     return (0);
     1009    if (flag > 1) { // 2 means just exit
     1010      delete(mol);
     1011      delete(periode);
     1012      return (0);
     1013    }
    10051014  }
    10061015
Note: See TracChangeset for help on using the changeset viewer.