Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incrementing Alphabet
Message
From
26/04/1998 00:13:42
Bob Thickens
Empire Medical Review Services, Inc
Mequon, Wisconsin, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00094857
Message ID:
00094944
Views:
18
>Today's Quiz. I want to maximize the number of choices I can assign to a group of records so I choose to use the alphabet through a three character field. How do I programatically increment the next assigned alphabetic character (i.e. AAA, AAB, AAC. .. AAZ then ABA, ABB, etc.)
>
>do I do this with ascii character (chr()) assignments or is there an easier way?
>
>Thanks in advance,
>
>Bill

Here is an old fox 2.6 function which uses a value in a single record file called control.dbf to create an 8 character long string used as a filename. It uses a thru z and o thru 9. I know that one may use a sys() function for a unique filename but this gives a filename which is easily identified as sequential:


FUNCTION OnePlus
PRIVATE vreturn, valreturn, vloop, vdigit, vnewfile, valias
USE Control IN SELECT(1)
IF FLOCK("Control")
vreturn = UPPER(Control->New_File)
valreturn = 0
vloop = 7
vdigit = 0
DO WHILE vloop >= 0
vdigit = ASC(SUBSTR(vreturn, 8 - vloop, 1))
valreturn = valreturn + ;
(36**vloop * IIF(vdigit > 57, vdigit - 55, vdigit - 48))
vloop = vloop - 1
ENDDO
valreturn = valreturn + 1
vloop = 7
vdigit = 0
vnewfile = ""
DO WHILE vloop >= 0
vdigit = INT(valreturn / (36**vloop))
vnewfile = vnewfile + IIF(vdigit < 10, CHR(48+vdigit), ;
CHR(55+vdigit))
valreturn = valreturn - (vdigit * 36**vloop)
vloop = vloop - 1
ENDDO
m.valias = ALIAS()

SELECT CONTROL
REPLACE Control->New_File WITH m->vnewfile
IF LEN(TRIM(valias)) <> 0
SELECT &valias
ENDIF

ELSE
vreturn = "ABORT"
ENDIF
USE IN SELECT("CONTROL")
RETURN(vreturn)
*-- EOF -- FUNCTION OnePlus
Previous
Reply
Map
View

Click here to load this message in the networking platform