Skip to content

Commit

Permalink
fix: generateNewIds if prefix used without numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
edkerk committed Dec 18, 2024
1 parent 8d1829a commit 8f6e4a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
5 changes: 4 additions & 1 deletion core/generateNewIds.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
fprintf(['No ' type ' ids with prefix "' prefix ...
'" currently exist in the model. The first new id will be "' ...
[prefix,num2str(1,['%0' num2str(numLength) 'd'])] '"\n'],'%s')
lastId=0;
end

if isnan(lastId)
lastId = 0;
end

newIds=cell(quantity,1);
Expand Down
21 changes: 12 additions & 9 deletions doc/core/generateNewIds.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,18 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0047 fprintf([<span class="string">'No '</span> type <span class="string">' ids with prefix &quot;'</span> prefix <span class="keyword">...</span>
0048 <span class="string">'&quot; currently exist in the model. The first new id will be &quot;'</span> <span class="keyword">...</span>
0049 [prefix,num2str(1,[<span class="string">'%0'</span> num2str(numLength) <span class="string">'d'</span>])] <span class="string">'&quot;\n'</span>],<span class="string">'%s'</span>)
0050 lastId=0;
0051 <span class="keyword">end</span>
0052
0053 newIds=cell(quantity,1);
0054
0055 <span class="keyword">for</span> k=1:quantity
0056 newIds{k}=[prefix,num2str(k+lastId,[<span class="string">'%0'</span> num2str(numLength) <span class="string">'d'</span>])];
0057 <span class="keyword">end</span>
0058 <span class="keyword">end</span></pre></div>
0050 <span class="keyword">end</span>
0051
0052 <span class="keyword">if</span> isnan(lastId)
0053 lastId = 0;
0054 <span class="keyword">end</span>
0055
0056 newIds=cell(quantity,1);
0057
0058 <span class="keyword">for</span> k=1:quantity
0059 newIds{k}=[prefix,num2str(k+lastId,[<span class="string">'%0'</span> num2str(numLength) <span class="string">'d'</span>])];
0060 <span class="keyword">end</span>
0061 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>

0 comments on commit 8f6e4a6

Please sign in to comment.