Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Aphanumeric sorts VFP XP?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00692368
Message ID:
00692387
Vues:
19
You can do that by "normalizing" key expression.
* Function NormalizeKey
LPARAMETERS tcKey
lcKey = ALLTRIM(tcKey)
llAlpha = .T.
lcNewKey = ""
lcNumber = ""
FOR i=1 TO LEN(lcKey)
	lcSym = SUBSTR(lcKey,i,1)
	IF ISDIGIT(lcSym)
		lcNumber = lcNumber + lcSym
		llAlpha = .F.
		IF i= LEN(lcKey)
			lcNewKey = lcNewKey + STR(VAL(lcNumber))
		ENDIF
	ELSE
		llAlpha = .T.
		IF  NOT EMPTY(lcNumber)	
			lcNewKey = lcNewKey + STR(VAL(lcNumber))
			lcNumber = ""
		ENDIF	
		lcNewKey = lcNewKey + lcSym
	ENDIF
ENDFOR
RETURN lcNewKey
You can replace STR(VAL(lcNumber)) with BINTOC(VAL(lcNumber)) to make key expression shorter.


>This all began when a customer wanted our software to retrieve information between bins like they do on the mainframe.
>
>Standard VFP sort/between:
>a1
>a100
>a1000
>a10a
>a1a
>a2
>a20
>
>This is the how it works in VFP currently. Although the customer wants to be able to select data from a1 through a20 and just get a1,a1a,a2,a20. Which I told him it was impossible. He pointed out that in WinXP can do it with files. So I started looking into it and WinXP does not sort files in same way character based sorts work. You can create a folder on disk in the folder put some files without extensions. Name them a1,a100,a1000,a10a,a1a,a2,a20. Click views details sort by name and it puts them in the "logical" order.
>
>a1
>a1a
>a2
>a10a
>a20
>a100
>a1000
>
>Does anyone know how they are doing this? I have tried padding, alltriming right and left. I think the only way to do this is break each character out and store them padded to a fixed length. Then use a standard sort. I have looked for it on the Microsoft site, but can not find anyplace they describe this. It really starts getting weird when you throw special characters in like {,[,# into the names.
>
>Any ideas?
>
>Dale
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform