EAGLE Central Forums
Where the EAGLE community meets. Sponsored by Stratford Digital.

Home » CadSoft Support Forums » eagle.suggest.eng » Part number formatting
Part number formatting [message #168035] Mon, 12 December 2016 16:01 Go to next message
Joel Santos Rico
Messages: 5
Registered: October 2016
Junior Member
I would like to know if it's possible to change the part number formatting. In particular, I would like to know if it's possible to pad the numbers so instead of getting R1, R2,... I can get R01, R02,....

I ask this because it's a bit annoying to short my BOMs and get R1, R11, R12, ..., R19 and then R2, R20, R21, ..., R3 and so on.

Thanks!

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/210932
Re: Part number formatting [message #168041 is a reply to message #168035] Mon, 12 December 2016 19:31 Go to previous messageGo to next message
rachaelp
Messages: 596
Registered: March 2015
Location: UK
Senior Member
Hi Joel,

You could use the renumber function found in Tools->Renumber parts....

Set the numerical order at say 100 and then everything on sheet 1 will start from 100, on sheet 2 from 200 and so on. It's not quite what you asked for but it will satisfy your need for correct numerical ordering.

Best Regards,

Rachael

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/210988
Re: Part number formatting [message #168045 is a reply to message #168035] Tue, 13 December 2016 01:49 Go to previous messageGo to next message
warrenbrayshaw
Messages: 1762
Registered: January 2010
Location: New Zealand
Senior Member
Hi

Where are you getting this sorted order from? A ulp perhaps? Please explain.
There are ways in Excel to get it ordered that way if that is where you are doing it, according to Google.

Warren
Re: Part number formatti ng [message #168048 is a reply to message #168041] Tue, 13 December 2016 10:35 Go to previous messageGo to next message
Joel Santos Rico
Messages: 5
Registered: October 2016
Junior Member
Thanks Rachael,

that will do the trick, although as you mention is not exactly what i need, I really don't mind that the numbering is in the hundreds.

--
To view any images and attachments in this post, visit:
https://www.element14.com/community/message/210937
Re: Part number formatting [message #168188 is a reply to message #168035] Sat, 31 December 2016 18:23 Go to previous message
Chuck Huber
Messages: 601
Registered: October 2004
Senior Member
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 12/12/2016 11:01 AM, Joel Santos
Rico wrote:<br>
</div>
<blockquote
cite="mid:457616021.331481558507728.JavaMail.jive@e14-cr-vp-appj8-01.premierfarnell.net"
type="cite">
<pre wrap="">I would like to know if it's possible to change the part number formatting. In particular, I would like to know if it's possible to pad the numbers so instead of getting R1, R2,... I can get R01, R02,....

I ask this because it's a bit annoying to short my BOMs and get R1, R11, R12, ..., R19 and then R2, R20, R21, ..., R3 and so on.

Thanks!

--
To view any images and attachments in this post, visit:
<a class="moz-txt-link-freetext" href="https://www.element14.com/community/message/210932">https://www.element14.com/community/message/210932</a>
</pre>
</blockquote>
<p><br>
</p>
<p>The reason this happens is because the sort order is determined
by what's called an "alpha sort", where each character in a string
is compared to its corresponding character in a second string
based on the ASCII value of each character.  (To be complete,
other character sets may be used based on locale.)  There is no
interpretation of the meaning of each character (digit vs.
letter).  Since the comparison is done on a character by character
basis, all the 1's will sort ahead of all the 2's, for each
character position.  i.e. the comparison does not try to interpret
the value of a string of digits.<br>
</p>
<p>Thus, R1, R10, R123, R19, R1&lt;anything&gt; will sort ahead of
all the R2&lt;anything&gt; names.  This is how you get the order
that you do.<br>
</p>
<p>What you desire is what's called a "version sort".  A version
sort looks for a sequence of digits embedded within a string, and
interprets the sequence as a single value before doing a
comparison.  R2 is less than R10 and thus would sort before the
R10.  In the alpha sort, R10 would sort before the R2.  (Recall
R1&lt;anything&gt; sorts before R2&lt;anything&gt;.)</p>
<p>For the devs:</p>
<blockquote>
<p>Man page:
<a class="moz-txt-link-freetext" href="http://man7.org/linux/man-pages/man3/strverscmp.3.html">http://man7.org/linux/man-pages/man3/strverscmp.3.html</a></p>
<p>strverscmp(3) is available when _GNU_SOURCE is defined.  This
should allow it to be pulled from glibc on demand on linux
platforms.  I'm not sure where this falls on Mac or Windows
machines.  Alternatively, just include the source in the build.<br>
</p>
Source can be found at:
<a class="moz-txt-link-freetext" href="https://opensource.apple.com/source/bison/bison-14/lib/strverscmp.c">https://opensource.apple.com/source/bison/bison-14/lib/strverscmp.c</a>
and many other places.<br>
</blockquote>
<p>As for implementation in the User Language, I would suggest
adding strverscmp() to the list of builtin functions.<br>
</p>
<p>Also, a variant of the builtin ULP sort() function, perhaps
called sortver(), can use the above comparison function to
determine sort order.</p>
<p>The icing on the cake would be to enhance the builtin fileglob()
function to allow a version sort on file names, just as
versionsort(3) does for DIR entries retrieved by scandir(3).<br>
See: <a class="moz-txt-link-freetext" href="http://man7.org/linux/man-pages/man3/versionsort.3.html">http://man7.org/linux/man-pages/man3/versionsort.3.html</a></p>
<blockquote>
<p>Syntax<br>
<tt>    int fileglob(string &amp;array[], string pattern[,
ALPHA_SORT | VERSION_SORT]);</tt><br>
</p>
<p>Builtin constants of appropriate value can be added
accordingly.  The default would be an alpha sort to maintain
backward compatibility of this function.<br>
</p>
</blockquote>
In summary, it would be really nice to have a sortver() function. 
While Joel, the original poster, described a problem, I would like
to ask for the above modifications to the ULP, namely:<br>
<ul>
<li><b>add strverscmp()</b> to the list of builtin string
functions,</li>
<li><b>add sortver()</b> as a function that does the same thing as
sort() except that it would use strverscmp to compare two
elements of an array, and<br>
</li>
<li><b>modify fileglob()</b> to accept an optional third argument
indicating whether the resulting set of file names is sorted
cannonically or by version.<br>
</li>
</ul>
Ideas?<br>
<br>
I wish all a happy and prosperous new year!<br>
<br>
Best regards,<br>
    - Chuck<br>
<br>
</body>
</html>
Previous Topic: Need a comonent for MC33CM0902WEF
Next Topic: Make EAGLE to remember the widht of the left area in the Control Panel
Goto Forum:
  


Current Time: Sun Aug 20 08:04:31 GMT 2017