Skip to content
Snippets Groups Projects
Commit ad44221e authored by leprob001's avatar leprob001
Browse files

Updated tomlini.m.

  / parseAsStruct: If a key already exists, the new value will be appended
    to the value that is already stored in the existing key.
parent 3b534a5c
No related branches found
No related tags found
No related merge requests found
......@@ -157,22 +157,19 @@ end
[line, comment] = extractValueAndComment(lines{i});
[key, value] = strtok(line(2:end));
% check if key already exists
if (isfield(returnContent, key))
% find key that is available
i = 1;
while (isfield(returnContent, [key num2str(i)]))
i = i + 1;
end
key = [key num2str(i)];
clear i;
end
valueAsNumber = str2num(value);
if isempty(valueAsNumber)
returnContent.(key) = strtrim(value);
parsedValue = strtrim(value);
else
returnContent.(key) = valueAsNumber;
parsedValue = valueAsNumber;
end
% check if key already exists
if (isfield(returnContent, key)) % add it to the existing key as new line
parsedValue = [ returnContent.(key); parsedValue];
end
returnContent.(key) = parsedValue;
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment