Changeset 39953 for trunk/Ohana
- Timestamp:
- Jan 21, 2017, 4:26:10 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.basic/list.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.basic/list.c
r39403 r39953 207 207 char line2[MAX_LINE_LENGTH]; 208 208 209 snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]); 209 snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]); // line = LIST:n 210 210 N = get_int_variable (line, &found); 211 212 // loop over all list elements: 211 213 for (i = 0; i < N; i++) { 212 214 // 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 214 216 value = get_variable (line); 215 217 if (value == NULL) continue; 218 219 // if this is the entry we want, delete and shift the rest down 216 220 if (!strcmp (value, argv[3])) { 217 221 free (value); 218 222 for (j = i + 1; j < N; j++) { 219 223 // 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 221 225 next_value = get_variable (line2); 222 226 set_str_variable (line, next_value); 223 strcpy (line, line2); 227 strcpy (line, line2); // line = LIST:j (will be j-1 next loop) 224 228 } 225 DeleteNamedScalar (line); 226 snprintf (line, MAX_LINE_LENGTH, "%s:n", argv[1]); 227 set_int_variable (line 2, 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); 228 232 return (TRUE); 229 233 }
Note:
See TracChangeset
for help on using the changeset viewer.
