Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is shorter than Sys(2007) ?
Message
De
27/05/2008 15:57:40
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01319700
Message ID:
01319787
Vues:
16
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?

>
>CLEAR
>lnVal = INT(VAL(SYS(2007, "whatever")))
>
>lcLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>lcCharList = lcLetters + LOWER(lcLetters)
>lnBase = LEN(lcCharList)
>lcVal = ""
>DO WHILE lnVal > 0
>	lnRest = lnVal % lnBase
>	lnVal = INT( lnVal / lnBase)
>	lcVal =  SUBSTR(lcCharList, lnRest,1) + lcVal
>ENDDO
>? lcVal
>
>>
>>The length of sys(2007) is 5 numbers. I'd like to convert this into a character string of alphabetic letters (A-Z), in order to get rid of some positions. I can write the algorithm, but perhaps someone else already wrote one?!
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform