Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Number at mytext
Message
De
05/12/2004 10:25:39
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
05/12/2004 00:40:14
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00966918
Message ID:
00966972
Vues:
18
Ah, well, that might be something like:
replace DocNumber with str(year(date()),4) + "-";
  + padl(SerialNumber("Sequence_1"), 6, "0")
Where SerialNumber() is the function that looks in your sequence tables. This function might look like this:
**********************************************************************
FUNCTION SERIALNUMBER(tnSequence)
* Conseguir número secuencial. Usado para generar claves primarias.
local lnSelect
lnSelect = select()
if used("serialnumber")
	select serialnumber
else
	select 0
	use serialnumber
endif
set order to "sequence"
seek padr(tnSequence, len(sequence))
if not found()
	append blank
	replace sequence with tnSequence, nextnum with 1
endif
local lnReturnValue
if lock()
	lnReturnValue = nextnum
	replace nextnum with nextnum + 1
else
	lnReturnValue = -1
endif
select (lnSelect)
unlock
return lnReturnValue
>hi,
>thank you for reply,
>
>that is mean myfield must be character,
>
>i need small code sample about mytext(mean the serial how i can do that),if you can,
>
>and how i can make myresearch when i have 04-0025.

Let's say that you save the year in 4 digits, and the sequence number in 6, with a hyphen (-) in between (but see also Tore's suggestion, to eliminate the hyphen).
local lnYear, lnDocNumber
lnYear = 2004
lnDocNumber = 73 && might be the result of some user input

set order to DocNumber
if not seek(str(lnYear, 4) + "-" + padl(lnDocNumber, 6, "0")
  MessageBox("This document doesn't exist.")
endif
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform