Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alphabetic numbering system
Message
From
09/01/1999 17:00:14
 
 
To
09/01/1999 15:24:38
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00174074
Message ID:
00174389
Views:
23
>>I am faced with the need to create (actually participate with) an alphabetic numbering system. The sequence is straight forward, and looks like this:
>>
>>AAAA
>>AAAB
>>.
>>.
>>AAAZ
>>AABA
>>
>>etc.
>>
>>Really my only need is to be able to increment these codes by one, so I need a function that receives "DPRZ" and returns "DPSA". Get it?
>>
>>I am fairly confident that I can pound out the code to do this, but all of my ideas so far would take an enormous amount of code- can anybody think of a practical solution?
>
function my2Alpha
>lparameters tcValue, tnAdd
>lnValue = 0
>for ix=len(tcValue) to 1 step -1
>	lnValue = lnValue + ;
>	(asc(substr(tcValue,ix,1))-asc("A"))*26^(len(tcValue)-ix)
>endfor
>lnValue = lnValue + tnAdd
>lcNewValue = ""
>do while lnValue > 0
>	lcNewValue = chr(asc("A")+lnValue%26) + lcNewValue
>	lnValue = int(lnValue / 26)
>enddo
>return lcNewValue
Cetin

Another graceful solution. Cetin, check out the rest of the messages in the thread to see what we all came up with.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform