If nombre de commande
Publié : jeu. 22/oct./2009 12:29
pb semble limité en nombre de commande if. Existe un code pour connaître le nombre de commande, comme If, dans son programme ?
j'ai atteint cette limite. Faut dire que ce gourmand de pâtissier a besoin de beaucoup de conditions.Fred a écrit :Théoriquement pas de limite
donnée sensible. mais merci quand mêmeOctavius a écrit :Tu dis ça parce que tu as un problème avec un code beauregard ? Tu nous fais voir ?
Code : Tout sélectionner
If ... CodeA... Else ...CodeB ... Endif
Code : Tout sélectionner
OpenConsole()
Global.I Marge, Tab = 4, LineQty
Procedure Pr(Text.S)
LineQty + 1
PrintN(Space(Marge) + Text)
EndProcedure
Procedure IfTest(Prof.I)
If Prof > 0
Pr("If ???")
Marge + Tab
IfTest(Prof - 1)
Marge - Tab
Pr("Else")
Marge + Tab
IfTest(Prof - 1)
Marge - Tab
Pr("EndIf")
Else
Pr("Sous-routine")
EndIf
EndProcedure
Repeat
Print("Saisissez la profondeur d'imbrication (commencez par 1 puis 2, etc...) : ")
Prof = Val(Input() )
PrintN("")
PrintN("")
PrintN("")
LineQty = 0
IfTest(Prof)
PrintN("")
PrintN("")
PrintN("")
PrintN("Pour " + Str(Prof) + " etage(s) d'imbrication, on a obtenu " + Str(LineQty) + " lignes de code.")
PrintN("")
PrintN("")
PrintN("")
Until Prof = 0
CloseConsole()
Pourquoi cette limite ? C'est directement lié à PureBasic ou bien aux processeurs ? Et y a-t-il une limite avec le nombre de ElseIf ?Fred a écrit :sauf au nombre d'imbrication qui ne doit pas depasser 128
Octavius a écrit :Pourquoi cette limite ? C'est directement lié à PureBasic ou bien aux processeurs ? Et y a-t-il une limite avec le nombre de ElseIf ?Fred a écrit :sauf au nombre d'imbrication qui ne doit pas depasser 128
en fait ce qui me désole c'est les certitudes utilisées !!une condition d'une profondeur de 128 étages (ou 128 imbrications) correspond à un univers d'environ 260 milliards de milliards de milliards de milliards de codes conditionnels
Code : Tout sélectionner
a=2
b=3
CallDebugger
If a=2
If b=3
Debug "ok"
EndIf
EndIf
If a=2 And b=3
Debug "ok"
EndIf
Code : Tout sélectionner
a=2
b=3
CallDebugger
If a=2
If b=3
Debug "ok"
EndIf
EndIf
If a=2 And b=3
Debug "ok"
EndIf
non, juste de simple if commeFred a écrit :Limite en imbrication ?
Code : Tout sélectionner
If variable=1:machin+1:Endif
j'utilise très peu d'imbrication, car pour moi cela complique le code. Comment dire, j'ai mémorisé tout mon code car il reste fondamentalement simple. Avec imbrication, je n'arrive plus à visualiser dans mon esprit l'ensemble du code, et donc à le mémoriser. Merci pour ton conseil.Ollivier a écrit :@Octavius
Salut, exécute mon petit code juste au-dessus et tu comprendras qu'à notre échelle d'humain comme à celle du plus puissant système de calcul réseau du Monde actuel et à venir pour au moins deux siècles, cette limite de 128 étages d'imbrications est tellement gigantesque qu'elle n'existe pas à nos petits yeux de misérables humains que nous sommes.
C'est juste que Beauregard se bat avec certain de ses défauts de méthode de programmation, et qu'en même temps (et ça peut se comprendre bien entendu) il doit éviter de publier son bébé pour être aidé. Comme je te le disais "Attention à l'imposture". On se fait vite glisser un code par des gens peu scrupuleux.
Ollivier
En fait j'attend que la marque du jeu soit protégé à l'international, ce qui prend vachement de temps.Cpl.Bator a écrit :D'ailleurs , auras t'on le droit de testé le pâtissier ?
Code : Tout sélectionner
; Si l'on place une instruction par ligne voici le Nombre obtenu
; pour prof 1 ; if else endif 3 lignes + 2 lignes subroutines
; ********************************************************************************
;pour prof 2 : 3 lignes niv1 + 6 lignes niv 2 + pow(2,2) subroutines
; ou (pow(2,0)+pow(2,1))*3+pow(2,2)
;if
; If Else EndIf
; Else
; If Else EndIf
; endif ici 3ligne
;pour prof 2 : 3 lignes niv1 + 6 lignes niv 2 + pow(2,2) subroutines
; ou somme des lignes de chaque niv *3 = (pow(2,0)+pow(2,1))*3 forme générale pour profondeur prof SOMME(pow(2,prof-1) de 0 à prof de if else ou endif
; Plus +Pow(2,2) -------------> forme générale pour profondeur prof pow(2,prof ) de subroutines
; Prg suivant
prof$=InputRequester("Nombre de lignes de prg en if(s) imbriqués","donnez la profondeur <129","128")
prof=Val(prof$)
sp.d=0
For i=0 To prof-1
sp.d+Pow(2,i)
Next
sp=sp*3+Pow(2,prof)
Debug "pour une profondeur de " + prof$+" ="+StrD(sp,0)
Code : Tout sélectionner
Dim a(128)
If a(1)=1
If a(2)=1
If a(3)=1
If a(4)=1
If a(5)=1
If a(6)=1
If a(7)=1
If a(8)=1
If a(9)=1
If a(10)=1
If a(11)=1
If a(12)=1
If a(13)=1
If a(14)=1
If a(15)=1
If a(16)=1
If a(17)=1
If a(18)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
If a(x)=1
Debug "ok"
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf