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
Moderator: wriedmann
Contatore alfanumerico
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
Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Contatore alfanumerico
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..
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()
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
- softdevo@tiscali.it
- Posts: 191
- Joined: Wed Sep 30, 2015 1:30 pm
Contatore alfanumerico
Grazie a tutti, thank you to all
- softdevo@tiscali.it
- Posts: 191
- Joined: Wed Sep 30, 2015 1:30 pm
Contatore alfanumerico
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
Danilo