Programma di esempio CODICE32.PRT
; CODICE32
;
; Programma per Proteus
;
; (C) 2003 Simone Zanella Productions
;
; Funzioni per la codifica e la decodifica del Codice 32 (Farmaceutico italiano).

FUNCTION Conv32(cod)

; Alfabeto per il calcolo del codice 32
base32 = "0123456789BCDFGHJKLMNPQRSTUVWXYZ"

; Calcola il check digit
c = C32CheckDigit(cod)
d = ""
; Trasforma il numero nella codifica alfanumerica Codice 32
FOR x = 1 TO 6
  d = SUBSTR(base32, INC(MOD(c, 32)), 1) d
  DIV(@c, 32)
NEXT
; Ritorna il codice calcolato
RETURN d


FUNCTION C32CheckDigit(cod)

; Calcola il check digit su cod, ritorna la stringa con il check digit

p = 0
FOR x = 2 TO 8 STEP 2
  c = MUL(SUBSTR(cod, x, 1), 2)
  ADD(@p, DIV(c, 10), MOD(c, 10))
NEXT
FOR x = 1 TO 7 STEP 2
  ADD(@p, SUBSTR(cod, x, 1))
NEXT
RETURN cod MOD(p, 10)


FUNCTION ReConv32(cod)

; Ritorna il codice numerico corrispondente al codice cod (farmaceutico)

; Alfabeto per il calcolo del codice 32
base32 = "0123456789BCDFGHJKLMNPQRSTUVWXYZ"

c = 0
FOR x = 1 TO 6
  d = SUBSTR(cod, x, 1)
  p = STRSTR(base32, d)
  c = ADD(MUL(c, 32), DEC(p))
NEXT
RETURN PADL(c, 9, "0")


CONSOLELN "02608901" ", " Conv32("02608901") ", " ReConv32(Conv32("02608901"))
CONSOLELN "12358231" ", " Conv32("12358231") ", " ReConv32(Conv32("12358231"))
CONSOLELN "44812722" ", " Conv32("44812722") ", " ReConv32(Conv32("44812722"))
CONSOLELN "12456762" ", " Conv32("12456762") ", " ReConv32(Conv32("12456762"))
CONSOLELN "12345678" ", " Conv32("12345678") ", " ReConv32(Conv32("12345678"))
CONSOLELN "90206826" ", " Conv32("90206826") ", " ReConv32(Conv32("90206826"))

ABORT 0

Indice esempi Prossimo esempio Esempio precedente Indice per argomenti Indice analitico
Midnight Lake iPhone Case Black Women Shoes Black Flat Shoes Leather Flats Black Patent Ballerinas Black Ballet Shoes Casual Shoes Black Shoes Women Balle Record Player Cufflinks Best iPhone XR Clear Cases iPhone XS/XS Max Leather Cases Sale Best iPhone 8/8 Plus Silicone Cases iPhone 7/7 Plus Cases & Screen Protector New Cases For iPhone 6/6 Plus iPhone 8 Case Sale iPhone Xr Case Online iPhone 7 Case UK Online iPhone X Case UK Sale iPhone X Case Deals iPhone Xs Case New Case For iPhone Xr UK Online Case For iPhone 8 UK Outlet Fashion Silver Cufflinks For Men Best Mens Cufflinks Outlet Online The Gold Cufflinks Shop Online Cheap Shirt Cufflinks On Sale Nice Wedding Cufflinks UK Online Top Black Cufflinks UK Online Mens Cufflinks Online Silver Cufflinks For Men Men Cufflinks UK Sale Gold Cufflinks UK Online Gold Cufflinks UK Silver Cufflinks UK Shirt Cufflinks Discount Online Mens Cufflinks Deals & Sales Girls Shoes For Dance Fashion Ballet Dance Shoes Best Ballet Flats Shoes UK Online Cheap Ballet Pointe Shoes UK Online Best Ballet Shoes Outlet Best Dance Shoes Sale Cheap Ballet Flats Sale UK Best Pointe Shoes Online UK Ballet Dance Shoes UK Shoes For Dance UK Best Ballet Slippers Shop Best Yoga Shoes Hotsell