voici une solution ..
Stringfields() , qui est une fonction Purebasic , qui remplace avantageusement les tableaux surtout pour ce qui concerne les strings
je déplore l'utilisation de if elsif.......
grace au Declare du debut de listing ....
Code : Tout sélectionner
; Code By Dobro
Declare Open_Window_0()
Declare Prof(verbe$,pronom_num)
Declare on_off(etat)
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Titre
#Button_etre
#Button_aller
#je
#Tu
#il
#Nous
#Vous
#Ils
#String_je
#String_Tu
#String_il
#String_nous
#String_Vous
#String_ils
#String_res_je
#String_res_tu
#String_res_il
#String_res_nous
#String_res_vous
#String_res_ils
#Text_sign
EndEnumeration
;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Arial", 48)
Global FontID2
FontID2 = LoadFont(2, "Arial", 28)
Global FontID3
FontID3 = LoadFont(3, "Arial", 12, #PB_Font_Bold)
Global verbe
Global aller$= "vais,vas,va,allons,allez,vont,allais,allais,allait,allions,alliez,allaient,allai,allas,alla,allâmes,allâtes,allèrent,irai,iras,ira,irons,irez,iront"
Global etre$="suis,es,est,sommes,êtes,sont,étais,étais,était,étions,étiez,étaient,fus,fus,fut,fûmes,fûtes,furent,serai,seras,sera,serons,serez,seront"
Open_Window_0()
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_Event_Gadget
If GadgetID = #Button_etre
on_off(0)
verbe$="etre"
ElseIf GadgetID = #Button_aller
on_off(0)
verbe$="aller"
ElseIf GadgetID = #String_je
pronom_num=0
Prof(verbe$,pronom_num)
ElseIf GadgetID = #String_Tu
pronom_num=1
Prof(verbe$,pronom_num)
ElseIf GadgetID = #String_il
pronom_num=2
Prof(verbe$,pronom_num)
ElseIf GadgetID = #String_nous
pronom_num=3
Prof(verbe$,pronom_num)
ElseIf GadgetID = #String_Vous
pronom_num=4
Prof(verbe$,pronom_num)
ElseIf GadgetID = #String_ils
pronom_num=5
Prof(verbe$,pronom_num)
ElseIf GadgetID = #String_res_je
ElseIf GadgetID = #String_res_tu
ElseIf GadgetID = #String_res_il
ElseIf GadgetID = #String_res_nous
ElseIf GadgetID = #String_res_vous
ElseIf GadgetID = #String_res_ils
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
End
;
; ************** Zone des procedures *************************
Procedure Open_Window_0()
If OpenWindow(#Window_0, 224, 8, 357, 373, "Conjugaison", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
TextGadget(#Titre, 60, 10, 220, 50, "Conjugaison")
SetGadgetFont(#Titre, FontID2)
ButtonGadget(#Button_etre, 60, 90, 100, 30, "Verbe Etre")
ButtonGadget(#Button_aller, 190, 90, 100, 30, "Verbe Aller")
TextGadget(#je, 30, 140, 40, 20, "Je")
SetGadgetFont(#je, FontID3)
TextGadget(#Tu, 30, 170, 40, 20, "Tu")
SetGadgetFont(#Tu, FontID3)
TextGadget(#il, 30, 200, 40, 20, "Il")
SetGadgetFont(#il, FontID3)
TextGadget(#Nous, 10, 230, 40, 20, "Nous")
SetGadgetFont(#Nous, FontID3)
TextGadget(#Vous, 10, 260, 40, 20, "Vous")
SetGadgetFont(#Vous, FontID3)
TextGadget(#Ils, 30, 290, 40, 20, "Ils")
SetGadgetFont(#Ils, FontID3)
StringGadget(#String_je, 70, 140, 130, 20, "")
StringGadget(#String_Tu, 70, 170, 130, 20, "")
StringGadget(#String_il, 70, 200, 130, 20, "")
StringGadget(#String_nous, 70, 230, 130, 20, "")
StringGadget(#String_Vous, 70, 260, 130, 20, "")
StringGadget(#String_ils, 70, 290, 130, 20, "")
StringGadget(#String_res_je, 230, 140, 50, 20, "")
StringGadget(#String_res_tu, 230, 170, 50, 20, "")
StringGadget(#String_res_il, 230, 200, 50, 20, "")
StringGadget(#String_res_nous, 230, 230, 50, 20, "")
StringGadget(#String_res_vous, 230, 260, 50, 20, "")
StringGadget(#String_res_ils, 230, 290, 50, 20, "")
on_off(1)
TextGadget(#Text_sign, 300, 50, 50, 20, "By Dobro")
EndIf
EndIf
EndProcedure
Procedure Prof(verbe$,pronom_num)
If verbe$="etre"
If GetGadgetText(#String_je+pronom_num)=StringField(etre$,1+pronom_num,",")
SetGadgetText( #String_res_je+pronom_num,"Bon")
fl=1
EndIf
If GetGadgetText(#String_je+pronom_num)=StringField(etre$,7+pronom_num,",")
SetGadgetText( #String_res_je+pronom_num,"Bon")
fl=1
EndIf
If GetGadgetText(#String_je+pronom_num)=StringField(etre$,13+pronom_num,",")
SetGadgetText( #String_res_je+pronom_num,"Bon")
fl=1
EndIf
If GetGadgetText(#String_je+pronom_num)=StringField(etre$,18+pronom_num,",")
SetGadgetText( #String_res_je+pronom_num,"Bon")
fl=1
EndIf
If fl=0
SetGadgetText( #String_res_je+pronom_num,"Faux")
EndIf
If fl=1 :fl=0:EndIf
EndIf
If verbe$="Aller"
If GetGadgetText(#String_je+pronom_num)=StringField(aller$,1+pronom_num,",")
SetGadgetText( #String_res_je+pronom_num,"Bon")
fl=1
EndIf
If GetGadgetText(#String_je+pronom_num)=StringField(aller$,7+pronom_num,",")
SetGadgetText( #String_res_je+pronom_num,"Bon")
fl=1
EndIf
If GetGadgetText(#String_je+pronom_num)=StringField(aller$,13+pronom_num,",")
SetGadgetText( #String_res_je+pronom_num,"Bon")
fl=1
EndIf
If GetGadgetText(#String_je+pronom_num)=StringField(aller$,18+pronom_num,",")
SetGadgetText( #String_res_je+pronom_num,"Bon")
fl=1
EndIf
If fl=0
SetGadgetText( #String_res_je+pronom_num,"Faux")
EndIf
If fl=1 :fl=0:EndIf
EndIf
EndProcedure
Procedure on_off(etat)
DisableGadget(#String_je, etat)
DisableGadget(#String_Tu,etat)
DisableGadget(#String_il,etat)
DisableGadget(#String_nous,etat)
DisableGadget(#String_Vous,etat)
DisableGadget(#String_ils,etat)
DisableGadget(#String_res_je,etat)
DisableGadget(#String_res_tu,etat)
DisableGadget(#String_res_il,etat)
DisableGadget(#String_res_nous,etat)
DisableGadget(#String_res_vous,etat)
DisableGadget(#String_res_ils,etat)
EndProcedure