IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 16, 2020, 2:04:27 PM (6 years ago)
Author:
tdeboer
Message:

quick undo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/create.c

    r41340 r41341  
    77  Vector *vec;
    88 
     9  // create a vector of empty strings
     10  if ((N = get_argument (argc, argv, "-str"))) {
     11    remove_argument (N, &argc, argv);
     12
     13    char *stringValue = NULL;
     14    if ((N = get_argument (argc, argv, "-value"))) {
     15      remove_argument (N, &argc, argv);
     16      stringValue = strcreate (argv[N]);
     17      remove_argument (N, &argc, argv);
     18    }
     19
     20    if (argc != 3) {
     21      gprint (GP_ERR, "USAGE: create vector Nelements -value word\n");
     22      return (FALSE);
     23    }
     24
     25    if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) return (FALSE);
     26    int Nelements = atoi (argv[2]);
     27
     28    // a newly reset vector has NULL-valued pointers
     29    ResetVector (vec, OPIHI_STR, Nelements);
     30    for (int i = 0; i < Nelements; i++) {
     31      vec[0].elements.Str[i] = stringValue ? strcreate (stringValue) : strcreate ("");
     32    }
     33    return TRUE;
     34  }
     35
    936  INT = FALSE;
    1037  if ((N = get_argument (argc, argv, "-int"))) {
     
    1643    gprint (GP_ERR, "USAGE: create vector start end [delta] [-int]\n");
    1744    gprint (GP_ERR, " -int : resulting vector is integer type (delta must be integer)\n");
     45    gprint (GP_ERR, " -str : resulting vector is string type (only give number of elements)\n");
    1846    return (FALSE);
    1947  }
Note: See TracChangeset for help on using the changeset viewer.