IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39953 for trunk/Ohana


Ignore:
Timestamp:
Jan 21, 2017, 4:26:10 PM (9 years ago)
Author:
eugene
Message:

was not re-setting the list length

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.basic/list.c

    r39403 r39953  
    207207    char line2[MAX_LINE_LENGTH];
    208208
    209     snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
     209    snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]); // line = LIST:n
    210210    N = get_int_variable (line, &found);
     211
     212    // loop over all list elements:
    211213    for (i = 0; i < N; i++) {
    212214      // snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[1], i);
    213       set_list_varname (line, argv[1], i, EXCEL_STYLE);
     215      set_list_varname (line, argv[1], i, EXCEL_STYLE); // line = LIST:i
    214216      value = get_variable (line);
    215217      if (value == NULL) continue;
     218
     219      // if this is the entry we want, delete and shift the rest down
    216220      if (!strcmp (value, argv[3])) {
    217221        free (value);
    218222        for (j = i + 1; j < N; j++) {
    219223          // snprintf (line, MAX_LINE_LENGTH, "%s:%d", argv[1], j);
    220           set_list_varname (line2, argv[1], j, EXCEL_STYLE);
     224          set_list_varname (line2, argv[1], j, EXCEL_STYLE); // line2 = LIST:j
    221225          next_value = get_variable (line2);
    222226          set_str_variable (line, next_value);
    223           strcpy (line, line2);
     227          strcpy (line, line2); // line = LIST:j (will be j-1 next loop)
    224228        }
    225         DeleteNamedScalar (line);
    226         snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]);
    227         set_int_variable (line2, N - 1);
     229        DeleteNamedScalar (line); // line = LIST:(N-1)
     230        snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]); // line = LIST:n (new value of n)
     231        set_int_variable (line, N - 1);
    228232        return (TRUE);
    229233      }
Note: See TracChangeset for help on using the changeset viewer.