3 conditions à ajouter avec texte

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
chercheacomprendre
Messages : 72
Inscription : dim. 15/févr./2009 10:59

3 conditions à ajouter avec texte

Message par chercheacomprendre »

comment faire pour ajouter les 3 conditions suivantes dans le code ?:

si je veut un controle des valeurs n*c en fonction de la longueur b :

-> si n*c=b alors un message : les spires sont jointives.
-> si n*c<b alors un message : les spires ne sont pas jointives.
-> si n*c>b alors un message : erreur ! valeurs impossibles.

mon code:

Code : Tout sélectionner

;programme de calcul d'inductance avec la formule de Nagaoka 

;code du 19 février 2009


   
Define L.F
Define A.D 
Define B.D 
Define C.D 
Define N.D 
Define K.D

OpenWindow(-1, 0, 0, 255, 150, "Calcul de self à air", $CF0001) ; fenetre principale

TextGadget(11, 0, 5,   200, 30, "    Diamètre du mandrin en mm") ;a
TextGadget(12, 0, 35,  200, 30, "    Longueur de la self en mm") ;b
TextGadget(13, 0, 65,  200, 30, "        Diamètre du fil en mm") ;c
TextGadget(14, 0, 95,  200, 30, "             Nombre de spires") ;n
TextGadget(15, 0, 125, 200, 30, "             Inductance en µH") ;L
StringGadget(1, 200, 0,   50, 30, "") ;position a
StringGadget(2, 200, 30,  50, 30, "") ;position b
StringGadget(3, 200, 60,  50, 30, "") ;position c
StringGadget(4, 200, 90,  50, 30, "") ;position n
StringGadget(5, 200, 120, 50, 30, "") ;position L
Repeat 
   A = ValD(GetGadgetText(1) ) 
   B = ValD(GetGadgetText(2) ) 
   C = ValD(GetGadgetText(3) ) 
   N = ValD(GetGadgetText(4) ) 
  

   ; conversion des cm en mm 
   A=A/10
   B=B/10
   C=C/10

   
   ; calcul du rayon théorique suivant Nagaoka
   A=(A+C)/2
   
   
   
  ; ==========================tests pour coeficient K ============
 
    If (2*(a/b))=0
    k=1   
    EndIf
   
    If (2*(a/b)) > 0.02 And (2*(a/b)) < 0.06
    k=0.97    
    EndIf
    
    If (2*(a/b)) > 0.07 And (2*(a/b)) < 0.11
    K=0.959
    EndIf
    
    If (2*(a/b)) > 0.12 And (2*(a/b)) < 0.16
    K=0.939
    EndIf
    
    If (2*(a/b)) > 0.17 And (2*(a/b)) < 0.21
    K=0.92
    EndIf
    
    If (2*(a/b)) > 0.22 And (2*(a/b)) < 0.26
    K=0.902
    EndIf
    
    If (2*(a/b)) > 0.27 And (2*(a/b)) < 0.31
    K=0.884
    EndIf
    
    If (2*(a/b)) > 0.32 And (2*(a/b)) < 0.41
    K=0.85
    EndIf
    
    If (2*(a/b)) > 0.42 And (2*(a/b)) < 0.51
    K=0.818
    EndIf
    
    If (2*(a/b)) > 0.52 And (2*(a/b)) < 0.61
    K=0.789
    EndIf
    
    If (2*(a/b)) > 0.62 And (2*(a/b)) < 0.71
    K=0.761
    EndIf
    
    If (2*(a/b)) > 0.72 And (2*(a/b)) < 0.81
    K=0.735
    EndIf
    
    If (2*(a/b)) > 0.82 And (2*(a/b)) < 0.91
    K=0.711
    EndIf
    
    If (2*(a/b)) > 0.92 And (2*(a/b)) < 1.01
    K=0.688
    EndIf
    
    If (2*(a/b)) > 1.02 And (2*(a/b)) < 1.26
    K=0.638
    EndIf
    
    If (2*(a/b)) > 1.27 And (2*(a/b)) < 1.51
    K=0.595
    EndIf
    
    If (2*(a/b)) > 1.52 And (2*(a/b)) < 1.76
    K=0.558
    EndIf
    
    If (2*(a/b)) > 1.77 And (2*(a/b)) < 2.01
    K=0.526
    EndIf
    
    If (2*(a/b)) > 2.02 And (2*(a/b)) < 2.51
    K=0.472
    EndIf
    
    If (2*(a/b)) > 2.52 And (2*(a/b)) < 3.01
    K=0.429
    EndIf
    
    If (2*(a/b)) > 3.02 And (2*(a/b)) < 3.51
    K=0.394
    EndIf
    
    If (2*(a/b)) > 3.52 And (2*(a/b)) < 4.01
    K=0.365
    EndIf
    
    If (2*(a/b)) > 4.02 And (2*(a/b)) < 5.01
    K=0.32
    EndIf
    
    If (2*(a/b)) > 5.02 And (2*(a/b)) < 6.01
    K=0.283
    EndIf
    
    If (2*(a/b)) > 6.02 And (2*(a/b)) < 7.01
    K=0.258
    EndIf
    
    If (2*(a/b)) > 7.02 And (2*(a/b)) < 8.01
    K=0.237
    EndIf
    
    If (2*(a/b)) > 8.02 And (2*(a/b)) < 9.01
    K=0.219
    EndIf
    
    If (2*(a/b)) > 9.02 And (2*(a/b)) < 10.01
    K=0.203
    EndIf
    
    If (2*(a/b)) > 10.02 And (2*(a/b)) < 25.01
    K=0.105
    EndIf
    
    If (2*(a/b)) > 25.02 And (2*(a/b)) < 50.01
    K=0.061
    EndIf
    
    If (2*(a/b)) > 50.02 And (2*(a/b)) < 75.01
    K=0.043
    EndIf
    
    If (2*(a/b)) > 75.02 And (2*(a/b)) < 100.01
    K=0.035
    EndIf
    
    If (2*(a/b)) > 100.02 And (2*(a/b)) < 200.01
    K=0.019
    EndIf
    
    If (2*(a/b)) > 200.02 And (2*(a/b)) < 400.01
    K=0.011
    EndIf
    
    
;===================================formule de Nagaoka ==================   
   
   L = (0.0395*(a*a)*(n*n)*K) / b
      
   
   If L <> AncienResultat 
      SetGadgetText(5, StrF(L,2) ) ; sortie du résultat position 5 avec que 2 chiffres apres la virgule
   EndIf 
   AncienResultat = L   
   
   
Until WaitWindowEvent() = 16
Cls
Messages : 620
Inscription : mer. 22/juin/2005 8:51
Localisation : Nantes

Message par Cls »

Je te conseille de regarder l'aide de PureBasic (touche F1 dans l'IDE).

Renseignes toi sur les structures conditionnelles (If : Then : Endif) et sur la fonction MessageRequester(), tu trouveras ton bonheur.

Ce serait sympa également de rajouter les balises 'code' & '/code' avec des crochets autours de ton code afin qu'il soit indenté (y'a un petit icône prévu lorsque tu créés ton message...)
Patrick88
Messages : 1564
Inscription : mer. 21/janv./2004 18:24

Re: 3 conditions à ajouter avec texte

Message par Patrick88 »

chercheacomprendre a écrit : -> si n*c=b alors un message : les spires sont jointives.
-> si n*c<b alors un message : les spires ne sont pas jointives.
-> si n*c>b alors un message : erreur ! valeurs impossibles.
devient

Code : Tout sélectionner

If n*c=b : MessageRequester("Attention","les spires sont jointives.",#PB_MessageRequester_Ok)  : EndIf
If n*c<b : MessageRequester("Attention","les spires ne sont pas jointives. ",#PB_MessageRequester_Ok)  : EndIf
If n*c>b : MessageRequester("Attention","erreur ! valeurs impossibles. ",#PB_MessageRequester_Ok)  : EndIf

; #PB_MessageRequester_YesNo       : Pour afficher les boutons 'Oui' et 'Non' 
; #PB_MessageRequester_YesNoCancel : Pour afficher les boutons 'Oui', 'Non' et 'Annuler' 
; #PB_MessageRequester_Ok          : Pour afficher seulement le bouton 'OK'
Avatar de l’utilisateur
Droopy
Messages : 1151
Inscription : lun. 19/juil./2004 22:31

Message par Droopy »

-> si n*c=b alors un message : les spires sont jointives.
-> si n*c<b alors un message : les spires ne sont pas jointives.
-> si n*c>b alors un message : erreur ! valeurs impossibles.
Select me semble mieux convenir
chercheacomprendre
Messages : 72
Inscription : dim. 15/févr./2009 10:59

Re: 3 conditions à ajouter avec texte

Message par chercheacomprendre »

Patrick88 a écrit :
chercheacomprendre a écrit : -> si n*c=b alors un message : les spires sont jointives.
-> si n*c<b alors un message : les spires ne sont pas jointives.
-> si n*c>b alors un message : erreur ! valeurs impossibles.
devient

Code : Tout sélectionner

If n*c=b : MessageRequester("Attention","les spires sont jointives.",#PB_MessageRequester_Ok)  : EndIf
If n*c<b : MessageRequester("Attention","les spires ne sont pas jointives. ",#PB_MessageRequester_Ok)  : EndIf
If n*c>b : MessageRequester("Attention","erreur ! valeurs impossibles. ",#PB_MessageRequester_Ok)  : EndIf

; #PB_MessageRequester_YesNo       : Pour afficher les boutons 'Oui' et 'Non' 
; #PB_MessageRequester_YesNoCancel : Pour afficher les boutons 'Oui', 'Non' et 'Annuler' 
; #PB_MessageRequester_Ok          : Pour afficher seulement le bouton 'OK'
oui merci, mais il me bloque mon code , si non ça fonctionne
merci
chercheacomprendre
Messages : 72
Inscription : dim. 15/févr./2009 10:59

Re: 3 conditions à ajouter avec texte

Message par chercheacomprendre »

chercheacomprendre a écrit :comment faire pour ajouter les 3 conditions suivantes dans le code ?:

si je veut un controle des valeurs n*c en fonction de la longueur b :

-> si n*c=b alors un message : les spires sont jointives.
-> si n*c<b alors un message : les spires ne sont pas jointives.
-> si n*c>b alors un message : erreur ! valeurs impossibles.

mon code:

Code : Tout sélectionner

;programme de calcul d'inductance avec la formule de Nagaoka 

;code du 19 février 2009


   
Define L.F
Define A.D 
Define B.D 
Define C.D 
Define N.D 
Define K.D

OpenWindow(-1, 0, 0, 255, 150, "Calcul de self à air", $CF0001) ; fenetre principale

TextGadget(11, 0, 5,   200, 30, "    Diamètre du mandrin en mm") ;a
TextGadget(12, 0, 35,  200, 30, "    Longueur de la self en mm") ;b
TextGadget(13, 0, 65,  200, 30, "        Diamètre du fil en mm") ;c
TextGadget(14, 0, 95,  200, 30, "             Nombre de spires") ;n
TextGadget(15, 0, 125, 200, 30, "             Inductance en µH") ;L
StringGadget(1, 200, 0,   50, 30, "") ;position a
StringGadget(2, 200, 30,  50, 30, "") ;position b
StringGadget(3, 200, 60,  50, 30, "") ;position c
StringGadget(4, 200, 90,  50, 30, "") ;position n
StringGadget(5, 200, 120, 50, 30, "") ;position L
Repeat 
   A = ValD(GetGadgetText(1) ) 
   B = ValD(GetGadgetText(2) ) 
   C = ValD(GetGadgetText(3) ) 
   N = ValD(GetGadgetText(4) ) 
  

   ; conversion des cm en mm 
   A=A/10
   B=B/10
   C=C/10

   
   ; calcul du rayon théorique suivant Nagaoka
   A=(A+C)/2
   
   
   
  ; ==========================tests pour coeficient K ============
 
    If (2*(a/b))=0
    k=1   
    EndIf
   
    If (2*(a/b)) > 0.02 And (2*(a/b)) < 0.06
    k=0.97    
    EndIf
    
    If (2*(a/b)) > 0.07 And (2*(a/b)) < 0.11
    K=0.959
    EndIf
    
    If (2*(a/b)) > 0.12 And (2*(a/b)) < 0.16
    K=0.939
    EndIf
    
    If (2*(a/b)) > 0.17 And (2*(a/b)) < 0.21
    K=0.92
    EndIf
    
    If (2*(a/b)) > 0.22 And (2*(a/b)) < 0.26
    K=0.902
    EndIf
    
    If (2*(a/b)) > 0.27 And (2*(a/b)) < 0.31
    K=0.884
    EndIf
    
    If (2*(a/b)) > 0.32 And (2*(a/b)) < 0.41
    K=0.85
    EndIf
    
    If (2*(a/b)) > 0.42 And (2*(a/b)) < 0.51
    K=0.818
    EndIf
    
    If (2*(a/b)) > 0.52 And (2*(a/b)) < 0.61
    K=0.789
    EndIf
    
    If (2*(a/b)) > 0.62 And (2*(a/b)) < 0.71
    K=0.761
    EndIf
    
    If (2*(a/b)) > 0.72 And (2*(a/b)) < 0.81
    K=0.735
    EndIf
    
    If (2*(a/b)) > 0.82 And (2*(a/b)) < 0.91
    K=0.711
    EndIf
    
    If (2*(a/b)) > 0.92 And (2*(a/b)) < 1.01
    K=0.688
    EndIf
    
    If (2*(a/b)) > 1.02 And (2*(a/b)) < 1.26
    K=0.638
    EndIf
    
    If (2*(a/b)) > 1.27 And (2*(a/b)) < 1.51
    K=0.595
    EndIf
    
    If (2*(a/b)) > 1.52 And (2*(a/b)) < 1.76
    K=0.558
    EndIf
    
    If (2*(a/b)) > 1.77 And (2*(a/b)) < 2.01
    K=0.526
    EndIf
    
    If (2*(a/b)) > 2.02 And (2*(a/b)) < 2.51
    K=0.472
    EndIf
    
    If (2*(a/b)) > 2.52 And (2*(a/b)) < 3.01
    K=0.429
    EndIf
    
    If (2*(a/b)) > 3.02 And (2*(a/b)) < 3.51
    K=0.394
    EndIf
    
    If (2*(a/b)) > 3.52 And (2*(a/b)) < 4.01
    K=0.365
    EndIf
    
    If (2*(a/b)) > 4.02 And (2*(a/b)) < 5.01
    K=0.32
    EndIf
    
    If (2*(a/b)) > 5.02 And (2*(a/b)) < 6.01
    K=0.283
    EndIf
    
    If (2*(a/b)) > 6.02 And (2*(a/b)) < 7.01
    K=0.258
    EndIf
    
    If (2*(a/b)) > 7.02 And (2*(a/b)) < 8.01
    K=0.237
    EndIf
    
    If (2*(a/b)) > 8.02 And (2*(a/b)) < 9.01
    K=0.219
    EndIf
    
    If (2*(a/b)) > 9.02 And (2*(a/b)) < 10.01
    K=0.203
    EndIf
    
    If (2*(a/b)) > 10.02 And (2*(a/b)) < 25.01
    K=0.105
    EndIf
    
    If (2*(a/b)) > 25.02 And (2*(a/b)) < 50.01
    K=0.061
    EndIf
    
    If (2*(a/b)) > 50.02 And (2*(a/b)) < 75.01
    K=0.043
    EndIf
    
    If (2*(a/b)) > 75.02 And (2*(a/b)) < 100.01
    K=0.035
    EndIf
    
    If (2*(a/b)) > 100.02 And (2*(a/b)) < 200.01
    K=0.019
    EndIf
    
    If (2*(a/b)) > 200.02 And (2*(a/b)) < 400.01
    K=0.011
    EndIf
    
    
;===================================formule de Nagaoka ==================   
   
   L = (0.0395*(a*a)*(n*n)*K) / b
      
   
   If L <> AncienResultat 
      SetGadgetText(5, StrF(L,2) ) ; sortie du résultat position 5 avec que 2 chiffres apres la virgule
   EndIf 
   AncienResultat = L   
   
   
Until WaitWindowEvent() = 16


oui je ne sais pas comment faire pour mettre ce test de conditions , avec un texte de message...
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

Salut ChercheAComprendre,

Est-ce que tu peux me poster ton code en ayant aggrandi la hauteur de la fenêtre?

Merci.
chercheacomprendre
Messages : 72
Inscription : dim. 15/févr./2009 10:59

3 conditions a ajouter

Message par chercheacomprendre »

la fenetre a été agrandie pour y placer une ligne de texte suivant la condition qui va


[/code];programme de calcul d'inductance avec la formule de Nagaoka

;code du 21 février 2009



Define L.F
Define A.D
Define B.D
Define C.D
Define N.D
Define K.D

OpenWindow(-1, 0, 0, 255, 180, "Calcul de self à air", $CF0001) ; fenetre principale

TextGadget(11, 0, 5, 200, 30, " Diamètre du mandrin en mm") ;a
TextGadget(12, 0, 35, 200, 30, " Longueur de la self en mm") ;b
TextGadget(13, 0, 65, 200, 30, " Diamètre du fil en mm") ;c
TextGadget(14, 0, 95, 200, 30, " Nombre de spires") ;n
TextGadget(15, 0, 125, 200, 30, " Inductance en µH") ;L
StringGadget(1, 200, 0, 50, 30, "") ;position a
StringGadget(2, 200, 30, 50, 30, "") ;position b
StringGadget(3, 200, 60, 50, 30, "") ;position c
StringGadget(4, 200, 90, 50, 30, "") ;position n
StringGadget(5, 200, 120, 50, 30, "") ;position L
Repeat
A = ValD(GetGadgetText(1) )
B = ValD(GetGadgetText(2) )
C = ValD(GetGadgetText(3) )
N = ValD(GetGadgetText(4) )


; conversion des cm en mm
A=A/10
B=B/10
C=C/10


; calcul du rayon théorique suivant Nagaoka
A=(A+C)/2



; ==========================tests pour coeficient K ============

If (2*(a/b))=0 :K=1 : EndIf

If (2*(a/b)) > 0.02 And (2*(a/b)) < 0.06 : K=0.97 : EndIf

If (2*(a/b)) > 0.07 And (2*(a/b)) < 0.11 : K=0.959: EndIf

If (2*(a/b)) > 0.12 And (2*(a/b)) < 0.16 : K=0.939: EndIf

If (2*(a/b)) > 0.17 And (2*(a/b)) < 0.21 : K=0.92 : EndIf

If (2*(a/b)) > 0.22 And (2*(a/b)) < 0.26 : K=0.902: EndIf

If (2*(a/b)) > 0.27 And (2*(a/b)) < 0.31 : K=0.884: EndIf

If (2*(a/b)) > 0.32 And (2*(a/b)) < 0.41 : K=0.85 : EndIf

If (2*(a/b)) > 0.42 And (2*(a/b)) < 0.51 : K=0.818: EndIf

If (2*(a/b)) > 0.52 And (2*(a/b)) < 0.61 : K=0.789: EndIf

If (2*(a/b)) > 0.62 And (2*(a/b)) < 0.71 : K=0.761: EndIf

If (2*(a/b)) > 0.72 And (2*(a/b)) < 0.81 : K=0.735: EndIf

If (2*(a/b)) > 0.82 And (2*(a/b)) < 0.91 : K=0.711: EndIf

If (2*(a/b)) > 0.92 And (2*(a/b)) < 1.01 : K=0.688: EndIf

If (2*(a/b)) > 1.02 And (2*(a/b)) < 1.26 : K=0.638: EndIf

If (2*(a/b)) > 1.27 And (2*(a/b)) < 1.51 : K=0.595: EndIf

If (2*(a/b)) > 1.52 And (2*(a/b)) < 1.76 : K=0.558: EndIf

If (2*(a/b)) > 1.77 And (2*(a/b)) < 2.01 : K=0.526: EndIf

If (2*(a/b)) > 2.02 And (2*(a/b)) < 2.51 : K=0.472: EndIf

If (2*(a/b)) > 2.52 And (2*(a/b)) < 3.01 : K=0.429: EndIf

If (2*(a/b)) > 3.02 And (2*(a/b)) < 3.51 : K=0.394: EndIf

If (2*(a/b)) > 3.52 And (2*(a/b)) < 4.01 : K=0.365: EndIf

If (2*(a/b)) > 4.02 And (2*(a/b)) < 5.01 : K=0.32 : EndIf

If (2*(a/b)) > 5.02 And (2*(a/b)) < 6.01 : K=0.283: EndIf

If (2*(a/b)) > 6.02 And (2*(a/b)) < 7.01 : K=0.258: EndIf

If (2*(a/b)) > 7.02 And (2*(a/b)) < 8.01 : K=0.237: EndIf

If (2*(a/b)) > 8.02 And (2*(a/b)) < 9.01 : K=0.219: EndIf

If (2*(a/b)) > 9.02 And (2*(a/b)) < 10.01: K=0.203: EndIf

If (2*(a/b)) > 10.02 And (2*(a/b)) < 25.01:K=0.105: EndIf

If (2*(a/b)) > 25.02 And (2*(a/b)) < 50.01:K=0.061: EndIf

If (2*(a/b)) > 50.02 And (2*(a/b)) < 75.01:K=0.043: EndIf

If (2*(a/b)) > 75.02 And (2*(a/b)) < 100.01:K=0.035:EndIf

If (2*(a/b)) > 100.02 And (2*(a/b)) < 200.01:K=0.019:EndIf

If (2*(a/b)) > 200.02 And (2*(a/b)) < 400.01:K=0.011:EndIf


;===================================formule de Nagaoka ==================

L = (0.0395*(a*a)*(n*n)*K) / b




If L <> AncienResultat
SetGadgetText(5, StrF(L,2) ) ; sortie du résultat position 5 avec que 2 chiffres apres la virgule
EndIf
AncienResultat = L


Until WaitWindowEvent() = 16
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

Message par comtois »

Tu peux remplacer tes If en créant une table et en faisant une boucle.

Exemple

Code : Tout sélectionner

#TableMax = 3
Structure Coef
  Mini.d
  Maxi.d
  k.d
EndStructure

Define Resultat.d, K.d
Dim Table.coef(#TableMax)

For n = 1 To #TableMax
  Read.d Table(n)\Mini 
  Read.d Table(n)\Maxi 
  Read.d Table(n)\k   
Next n

Resultat = (2*(a/b))
;Donne une valeur à résultat pour tester 
Resultat = 0.059

For n = 1 To #TableMax
  If Resultat>=Table(n)\Mini And Resultat<=Table(n)\Maxi
    K = Table(n)\k
    Break
  EndIf
Next n

Debug K

;Table à compléter ....
DataSection
Data.d 0.00, 0.01, 1.00
Data.d 0.02, 0.06, 0.97
Data.d 0.07, 0.11, 0.959  
EndDataSection
http://purebasic.developpez.com/
Je ne réponds à aucune question technique en PV, utilisez le forum, il est fait pour ça, et la réponse peut profiter à tous.
chercheacomprendre
Messages : 72
Inscription : dim. 15/févr./2009 10:59

Message par chercheacomprendre »

comtois a écrit :Tu peux remplacer tes If en créant une table et en faisant une boucle.

Exemple

Code : Tout sélectionner

#TableMax = 3
Structure Coef
  Mini.d
  Maxi.d
  k.d
EndStructure

Define Resultat.d, K.d
Dim Table.coef(#TableMax)

For n = 1 To #TableMax
  Read.d Table(n)\Mini 
  Read.d Table(n)\Maxi 
  Read.d Table(n)\k   
Next n

Resultat = (2*(a/b))
;Donne une valeur à résultat pour tester 
Resultat = 0.059

For n = 1 To #TableMax
  If Resultat>=Table(n)\Mini And Resultat<=Table(n)\Maxi
    K = Table(n)\k
    Break
  EndIf
Next n

Debug K

;Table à compléter ....
DataSection
Data.d 0.00, 0.01, 1.00
Data.d 0.02, 0.06, 0.97
Data.d 0.07, 0.11, 0.959  
EndDataSection

oui merci pour le code,
mais sur mon code les conditions pour trouvé le K est ok, il fonctionne bien, par contre pour y placer tois conditions :
-> si n*c=b alors un message : les spires sont jointives.
-> si n*c<b alors un message : les spires ne sont pas jointives.
-> si n*c>b alors un message : erreur ! valeurs impossibles.

là je ne sais comment faire!
apres le calcul de la valeur de l'inductance , y placer en bas de la fenetre une ligne de message indiquant un des trois messages.

mais je ne sais pas le faire.

salut
Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

chercheacomprendre a écrit :a fenetre a été agrandie pour y placer une ligne de texte suivant la condition qui va
Exactement!

1) Tu peux l'aggrandir encore un peu, car ça manque de hauteur encore.

2) Ensuite, ajoute un gadget de texte qui affichera le message voulu dans ce nouvel emplacement.(Instruction TextGadget() )

3) Après, pour afficher quelque chose à l'écran via ce nouveau gadget, il faut utiliser l'instruction SetGadgetText() (Rappel d'anglais : Set = Régler).

ça sera là ta grande difficulté : retrouve le code que Le Soldat Inconnu a écrit dans un autre de tes sujet pour me rappeler que je t'ai posté une mauvaise boucle principale. Tu peux toujours insérer tes trois conditions dans la boucle principale pour voir, seulement ton CPU va saturer. Or LSI t'a posté un excellent modèle de boucle principal (il est organisé pour ne pas saturer le CPU) avec plein de fonction Select, Case, EndSelect, etc...
chercheacomprendre
Messages : 72
Inscription : dim. 15/févr./2009 10:59

calcul de self suite

Message par chercheacomprendre »

Ollivier a écrit :
chercheacomprendre a écrit :a fenetre a été agrandie pour y placer une ligne de texte suivant la condition qui va
Exactement!

1) Tu peux l'aggrandir encore un peu, car ça manque de hauteur encore.

2) Ensuite, ajoute un gadget de texte qui affichera le message voulu dans ce nouvel emplacement.(Instruction TextGadget() )

3) Après, pour afficher quelque chose à l'écran via ce nouveau gadget, il faut utiliser l'instruction SetGadgetText() (Rappel d'anglais : Set = Régler).

ça sera là ta grande difficulté : retrouve le code que Le Soldat Inconnu a écrit dans un autre de tes sujet pour me rappeler que je t'ai posté une mauvaise boucle principale. Tu peux toujours insérer tes trois conditions dans la boucle principale pour voir, seulement ton CPU va saturer. Or LSI t'a posté un excellent modèle de boucle principal (il est organisé pour ne pas saturer le CPU) avec plein de fonction Select, Case, EndSelect, etc...
oui, j'ai essayé avec addgadgetitem mais j'ai du oublié un truc ...

mon code :

Code : Tout sélectionner


;code du 21 février 2009 

; fenetre élargie pour messages 
    
Define L.F 
Define A.D 
Define B.D 
Define C.D 
Define N.D 
Define K.D

Enumeration

#gadgettext
EndEnumeration



OpenWindow(-1, 0, 0, 280, 240, "Calcul de self à air", $CF0001) ; fenetre principale 

TextGadget(11, 0, 20,   200, 30, "    Diamètre du mandrin en mm") ;a 
TextGadget(12, 0, 50,  200, 30, "    Longueur de la self en mm") ;b 
TextGadget(13, 0, 80,  200, 30, "        Diamètre du fil en mm") ;c 
TextGadget(14, 0, 110,  200, 30, "             Nombre de spires") ;n 
TextGadget(15, 0, 140, 200, 30, "             Inductance en µH") ;L 
StringGadget(1, 200, 10,   50, 30, "") ;position a 
StringGadget(2, 200, 40,  50, 30, "") ;position b 
StringGadget(3, 200, 70,  50, 30, "") ;position c 
StringGadget(4, 200, 100,  50, 30, "") ;position n 
StringGadget(5, 200, 130, 50, 30, "") ;position L 
Repeat 
   A = ValD(GetGadgetText(1) ) 
   B = ValD(GetGadgetText(2) ) 
   C = ValD(GetGadgetText(3) ) 
   N = ValD(GetGadgetText(4) ) 
  

   ; conversion des cm en mm 
   A=A/10 
   B=B/10 
   C=C/10 

    
   ; calcul du rayon théorique suivant Nagaoka 
   A=(A+C)/2 
    
    
    
  ; ==========================tests pour coeficient K ============ 
  
    If (2*(a/b))=0 :K=1 : EndIf
    
    If (2*(a/b)) > 0.02 And (2*(a/b)) < 0.06 : K=0.97 : EndIf 
    
    If (2*(a/b)) > 0.07 And (2*(a/b)) < 0.11 : K=0.959: EndIf
    
    If (2*(a/b)) > 0.12 And (2*(a/b)) < 0.16 : K=0.939: EndIf
    
    If (2*(a/b)) > 0.17 And (2*(a/b)) < 0.21 : K=0.92 : EndIf 
    
    If (2*(a/b)) > 0.22 And (2*(a/b)) < 0.26 : K=0.902: EndIf 
    
    If (2*(a/b)) > 0.27 And (2*(a/b)) < 0.31 : K=0.884: EndIf
    
    If (2*(a/b)) > 0.32 And (2*(a/b)) < 0.41 : K=0.85 : EndIf 
    
    If (2*(a/b)) > 0.42 And (2*(a/b)) < 0.51 : K=0.818: EndIf 
    
    If (2*(a/b)) > 0.52 And (2*(a/b)) < 0.61 : K=0.789: EndIf
    
    If (2*(a/b)) > 0.62 And (2*(a/b)) < 0.71 : K=0.761: EndIf 
    
    If (2*(a/b)) > 0.72 And (2*(a/b)) < 0.81 : K=0.735: EndIf
    
    If (2*(a/b)) > 0.82 And (2*(a/b)) < 0.91 : K=0.711: EndIf
    
    If (2*(a/b)) > 0.92 And (2*(a/b)) < 1.01 : K=0.688: EndIf
    
    If (2*(a/b)) > 1.02 And (2*(a/b)) < 1.26 : K=0.638: EndIf 
    
    If (2*(a/b)) > 1.27 And (2*(a/b)) < 1.51 : K=0.595: EndIf 
    
    If (2*(a/b)) > 1.52 And (2*(a/b)) < 1.76 : K=0.558: EndIf
    
    If (2*(a/b)) > 1.77 And (2*(a/b)) < 2.01 : K=0.526: EndIf
    
    If (2*(a/b)) > 2.02 And (2*(a/b)) < 2.51 : K=0.472: EndIf
    
    If (2*(a/b)) > 2.52 And (2*(a/b)) < 3.01 : K=0.429: EndIf
    
    If (2*(a/b)) > 3.02 And (2*(a/b)) < 3.51 : K=0.394: EndIf 
    
    If (2*(a/b)) > 3.52 And (2*(a/b)) < 4.01 : K=0.365: EndIf
    
    If (2*(a/b)) > 4.02 And (2*(a/b)) < 5.01 : K=0.32 : EndIf
    
    If (2*(a/b)) > 5.02 And (2*(a/b)) < 6.01 : K=0.283: EndIf 
    
    If (2*(a/b)) > 6.02 And (2*(a/b)) < 7.01 : K=0.258: EndIf
    
    If (2*(a/b)) > 7.02 And (2*(a/b)) < 8.01 : K=0.237: EndIf 
    
    If (2*(a/b)) > 8.02 And (2*(a/b)) < 9.01 : K=0.219: EndIf 
    
    If (2*(a/b)) > 9.02 And (2*(a/b)) < 10.01: K=0.203: EndIf 
    
    If (2*(a/b)) > 10.02 And (2*(a/b)) < 25.01:K=0.105: EndIf  
    
    If (2*(a/b)) > 25.02 And (2*(a/b)) < 50.01:K=0.061: EndIf 
    
    If (2*(a/b)) > 50.02 And (2*(a/b)) < 75.01:K=0.043: EndIf
    
    If (2*(a/b)) > 75.02 And (2*(a/b)) < 100.01:K=0.035:EndIf
    
    If (2*(a/b)) > 100.02 And (2*(a/b)) < 200.01:K=0.019:EndIf 
    
    If (2*(a/b)) > 200.02 And (2*(a/b)) < 400.01:K=0.011:EndIf  
    
    
;===================================formule de Nagaoka ==================    
    
   L = (0.0395*(a*a)*(n*n)*K) / b 
   
   
 ; modifs texte a ajouter en bas apres résultat de L  (le 21-02)
   
   If n*c=b : AddGadgetItem (#gadgettext ,0,190,200,30,"les spires sont jointives"): EndIf
   If n*c<b : AddGadgetItem ( #gadgettext,0,190,200,30, "les spires ne sont pas jointives"): EndIf
   If n*c>b : AddGadgetItem ( #gadgettext ,0,190,200,30, "erreur ! valeurs incompatibles.") :EndIf
   
      
    
   If L <> AncienResultat 
      SetGadgetText(5, StrF(L,2) ) ; sortie du résultat position 5 avec que 2 chiffres apres la virgule 
   EndIf 
   AncienResultat = L    
    
    
Until WaitWindowEvent() = 16

Ollivier
Messages : 4197
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

Message par Ollivier »

chercheacomprendre a écrit :oui, j'ai essayé avec addgadgetitem mais j'ai du oublié un truc ...
8O
???

A quel endroit je parle de AddGadgetItem dans ma réponse ????

Merci.
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

il y a 2 topic , pour le meme sujet , là ... ça va pas :)

je stop celui ci , que j'effacerai par la suite

continuez ici , s'il vous plait !! :)

http://www.purebasic.fr/french/viewtopic.php?t=9067


chercheacomprendre

faut pas creer des sujets multiple, concernant la meme chose !! merci


car dans ton deuxieme sujet , j'ai répondu a ton probleme de IF multiple

et je viens de voir que Comtois avait deja répondu ici pour a meme chose !! :twisted:
Verrouillé