Code : Tout sélectionner
Enumeration
#Fenetre_principale
EndEnumeration
Enumeration
#Text_0
#Text_1
#Text_2
#Text_3
#Text_4
#Text_5
#Text_6
#Text_7
#Text_8
#Text_9
#Text_10
#Text_11
#Text_12
#Text_13
#Text_14
#Text_15
#Text_16
#Text_17
#Text_18
#Text_19
#Text_20
#Texte_21
#Texte_22
#String_Sexe
#String_Annee
#String_Mois
#String_Departement
#String_Commune
#String_Numero
#String_Cle
#String_Numero_complet
#Bouton_Sexe
#Bouton_Annee
#Bouton_Mois
#Bouton_Departement
#Bouton_Commune
#Bouton_Numero
#Bouton_Decoder
#Texte_Trait
#Texte_Trait2
#Texte_Trait3
#Texte_Trait4
#Texte_Trait5
#Texte_Trait6
#Texte_Trait7
EndEnumeration
Global.s Trait = "——————————————————————————————————————————————————————————————————————"
Procedure OpenWindow_Fenetre_principale()
If OpenWindow(#Fenetre_principale, 0, 0, 420, 385, "Calcul de la clé du code Insee", #PB_Window_SystemMenu|#PB_Window_SizeGadget|
#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
TextGadget(#Text_0, 5, 5, 285, 15, "Code sexe")
TextGadget(#Text_1, 5, 20, 285, 15, "[1 = homme, 2 = femme, 3 = numéro temporaire")
TextGadget(#Texte_Trait, 0, 30, 420, 10, Trait)
TextGadget(#Text_2, 5, 40, 285, 15, "Année de naissance")
TextGadget(#Text_3, 5, 55, 285, 15, "[2 derniers chiffres du millésime : 2013 : 13")
TextGadget(#Texte_Trait2,0,65, 420, 10, Trait)
TextGadget(#Text_4, 5, 75, 285, 15, "Mois naissance")
TextGadget(#Text_5, 5, 90, 285, 15, "[sur 2 chiffres : janvier = 01, décembre = 12]")
TextGadget(#Text_6, 5, 105, 285, 15, "20 et au delà : pièce d'état civil incomplète")
TextGadget(#Texte_Trait3, 0, 115, 420, 10, Trait)
TextGadget(#Text_7, 5, 125, 285, 15, "Code département de naissance")
TextGadget(#Text_8, 5, 140, 285, 15, "[sur 2 chiffres ou lettres, exemples:")
TextGadget(#Text_9, 5, 155, 285, 15, "75 pour Paris")
TextGadget(#Text_10, 5, 170, 285, 15, "99 pour l'étranger")
TextGadget(#Text_11, 5, 185, 285, 15, "2A pour la Corse du Sud")
TextGadget(#Text_12, 5, 200, 285, 15, "2B pour la Haute Corse")
TextGadget(#Text_13, 5, 215, 285, 15, "outre mer : département sur 3 chiffres (1 sur champ suivant)]")
TextGadget(#Texte_Trait4, 0, 225, 420, 10, Trait)
TextGadget(#Text_20, 5, 235, 285, 15, "Code Insee commune de naissance")
TextGadget(#Texte_21, 5, 250, 285, 15, "[sur 3 chiffres (2 pour l'outre mer)]")
TextGadget(#Texte_22, 5, 265, 285, 15, "990 à 999 : pupille de l'Etat ou lieu de naissance inconnu")
TextGadget(#Texte_Trait5, 0, 275, 420, 10, Trait)
TextGadget(#Text_14, 5, 285, 285, 15, "Numéro d'ordre")
TextGadget(#Text_15, 5, 300, 285, 15, "[sur 3 chiffres]")
TextGadget(#Texte_Trait6, 0, 310, 420, 10, Trait)
TextGadget(#Text_16, 5, 320, 285, 15, "Clé de contrôle")
TextGadget(#Text_17, 5, 335, 285, 15, "[2 chiffres]")
TextGadget(#Texte_Trait7, 0, 345, 420, 10, Trait)
TextGadget(#Text_18, 5, 355, 285, 15, "Numéro de sécurité sociale complet")
TextGadget(#Text_19, 5, 370, 285, 15, "[15 chiffres]")
StringGadget(#String_Sexe, 290, 5, 14, 20, "", #PB_String_Numeric)
StringGadget(#String_Annee, 290, 40, 18, 20, "", #PB_String_Numeric)
StringGadget(#String_Mois, 290, 75, 18, 20, "")
StringGadget(#String_Departement, 290, 125, 18, 20, "", #PB_String_UpperCase)
StringGadget(#String_Commune, 290, 235, 25, 20, "", #PB_String_Numeric)
StringGadget(#String_Numero, 290, 285, 25, 20, "", #PB_String_Numeric)
TextGadget(#String_Cle, 290, 320, 20, 20, "", #PB_String_ReadOnly)
StringGadget(#String_Numero_complet, 290, 355, 120, 20, "")
ButtonGadget(#Bouton_Sexe, 325, 5, 80, 20, "Changer")
ButtonGadget(#Bouton_Annee, 325, 40, 80, 20, "Changer")
ButtonGadget(#Bouton_Mois, 325, 75, 80, 20, "Changer")
ButtonGadget(#Bouton_Departement, 325, 125, 80, 20, "Changer")
ButtonGadget(#Bouton_Commune, 325, 235, 80, 20, "Changer")
ButtonGadget(#Bouton_Numero, 325, 285, 80, 20, "Changer")
ButtonGadget(#Bouton_Decoder, 325, 320, 80, 20, "Décoder la clé")
SetActiveGadget(#String_Sexe)
SetGadgetAttribute(#String_Sexe, #PB_String_MaximumLength, 1)
SetGadgetAttribute(#String_Annee, #PB_String_MaximumLength, 2)
SetGadgetAttribute(#String_Mois, #PB_String_MaximumLength, 2)
SetGadgetAttribute(#String_Departement, #PB_String_MaximumLength, 2)
SetGadgetAttribute(#String_Commune, #PB_String_MaximumLength, 3)
SetGadgetAttribute(#String_Numero, #PB_String_MaximumLength, 3)
EndIf
EndProcedure
OpenWindow_Fenetre_principale()
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case #String_Sexe
text.s = GetGadgetText(#String_Sexe)
If text.s < "1" Or text.s > "3"
Beep_(880,100)
text2.s = Left(text.s,Len(text.s)-1)
SetGadgetText(#String_Sexe, text2.s)
EndIf
Case #String_Mois
text.s = GetGadgetText(#String_Mois)
If text.s > "12"
Beep_(880,100)
text2.s = Left(text.s,Len(text.s)-2)
SetGadgetText(#String_Mois, text2.s)
EndIf
Case #String_Departement
text.s= GetGadgetText(#String_Departement)
If Len(text.s) < 3
Select Left(text.s, 1)
Case "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f",
"g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"
Beep_(880,100)
text.s= GetGadgetText(#String_Departement)
text2.s= Left(text.s,Len(text.s)-1)
SetGadgetText(#String_Departement, text2.s)
Case "2"
If (Asc(Right(text.s,1))>47 And Asc(Right(text.s,1))<58 ) Or (Asc(Right(text.s,1))=65 Or Asc(Right(text.s,1))=66)
text.s= GetGadgetText(#String_Departement)
Else
Beep_(880,100)
text.s= GetGadgetText(#String_Departement)
text2.s= Left(text.s,Len(text.s)-1)
SetGadgetText(#String_Departement, text2.s)
EndIf
Case "1" , "3" , "4", "5", "6", "7", "8", "9"
If (Asc(Right(text.s,1))>47 And Asc(Right(text.s,1))<58 )
text.s= GetGadgetText(#String_Departement)
Else
Beep_(880,100)
text.s= GetGadgetText(#String_Departement)
text2.s= Left(text.s,Len(text.s)-1)
SetGadgetText(#String_Departement, text2.s)
EndIf
EndSelect
EndIf
Case #Bouton_Decoder
If UCase(Right(GetGadgetText(#String_Departement),1))= "A"
Departement$ = "20"
Resultat = Val(GetGadgetText(#String_Sexe) + GetGadgetText(#String_Annee) + GetGadgetText(#String_Mois) +
Departement$ + GetGadgetText(#String_Commune) + GetGadgetText(#String_Numero))
Resultat - 1000000
ElseIf UCase(Right(GetGadgetText(#String_Departement),1))= "B"
Departement$ = "20"
Resultat = Val(GetGadgetText(#String_Sexe) + GetGadgetText(#String_Annee) + GetGadgetText(#String_Mois) +
Departement$+GetGadgetText(#String_Commune)+GetGadgetText(#String_Numero))
Resultat - 2000000
Else
Resultat = Val(GetGadgetText(#String_Sexe)+GetGadgetText(#String_Annee)+GetGadgetText(#String_Mois) +
GetGadgetText(#String_Departement)+GetGadgetText(#String_Commune)+GetGadgetText(#String_Numero))
EndIf
SetGadgetText(#String_Cle, Str(97 - Mod(Resultat, 97)))
SetGadgetText(#String_Numero_complet, GetGadgetText(#String_Sexe) + " " + GetGadgetText(#String_Annee) + " " +
GetGadgetText(#String_Mois) + " " + GetGadgetText(#String_Departement) + " " +
GetGadgetText(#String_Commune) + " "+GetGadgetText(#String_Numero) + " [" + GetGadgetText(#String_Cle) + "]")
Case #Bouton_Sexe
SetGadgetText(#String_Sexe, "")
SetActiveGadget(#String_Sexe)
Case #Bouton_Annee
SetGadgetText(#String_Annee, "")
SetActiveGadget(#String_Annee)
Case #Bouton_Mois
SetGadgetText(#String_Mois, "")
SetActiveGadget(#String_Mois)
Case #Bouton_Departement
SetGadgetText(#String_Departement, "")
SetActiveGadget(#String_Departement)
Case #Bouton_Commune
SetGadgetText(#String_Commune, "")
SetActiveGadget(#String_Departement)
Case #Bouton_Numero
SetGadgetText(#String_Numero, "")
SetActiveGadget(#String_Numero)
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Fenetre_principale
CloseWindow(#Fenetre_principale)
Break
EndSelect
EndSelect
ForEver
J'en profite pour remercie spécialement Dobro, Falsam et MLD pour leur aide active et efficace.