Page 1 of 1
Contatore alfanumerico
Posted: Sat Jan 19, 2019 7:13 pm
by softdevo@tiscali.it
Salve a tutti. La fatturazione elettronica limita a 5 caratteri il contatore progressivo dei file XML.
99999 è un numero facilmente raggiungibile e superabile.
Mi servirebbe una idea per creare un contatore tipo:
00001
00002
00003
………
99999
A0001
A0002
………
AB001
……...
ZZZZZ
Qualche idea?
Grazie
Danilo
Contatore alfanumerico
Posted: Sat Jan 19, 2019 7:26 pm
by FFF
Class Alfanumerico, using ascii values and overwrite the + operator? You'll have to skip the "unusable" values, so it might not be ultra fast, but usually you won't generate invoices in millisecond steps
Karl
Contatore alfanumerico
Posted: Sun Jan 20, 2019 12:11 am
by Chris
Danilo,
Are you sure you prefer to use letters only after reaching 99999? In my opinion, if you want to eventually start combining numbers and letters, it is better to do that from the start, so 00009->0000A, 0000Z->00010 etc.
This code should do that, but if you want to do it your original way (letters only after "99999"), it can be modified..
Code: Select all
USING System.Text
FUNCTION Start() AS VOID
? NextNumber("00000")
? NextNumber("0000A")
? NextNumber("0000Y")
? NextNumber("0000Z")
? NextNumber("00099")
? NextNumber("000ZZ")
? NextNumber("01ZZZ")
RETURN
FUNCTION NextNumber(cCurrent AS STRING) AS STRING
STATIC LOCAL cNext := StringBuilder{} AS StringBuilder
LOCAL lCarry := TRUE AS LOGIC
cNext:Length := 0
FOR LOCAL n := cCurrent:Length - 1 AS INT DOWNTO 0
LOCAL nAsc AS INT
nAsc := cCurrent[n]
IF lCarry
lCarry := FALSE
nAsc ++
IF nAsc == 58 // '9' + 1
nAsc := 65 // 'A'
ELSEIF nAsc == 91 // 'Z' + 1
nAsc := 48 // '0'
lCarry := TRUE
END IF
END IF
cNext:Insert(0 , (Char)nAsc)
NEXT
RETURN cNext:ToString()
Contatore alfanumerico
Posted: Sun Jan 20, 2019 9:09 am
by softdevo@tiscali.it
Grazie a tutti, thank you to all
Contatore alfanumerico
Posted: Sun Jan 20, 2019 9:13 am
by softdevo@tiscali.it
In some cases I have to maintain compatibility with the past, Cases in which they started to number the invoices from 1 to 99999
Danilo