Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alphabetic numbering system
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00174074
Message ID:
00174155
Views:
29
George, John-

Beautiful!!!

I am humbled by both yours and John's intellects. I came up with my own, but it wasn't quite as simple. I approached it completely differently, from a more mathematical side. Here is what I came up with:
?Base10ToBase26(Base26ToBase10("AAAA")+1)

FUNCTION Base10ToBase26
LPARA tnStartNumber
LOCAL lnNumerator, lnMaxDigits, lcResult, lnDigitValue, lnNumerator, 

lnNumerator = tnStartNumber
lnMaxDigits = MAX_DIGITS
lcResult = ""

IF tnStartNumber > (26^lnMaxDigits)
	RETURN REPLICATE("A",lnMaxDigits)
ENDIF

FOR i = (lnMaxDigits - 1) TO 0 STEP -1
	lnDigitValue  = INT(lnNumerator/(26^i))
	lcResult = lcResult + CHR(lnDigitValue + 65)
	lnNumerator = lnNumerator - (lnDigitValue * (26^i))
ENDFOR

RETURN lcResult
ENDFUNC



FUNCTION Base26ToBase10
LPARA tcStartCode
LOCAL lcStartCode, lnComplementi, lcDigit, lnDigitValue, lnCorrectedDigitValue, lnResult


lcStartCode = tcStartCode
lnResult = 0
FOR i = LEN(lcStartCode) TO 1 STEP -1
	lnComplementi = LEN(lcStartCode) - i
	lcDigit = SUBSTR(lcStartCode, i, 1)
	lnDigitValue = ASC(lcDigit) - 65
	lnCorrectedDigitValue = lnDigitValue * 26^lnComplementi	
	lnResult = lnResult + lnCorrectedDigitValue
ENDFOR


RETURN lnResult
Thanks to everybody for your input and ideas.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform