Asked • 04/28/19

How do I create and increment a 2 or 3 digit hexadecimal number?

How do I increment the highest hexidecimal number from an array of hexidecimal numbers? My knowledge of hexidecimal is somewhat spotty so any help would be appreciated. And to be perfectly honest I don't know if the numbers are hexadecimal or not because there is a "u" in front of them but they look that way if you remove the "u". The values are from an InDesign snippet document. Example: var anArray = ["uf9","ufc","u111","u112","u136","u137"]; // actual values var getUniqueID = getNextHigherNumber(anArray); function getNextHigherNumber(anArray) { // sort array // create variable and add one // return variable return variable; } XML from the server (look at Self and Source): <Hyperlink Self="ufc" Name="is a multiline hyperlink that terminates here" Source="uf9" Visible="false" Highlight="None" Width="Thin" BorderStyle="Solid" Hidden="false" DestinationUniqueKey="1"> <Properties> <BorderColor type="enumeration">Black</BorderColor> <Destination type="object">HyperlinkURLDestination/http%3a//test.com#1stMultilineLink/</Destination> </Properties> </Hyperlink> <Hyperlink Self="u112" Name="hyperlink inline" Source="u111" Visible="false" Highlight="None" Width="Thin" BorderStyle="Solid" Hidden="false" DestinationUniqueKey="2"> <Properties> <BorderColor type="enumeration">Black</BorderColor> <Destination type="object">HyperlinkURLDestination/http%3a//test.com</Destination> </Properties> </Hyperlink> <Hyperlink Self="u137" Name="another multline hyperlink" Source="u136" Visible="false" Highlight="Outline" Width="Thick" BorderStyle="Solid" Hidden="false" DestinationUniqueKey="3"> <Properties> <BorderColor type="enumeration">Purple</BorderColor> <Destination type="object">HyperlinkURLDestination/http%3a//google.com#multilinehyperlink</Destination> </Properties> </Hyperlink> More background: I have an existing XML document that looks like it's using hexidecimal number system for it's IDs and I need to be able to create a unique ID for new nodes. The ID values look similar to HTML web colors like, "0xFF0000" (which is red) but the difference is that it is using 2 or 3 characters instead of 6, for example, "ufc" or "u112". I receive an XML file from the server and it has nodes and each node has an ID with a unique value (see XML example above). If I have to create a new "item" I need to create a unique ID for it that isn't already used.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.