Ignore:
Timestamp:
02/18/16 02:32:57 (8 years ago)
Author:
sz
Message:
  • MiniGenotype? extended to handle all Genotype fields contained in .gen files
  • loader_test now displays any MiniGenotype? field instead of the raw genotype when given the field name
  • MiniGenotypeLoader? and stdiofile.o included in SDK_LIB_OBJS
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/_demos/loader_test.cpp

    r382 r473  
    1717if (argc<2)
    1818        {
    19         fprintf(stderr,"Arguments: filename [optional: genotype name or index (1-based)]\n"
    20              "If a genotype is indicated (by providing the optional genotype identifier), the program will output the raw genotype, suitable for Framsticks Theater's genotype viewer mode. If the second optional argument is not given, the genotype names from the file will be listed.\n"
     19        fprintf(stderr,"Arguments: filename [genotype name or index (1-based) [field name]]\n"
     20             "If a genotype is indicated (by providing the optional genotype identifier), the program will output the raw genotype, suitable for Framsticks Theater's genotype viewer mode. If a genotype and a field name is given, the field value (instead of the raw genotype) is printed. If the second argument is not given, the genotype names from the file will be listed.\n"
    2121             "Example: loader_test walking.gen \"Basic Quadruped\" | theater -g -\n"
    2222                );
     
    2828MiniGenotypeLoader loader(argv[1]);
    2929const char* selected=(argc<3)?NULL:argv[2];
     30const char* field_name=(argc<4)?NULL:argv[3];
    3031int selected_index=(selected&&isdigit(selected[0]))?atol(selected):0;
    3132// using char* constructor (passing the file name to open)
     
    4849                                continue;
    4950                        }
    50                 puts(loaded->genotype.c_str());
     51                if (field_name)
     52                        {
     53                        Param p(minigenotype_paramtab,loaded);
     54                        int field_index=p.findId(field_name);
     55                        if (field_index<0)
     56                                {
     57                                printf("Field '%s' not found\n",field_name);
     58                                return 3;
     59                                }
     60                        else
     61                                puts(p.get(field_index).c_str());
     62                                }
     63                        else
     64                                puts(loaded->genotype.c_str());
    5165                return 0;
    5266                }
Note: See TracChangeset for help on using the changeset viewer.