Bonsoir tout le monde, voici mon souci je viens d'avoir le programme qui converti
en décimal, binaire et hexadécimal sauf que quand je lance j'ai une erreur (ERR : SYNTAX) à cette ligne :
Code
0->Z
Voici le programme en entier :
Code
Lbl 0
0->Z
Menu("GE:","HEX > DEC",A,"DEC > HEX",B,"DEC > BIN",C,"BIN > DEC",D,"QUITTER",Z)
:
Lbl A
ClrList L1,L2
ClrHome
10->A:11->B:12->C:13->D:14->E:15->F
Disp "*-HEX > DEC----*"
0->S
Input "NB CHIFFRE=",G
G->dim L1
For(I,1,G)
Repeat H[supérieur ou égal]0 and H[inférieur ou égal]15
ClrHome
Disp "*-HEX > DEC----*","NB"
Output(2,4,I)
Prompt H
int H->H
If H<0 or H>15
Then:Output(5,4,"ERROR:")
If H<0:Output(5,11,"H<0")
If H>15:Output(5,11,"H>15")
Pause
End
H->L1(I)
End
16^(G-I)->L2(I)
S+L1(I)*L2(I)->S
End
5->K:0->L
Output(7,1,"HEX=")
For(J,1,G)
If L1(J)>0:1->L
If L1(J)[supérieur ou égal]10:K+1->K
If L1(J)=10:Output(7,K,"A")
If L1(J)=11:Output(7,K,"B")
If L1(J)=12:Output(7,K,"C")
If L1(J)=13:Output(7,K,"D")
If L1(J)=14:Output(7,K,"E")
If L1(J)=15:Output(7,K,"F")
If L1(J)<10 and L=1
Then:K+1->K:Output(7,K,L1(J))
End
End
Output(8,1,"DEC=")
Output(8,6,S)
Pause
ClrHome
Menu("> BIN","NON",0,"OUI",1)
Lbl 1
1->Z
Goto C
:
Lbl D
ClrHome
ClrList L1,L2
Disp "*-BIN > DEC----*"
0->S
Input "NB CHIFFRE=",G
G->dim L1
For(I,1,G)
Repeat H=0 or H=1
ClrHome
Disp "*-BIN > DEC----*","NB"
Output(2,4,I)
Prompt H
int H->H
If H<0 or H>1
Then:Output(5,4,"ERROR:")
If H<0:Output(5,11,"H<0")
If H>1:Output(5,11,"H>1")
Pause
End
H->L1(I)
End
2^(G-I)->L2(I)
S+L1(I)*L2(I)->S
End
Disp "","",""
Output(6,1,"BIN SUR")
Output(6,9,G)
Output(6,12,"BITS"
Pause L1
Output(8,1,"DEC=")
Output(8,6,S)
Pause
Menu("> HEX","NON",0,"OUI",2)
Lbl 2
1->Z
Goto B
:
Lbl B
ClrHome
Disp "*-DEC > HEX----*","MAX=4294967295"
If Z=0
Then:Prompt S
Else:Disp "S=":Output(3,4,S)
End
ClrList L1,L2
If S<16^8
Then
{16^7,16^6,16^5,16^4,16^3,16²,16}->L1
Disp "","HEX="
For(I,1,7)
int (S/L1(I))->L2(I)
S-L1(I)*L2(I)->S
End
S->L2(8)
5->A:0->B
For(J,1,8)
If L2(J)>0:1->B
If L2(J)[supérieur ou égal]10:A+1->A
If L2(J)=10:Output(5,A,"A")
If L2(J)=11:Output(5,A,"B")
If L2(J)=12:Output(5,A,"C")
If L2(J)=13:Output(5,A,"D")
If L2(J)=14:Output(5,A,"E")
If L2(J)=15:Output(5,A,"F")
If L2(J)<10 and B=1
Then:A+1->A:Output(5,A,L2(J))
End
End
Else
Output(5,3,"ERROR: S>MAX")
End
Pause
ClrHome
Goto 0
:
Lbl C
ClrHome
Disp "*-DEC > BIN----*","MAX=4294967295"
If Z=0
Then:Prompt S
Else:Disp "S=":Output(3,4,S)
End
ClrList L1,L2
If S<2^32
Then
For(I,0,31)
2^(31-I)->L1(I+1)
End
0->A:0->B
Disp "","BIN SUR"
For(J,1,32)
int (S/L1(J))->L2(J)
If L2(J)=1
Then:1->B:S-L1(J)->S
If A=0:J->A
End
End
Output(5,9,33-A)
Output(5,12,"BITS")
For(K,1,33-A)
If K[inférieur ou égal]16
Then:Output(6,K,L2(K+A-1))
Else:Output(7,K-16,L2(K+A-1))
End
End
Else
Output(5,3,"ERROR: S>MAX")
End
Pause
ClrHome
Goto 0
::
Lbl Z
ClrHome
Autorisation : Membre
Nb de messages : 3
Inscrit le : Mer 15 Oct 2008, 0:55
Posté le : Mer 15 Oct 2008, 21:34
Erf cela fais toujours la même au même endroit.
J'ai modifié tout se qui est en rouge et en noir la ou j'ai les errreur de lancement :
Lbl 0 0->Z
Menu("GE:","HEX > DEC",A,"DEC > HEX",B,"DEC > BIN",C,"BIN > DEC",D,"QUITTER",Z) :
Lbl A ClrList L1,L2
ClrHome
10->A:11->B:12->C:13->D:14->E:15->F
Disp "*-HEX > DEC----*"
0->S
Input "NB CHIFFRE=",G
G->dim L1
For(I,1,G)
Repeat H[supérieur ou égal]0 and H[inférieur ou égal]15
ClrHome
Disp "*-HEX > DEC----*","NB"
Output(2,4,I)
Prompt H
int H->H
If H<0 or H>15
Then:Output(5,4,"ERROR:")
If H<0:Output(5,11,"H<0")
If H>15:Output(5,11,"H>15")
Pause
End
H->L1(I)
End
16^(G-I)->L2(I)
S+L1(I)*L2(I)->S
End
5->K:0->L
Output(7,1,"HEX=")
For(J,1,G)
If L1(J)>0:1->L
If L1(J)[supérieur ou égal]10:K+1->K
If L1(J)=10:Output(7,K,"A")
If L1(J)=11:Output(7,K,"B")
If L1(J)=12:Output(7,K,"C")
If L1(J)=13:Output(7,K,"D")
If L1(J)=14:Output(7,K,"E")
If L1(J)=15:Output(7,K,"F")
If L1(J)<10 and L=1
Then:K+1->K:Output(7,K,L1(J))
End
End
Output(8,1,"DEC=")
Output(8,6,S)
Pause
ClrHome
Menu("> BIN","NON",0,"OUI",1)
Lbl 1
1->Z
Goto C :
Lbl D ClrHome
ClrList L1,L2
Disp "*-BIN > DEC----*"
0->S
Input "NB CHIFFRE=",G
G->dim L1
For(I,1,G)
Repeat H=0 or H=1
ClrHome
Disp "*-BIN > DEC----*","NB"
Output(2,4,I)
Prompt H
int H->H
If H<0 or H>1
Then:Output(5,4,"ERROR:")
If H<0:Output(5,11,"H<0")
If H>1:Output(5,11,"H>1")
Pause
End
H->L1(I)
End
2^(G-I)->L2(I)
S+L1(I)*L2(I)->S
End
Disp "","",""
Output(6,1,"BIN SUR")
Output(6,9,G)
Output(6,12,"BITS"
Pause L1
Output(8,1,"DEC=")
Output(8,6,S)
Pause
Menu("> HEX","NON",0,"OUI",2)
Lbl 2
1->Z
Goto B :
Lbl B ClrHome
Disp "*-DEC > HEX----*","MAX=4294967295"
If Z=0
Then:Prompt S
Else:Disp "S=":Output(3,4,S)
End
ClrList L1,L2
If S<16^8
Then
{16^7,16^6,16^5,16^4,16^3,16²,16}->L1
Disp "","HEX="
For(I,1,7)
int (S/L1(I))->L2(I)
S-L1(I)*L2(I)->S
End
S->L2(
5->A:0->B
For(J,1,
If L2(J)>0:1->B
If L2(J)[supérieur ou égal]10:A+1->A
If L2(J)=10:Output(5,A,"A")
If L2(J)=11:Output(5,A,"B")
If L2(J)=12:Output(5,A,"C")
If L2(J)=13:Output(5,A,"D")
If L2(J)=14:Output(5,A,"E")
If L2(J)=15:Output(5,A,"F")
If L2(J)<10 and B=1
Then:A+1->A:Output(5,A,L2(J))
End
End
Else
Output(5,3,"ERROR: S>MAX")
End
Pause
ClrHome
Goto 0 :
Lbl C ClrHome
Disp "*-DEC > BIN----*","MAX=4294967295"
If Z=0
Then:Prompt S
Else:Disp "S=":Output(3,4,S)
End
ClrList L1,L2
If S<2^32
Then
For(I,0,31)
2^(31-I)->L1(I+1)
End
0->A:0->B
Disp "","BIN SUR"
For(J,1,32)
int (S/L1(J))->L2(J)
If L2(J)=1
Then:1->B:S-L1(J)->S
If A=0:J->A
End
End
Output(5,9,33-A)
Output(5,12,"BITS")
For(K,1,33-A)
If K[inférieur ou égal]16
Then:Output(6,K,L2(K+A-1))
Else:Output(7,K-16,L2(K+A-1))
End
End
Else
Output(5,3,"ERROR: S>MAX")
End
Pause
ClrHome
Goto 0 ::
Lbl Z
ClrHome
Autorisation : Membre
Nb de messages : 879
Inscrit le : Sam 16 Jui 2007, 13:37
Posté le : Jeu 16 Oct 2008, 19:05
Tu programmes sur Ti-graph ?
Si oui, lorsque tu lance le programme vas où se trouve l'erreur, efface ClrHome (ou ClrList) et remplace par la pré-commande ClrHome (eidem avec ClrList) qui se trouve dans [PRGM] + [->] + [8]..
Sinon je ne vois pas d'où le bug peut venir, ta calculatrice est bien en anglais (je préfère être sûr^^).
Ps: Bravo pour ton programme, mais quel dommage d'écrire tout un paquet de lignes pour ça ! Un traitement générale de toute les bases serait plus court !