Forum > General
is there a Base 26 / Radix 26 A..Z functions in the libs?
jamie:
I am an advocate of using what is already in the libs instead of re-inventing the wheel and adding bloat to the code.
I need to Decode a string input like this.
'A..Z' or any combination like 'AA', 'BB' etc.
works like HEX digits only each digit is worth 26.
I am using this for the RULERS on the side of a Document sheet, and I know there is some spread sheet code hanging around here that does encode and decode these columns.
For now I am just looking to convert to an integer;
No need for anyone to write one for me, I can do that myself but would love to reuse code.
Jamie
dsiders:
--- Quote from: jamie on May 31, 2026, 07:18:44 pm ---I am an advocate of using what is already in the libs instead of re-inventing the wheel and adding bloat to the code.
I need to Decode a string input like this.
'A..Z' or any combination like 'AA', 'BB' etc.
works like HEX digits only each digit is worth 26.
I am using this for the RULERS on the side of a Document sheet, and I know there is some spread sheet code hanging around here that does encode and decode these columns.
For now I am just looking to convert to an integer;
No need for anyone to write one for me, I can do that myself but would love to reuse code.
Jamie
--- End quote ---
Haven't used this myself, but...
https://wiki.freepascal.org/Base_converting
jamie:
Nice looking code there, but it looks like not exactly what I was looking for.
Example:
"A" = 0; "AA" = 26
So:
"B" = 1 and "BA" = 27
I can't believe someone hasn't come up with this yet for a common base function.
Jamie
Thausand:
--- Quote from: jamie on May 31, 2026, 08:19:10 pm ---I can't believe someone hasn't come up with this yet for a common base function.
--- End quote ---
I have think this not present because is use case special.
When column indicate can make 1:1 map-look-table. When want practice use then why is limit 26 ? there is also exist lowcase and upcase character and number and more other character then can have example base 36 when have include number.
jamie:
I had to settle for this.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function DecodeGridLetterValue(aValue: ansistring): int64;var I: integer;begin aValue := UpperCase(aValue); Result := 0; for I := 1 to Length(AValue) do begin Result := Result * 26 + (Ord(AValue[I]) - Ord('A')); end;end; function EncodeGridLetterValue(aValue: int64): ansistring;var Balance: integer;begin repeat Balance := Avalue mod 26; Result := Result.InSert(0, char(Ord('A') + Balance)); AValue := AValue div 26; until AValue = 0;end;
So I can get A..Z, but for multiples I had to make sure I didn't have a 0 (A) value at the start.
"A" = 0
"Z" = 25
"BA" = 26
And so on. With this I can Encode and decode the RULER marks and make an indexable lookup Ruler.
Navigation
[0] Message Index
[#] Next page