Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is shorter than Sys(2007) ?
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01319700
Message ID:
01319831
Views:
14
Yes, I see the problem. Try (works even for 0)
	lcLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	lcCharList = lcLetters 
	lnBase = LEN(lcCharList)
	lcVal = ""
	FOR i=1 TO 4
		lnRest = (lnVal % lnBase) 
		lnVal = INT( lnVal / lnBase)
		lcVal =  SUBSTR( lcCharList, lnRest + 1 , 1 ) + lcVal
	ENDFOR
>Nice shot. However, exactly your case ("whatever") showed a problem. It could be repaired by decreasing lnBase with 1 and increasing lnRest with 1. Here's the testcode:
>
>
create cursor c_sys2007 ( theNumber i, theString c(10) )
>for n = 1 to 99999
>	lnval = n
>	lcLetters = "ABCDEFGHIJKLMNOPQRSTUVWXY"
>	lcCharList = lcLetters + LOWER(lcLetters)
>	lnBase = LEN(lcCharList) - 1
>	lcVal = ""
>	DO WHILE lnVal > 0
>		lnRest = lnVal % lnBase
>		lnVal = INT( lnVal / lnBase)
>		lcVal =  SUBSTR( lcCharList, lnRest + 1, 1 ) + lcVal
>	ENDDO
>	insert into c_sys2007 values ( n, lcVal )
>next
>
>browse title "Raw result"
>
>select cnt(*) as _cnt, theString from c_sys2007 order by 2 group by 2 into cursor c_sys2007a
>browse title "Occurence of each string - Desc - Column 1 should have no other value than 1"
>
>select len(alltrim(thestring)) as theLen from c_sys2007a order by 1 desc into cursor c_sys2007b
>select dist theLen from c_sys2007b order by 1 desc into cursor c_sys2007c
>browse title "Distinct of lengths"
>
>I think I'll gonna use a variation. lcCharlist will be lcLetters only, in order to have only upper case in the outcome. And I want the string to be four positions always. That can be accomplished by reserving the Z, so by decreasing lcLetters with 1 and doing padr() with the Z.
>
>Problem solved. Thanks Sergey. Did you write this today?
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform