Welcome, Guest
Username: Password: Remember me
Qui si parla italiano
  • Page:
  • 1

TOPIC:

Contatore alfanumerico 19 Jan 2019 20:13 #7170

  • softdevo@tiscali.it's Avatar
  • Topic Author


  • Posts: 174
  • 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

    Please Log in or Create an account to join the conversation.

    Contatore alfanumerico 19 Jan 2019 20:26 #7171

    • FFF
    • FFF's Avatar


  • Posts: 1392
  • 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
    Regards
    Karl (X# 2.14.0.4; Xide 1.33; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    Last edit: by FFF. Reason: typo

    Contatore alfanumerico 20 Jan 2019 01:11 #7172

    • Chris
    • Chris's Avatar


  • Posts: 3750
  • 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..
    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()
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Contatore alfanumerico 20 Jan 2019 10:09 #7173

    • softdevo@tiscali.it's Avatar
    • Topic Author


  • Posts: 174
  • Grazie a tutti, thank you to all

    Please Log in or Create an account to join the conversation.

    Contatore alfanumerico 20 Jan 2019 10:13 #7174

    • softdevo@tiscali.it's Avatar
    • Topic Author


  • Posts: 174
  • 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

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1
    Moderators: wriedmann