Précédente Accueil Remonter Suivante

MATH 1

Visual Basic for MS-DOS

 

 

DECLARE SUB orthmath (re%, ni%, mo1$(), mo2$(), rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB tablesplus (re%, ni%, rt$, gg2$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB compter (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB doubles (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB attendre (tx!)
DECLARE SUB bilan (ma$(), niveaux%(), eleve%, VarEnreg AS ANY, rt$, noir%, bleu%, rouge%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB calmoy (t$(), moy$(), niveaux%())
DECLARE SUB chiffres (fond%)
DECLARE SUB entree (x%, y%)
DECLARE SUB fleches (v%, h%, w$(), np%, r%, drap%, v2%, h2%)
DECLARE SUB flechesmenu (w$(), r%, coul%)
DECLARE SUB lettres (fond%)
DECLARE SUB ligne23 (x%, y%)
DECLARE SUB quitter (fond%)
DECLARE SUB titre (titr$)
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB centre (v%, cc%, ph$)
DECLARE SUB tableauexo (p$())
DECLARE SUB ouinon (r$)
DECLARE SUB addition (re%, ni%, rt$, gg$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB avantapres (re%, ni%, rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB classernombres (re%, ni%, rt$, pre$, gg$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB decompo (re%, ni%, rt$, gg2$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB lettre (re%, ni%, un$(), di$(), ex$(), ch$(), mot$(), rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB multiplications (re%, ni%, rt$, gg$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB nombrechiffre (re%, ni%, un$(), di$(), ex$(), rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB regle (re%, ni%, rt$, gg$, pre$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB soustractions (re%, ni%, flagscreengraph%, rt$, gg$, titr$, pre$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB tableauplus (re%, ni%, rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB tablesmulti (re%, ni%, rt$, gg2$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB valeurchiffre (re%, ni%, rt$, pre$, gg$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB frise (re%, ni%, rt$, gg$, pre$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%, coef1!, coef2!, nbniv%)
DECLARE SUB heure (re%, ni%, rt$, gg$, pre$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB coord (re%, ni%, rt$, gg$, pre$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%, coef1!, coef2!, nbniv%)
DECLARE SUB reproduction (re%, ni%, rt$, gg$, pre$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%, coef1!, coef2!, nbniv%)
DECLARE SUB moitie (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'EXERCICES AAS MATH niveau I
'module 1 - bibliothèque
'Daniel CLERC
'24/12/2004
'version 1.4.5

DEFINT A-Z

'variables globales
COMMON SHARED ni, couleur, rt$, gg$, gg2$, pre$, titr$, prog, eleve, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill

' Inclut les fichiers contenant les déclarations relatives aux procédures appelées.
'$INCLUDE: 'MOUSE.BI'
'$INCLUDE: 'VBDOS.BI'

CONST FALSE = 0
CONST TRUE = NOT FALSE

rt$ = CHR$(17) + CHR$(196) + CHR$(217)
gg$ = CHR$(24) + " " + CHR$(25) + " puis " + rt$
gg2$ = CHR$(24) + " " + CHR$(25) + " " + CHR$(27) + " " + CHR$(26) + " puis " + rt$

coef1! = .72 'pour carré
coef2! = .72 'pour cercle

TYPE TypeEnreg
nom AS STRING * 20
prenom AS STRING * 20
nbexo AS STRING * 21
Divers AS STRING * 50
notes AS STRING * 3000
END TYPE
DIM VarEnreg AS TypeEnreg

ma = 21
DIM moy$(39), niveaux(ma)
DIM t$(100), p$(ma)
DIM mo1$(24), mo2$(14)'orthmath
DIM un$(9), di$(9), ex$(6), un2$(9), di2$(9), ex2$(6) 'pour chiffres
DIM ch$(54), mot$(36)

OPEN "pointeur.dat" FOR INPUT AS #1
INPUT #1, eleve, sens, couleur, texte, lecture$
CLOSE
OPEN "pointeur.dat" FOR OUTPUT AS #1
WRITE #1, eleve, 2, 1, texte, lecture$
CLOSE

ON ERROR GOTO erreur '===
flagscreengraph = 0
SCREEN 9
SCREEN 0
'couleur = 0'===

IF couleur = 1 THEN
noir = 0: bleu = 1: vert = 2: rouge = 4: marron = 6: blanc = 7: vertclair = 10: cyanclair = 11: rougeclair = 12: jaune = 14: blancbrill = 15
ELSE
noir = 0: bleu = 0: vert = 15: rouge = 7: marron = 7: blanc = 7: vertclair = 15: cyanclair = 15: rougeclair = 15: jaune = 15: blancbrill = 15
END IF



COLOR , noir, noir: CLS : KEY OFF: LOCATE , , 0
GOSUB init
RANDOMIZE TIMER

IF sens = 1 AND eleve > 0 THEN
CALL bilan(p$(), niveaux(), eleve, VarEnreg, rt$, noir, bleu, rouge, vertclair, cyanclair, rougeclair, jaune, blancbrill)
END IF

menuprincipal:
' Vérifie que le gestionnaire de souris est installé.
MouseInit
MouseShow

COLOR , bleu, noir: CLS
CALL cadre(2, 20, 40, 2, vert)
COLOR , vert
CALL centre(3, blancbrill, "ACTIVITES de MATHEMATIQUES - niveau I")
COLOR , bleu


IF eleve <> 0 THEN
'lecture des notes
OPEN "fichier.dat" FOR RANDOM AS #1 LEN = LEN(VarEnreg)
GET #1, eleve, VarEnreg
nom$ = RTRIM$(VarEnreg.nom)
pre$ = RTRIM$(VarEnreg.prenom)
'math niv 1 est en 3°
nbexo$ = LTRIM$(STR$(VAL(MID$(VarEnreg.nbexo, 7, 3))))
resultat$ = MID$(VarEnreg.notes, 801, 400)
j = 1
FOR i = 1 TO 200 STEP 2 '===
t$(j) = MID$(resultat$, i, 2)
j = j + 1
NEXT
CLOSE
CALL calmoy(t$(), moy$(), niveaux())
END IF

IF VAL(nbexo$) > 1 THEN
COLOR jaune
z$ = RTRIM$(nbexo$) + " exercices"
LOCATE 4, 79 - LEN(z$): PRINT z$
END IF
LOCATE 4, 2
COLOR jaune
IF eleve <> 0 THEN
w$ = pre$ + " " + nom$
IF LEN(w$) > 17 THEN
PRINT nom$
ELSE
PRINT w$
END IF
END IF

CALL tableauexo(p$())

'affiche liste exo
h1 = 6: h2 = 32: h3 = 58
COLOR blancbrill
LOCATE 7
FOR i = 1 TO 7
LOCATE , h1: PRINT p$(i): PRINT
NEXT
LOCATE 7
FOR i = 8 TO 14
LOCATE , h2: PRINT p$(i): PRINT
NEXT
LOCATE 7
FOR i = 15 TO 21
LOCATE , h3: PRINT p$(i): PRINT
NEXT

IF eleve <> 0 THEN
'affiche éval sur trois colonnes
COLOR , noir
debut = 1: fin = 7: h = 4
FOR boucle = 1 TO 3
LOCATE 7
FOR i = debut TO fin
LOCATE , h
IF moy$(i) = "" THEN
PRINT " ": PRINT
ELSEIF (VAL(moy$(i)) = 9 OR VAL(moy$(i)) = 10) THEN
COLOR vertclair: PRINT "A": PRINT
ELSEIF (VAL(moy$(i)) = 7 OR VAL(moy$(i)) = 8) THEN
COLOR vert: PRINT "B": PRINT
ELSEIF (VAL(moy$(i)) = 6 OR VAL(moy$(i)) = 5) THEN
COLOR jaune: PRINT "C": PRINT
ELSE
COLOR rougeclair: PRINT "D": PRINT
END IF
COLOR blancbrill
NEXT
debut = fin + 1: fin = fin + 7: IF fin > ma THEN fin = ma
h = h + 26
NEXT boucle
COLOR , bleu
END IF
CALL flechesmenu(p$(), prog, rouge)

COLOR , noir

IF prog = 0 THEN
COLOR , bleu
LOCATE 22, 1: PRINT SPACE$(80)
LOCATE 22, 28
COLOR blanc: BEEP: PRINT "Quitter ";
CALL ouinon(r$)
IF r$ = "O" THEN GOTO fin
GOTO menuprincipal
END IF

IF prog = 42 THEN
CALL bilan(p$(), niveaux(), eleve, VarEnreg, rt$, noir, bleu, rouge, vertclair, cyanclair, rougeclair, jaune, blancbrill)
GOTO menuprincipal
END IF

COLOR , noir: CLS
titr$ = p$(prog): ni = 1

COLOR , noir

'valeur de la matière
mat = 0
FOR i = 1 TO prog - 1
mat = mat + niveaux(i)
NEXT

SELECT CASE prog
CASE 1
CALL decompo(re, ni, rt$, gg2$, pre$, titr$, prog, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 2
CALL tablesplus(re%, ni%, rt$, gg2$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 3
CALL tableauplus(re%, ni%, rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 4
CALL addition(re, ni, rt$, gg$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 5
CALL orthmath(re, ni, mo1$(), mo2$(), rt$, gg$, pre$, titr$, prog, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 6
CALL valeurchiffre(re, ni, rt$, pre$, gg$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 7
CALL nombrechiffre(re%, ni%, un$(), di$(), ex$(), rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 8
CALL lettre(re%, ni%, un$(), di$(), ex$(), ch$(), mot$(), rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 9
CALL classernombres(re, ni, rt$, pre$, gg$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 10
CALL regle(re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 11
CALL avantapres(re, ni, rt$, gg$, pre$, titr$, prog, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 12
CALL tablesmulti(re%, ni%, rt$, gg2$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 13
CALL multiplications(re, ni, rt$, gg$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 14
CALL soustractions(re, ni, flagscreengraph, rt$, gg$, titr$, pre$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 15
CALL doubles(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 16
CALL moitie(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 17
CALL compter(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 18
IF flagscreengraph = 0 THEN
CALL heure(re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
ELSE
GOSUB graphique: GOTO menuprincipal
END IF

CASE 19
IF flagscreengraph = 0 THEN
CALL reproduction(re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur, coef1!, coef2!, nbniv)
ELSE
GOSUB graphique: GOTO menuprincipal
END IF

CASE 20
IF flagscreengraph = 0 THEN
CALL frise(re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur, coef1!, coef2!, nbniv)
ELSE
GOSUB graphique: GOTO menuprincipal
END IF

CASE 21
IF flagscreengraph = 0 THEN
CALL coord(re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur, coef1!, coef2!, nbniv)
ELSE
GOSUB graphique: GOTO menuprincipal
END IF

END SELECT
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE &H417, (PEEK(&H417) AND &HBF) 'minus
DEF SEG

GOSUB enregistre
CALL ligne23(noir, noir)
CALL entree(noir, noir)
GOTO menuprincipal
END

fin:
COLOR , noir
IF eleve > 0 THEN
CALL bilan(p$(), niveaux(), eleve, VarEnreg, rt$, noir, bleu, rouge, vertclair, cyanclair, rougeclair, jaune, blancbrill)
END IF
CLS
RUN "menuexo"
END

enregistre:
COLOR , noir: IF eleve = 0 THEN RETURN
CALL centre(23, blanc, "Enregistrement de la note")
re$ = LTRIM$(STR$(re)): IF LEN(re$) = 1 THEN re$ = " " + re$
pointeur = ni + mat
OPEN "fichier.dat" FOR RANDOM AS #1 LEN = LEN(VarEnreg)
GET #1, eleve, VarEnreg
nbexo$ = VarEnreg.nbexo

nombre$ = LTRIM$(STR$(VAL(MID$(nbexo$, 7, 3)) + 1))
IF LEN(nombre$) = 1 THEN
nombre$ = "00" + nombre$
ELSEIF LEN(nombre$) = 2 THEN
nombre$ = "0" + nombre$
END IF

'=== mat ce est en 3° -> 6
IF VAL(nombre$) < 1000 THEN
VarEnreg.nbexo = MID$(nbexo$, 1, 6) + nombre$ + MID$(nbexo$, 10)
END IF

notes$ = MID$(VarEnreg.notes, 801, 400)
IF pointeur = 1 THEN
notes$ = re$ + MID$(notes$, 2 * pointeur + 1)
ELSE
notes$ = MID$(notes$, 1, (pointeur - 1) * 2) + re$ + MID$(notes$, 2 * pointeur + 1)
END IF
VarEnreg.notes = MID$(VarEnreg.notes, 1, 800) + notes$ + MID$(VarEnreg.notes, 1201)
PUT #1, eleve, VarEnreg
CLOSE #1
CALL attendre(.5)
CALL centre(23, noir, SPACE$(80))
RETURN

graphique:
COLOR , bleu: CLS
BEEP
CALL cadre(8, 5, 70, 8, rouge)
COLOR , rouge
CALL centre(10, blanc, "ATTENTION")
CALL centre(12, blancbrill, "Votre ordinateur ne possède pas de carte graphique EGA ou VGA.")
CALL centre(14, blancbrill, "Cette activité n'est donc pas accessible.")
COLOR , noir
CALL getinvimouse(w)
w$ = INPUT$(1)
RETURN

init:
DATA Décomposition,2
DATA Tables d'additions,4
DATA Tableau d'additions,4
DATA Additions,4
DATA Orthographe,2
DATA Valeur des chiffres,2
DATA Nombres en chiffres,3
DATA Nombres en lettres,3
DATA Nombres rangés,3
DATA Suite des nombres,2
DATA Avant - Après,3

DATA Tables de multi.,4
DATA Multiplications,4
DATA Soustractions,4
DATA Double des nombres,3
DATA Moitié des nombres,3
DATA Compter,4
DATA Heure et minutes,2
DATA Reproduction,3
DATA Frises,2
DATA Coordonnées,3

FOR i = 1 TO ma: READ p$(i), niveaux(i): NEXT
nbniveaux = 0
FOR i = 1 TO ma
nbniveaux = nbniveaux + niveaux(i)
NEXT

'data exo1

'pour orthomath

DATA zéro,un,deux,trois,quatre,cinq,six,sept,huit,neuf,dix,onze,douze,treize
DATA quatorze,quinze,seize,vingt,trente,quarante,cinquante,soixante,cent,mille
FOR i = 1 TO 24: READ mo1$(i): NEXT
'idem
DATA calcul,opération,soustraction,multiplication,somme,reste,mathématiques
DATA addition,exercice,problème,retenue,nombre,chiffre,total
FOR i = 1 TO 14: READ mo2$(i): NEXT

DATA "un ","deux ","trois ","quatre ","cinq ","six ","sept ","huit ","neuf "
DATA "dix ","vingt ","trente ","quarante ","cinquante ","soixante ","soixante dix ","quatre vingt ","quatre vingt dix "
DATA "onze ","douze ","treize ","quatorze ","quinze ","seize "
FOR i = 1 TO 9: READ un$(i): NEXT
FOR i = 1 TO 9: READ di$(i): NEXT
FOR i = 1 TO 6: READ ex$(i): NEXT

DATA "un ","deux ","trois ","quatre ","cinq ","six ","sept ","huit ","neuf "
DATA "dix ","vingt ","trente ","quarante ","cinquante ","soixante ","soixante dix ","quatre vingt ","quatre vingt dix "
DATA "onze ","douze ","treize ","quatorze ","quinze ","seize "
FOR i = 1 TO 9: READ un2$(i): NEXT
FOR i = 1 TO 9: READ di2$(i): NEXT
FOR i = 1 TO 6: READ ex2$(i): NEXT

DATA 14,38,42,66,81,17,29,72,51,88,93,55,70,78,83,84,90,99
DATA 115,214,326,570,432,745,850,963,100,147,676,782,930,623,296,868,950,111
DATA 1237,2568,2390,5861,8743,7639,3219,6388,7324,8888,9999,6666,5555,4444,3333,2222,7777,1111
FOR i = 1 TO 54: READ ch$(i): NEXT

FOR i = 1 TO 9
mot$(i) = RTRIM$(un2$(i))
NEXT
FOR j = 1 TO 9
mot$(i) = RTRIM$(di2$(j))
i = i + 1
NEXT
FOR j = 1 TO 6
mot$(i) = RTRIM$(ex2$(j))
i = i + 1
NEXT
mot$(25) = "cent"
mot$(26) = "mille"
mot$(27) = "million"
mot$(28) = "et"
mot$(29) = "millions"
mot$(30) = "cents"
mot$(31) = "zéro"
mot$(32) = "zero"

RETURN

erreur:
programme$ = "exo_ma1"

IF ERR = 5 THEN
flagscreengraph = 1
RESUME NEXT
END IF

SCREEN 0
COLOR , bleu: CLS
BEEP
CALL cadre(8, 5, 70, 9, rouge)
COLOR , rouge
CALL centre(10, blanc, "ATTENTION")


SELECT CASE ERR
CASE 71
CALL centre(12, blancbrill, "Disque non prêt")

CASE 70
CALL centre(12, blancbrill, "Disquette protégée")

CASE 53, 57, 72
CALL centre(12, blancbrill, "Problème sur le disque")

CASE 61
CALL centre(12, blancbrill, "Disque plein")

CASE 25, 26, 68
CALL centre(12, blancbrill, "Imprimante non prête")

CASE 27
CALL centre(12, blancbrill, "Imprimante sans papier")

CASE ELSE
CALL centre(12, blancbrill, "Erreur système n°" + LTRIM$(STR$(ERR)))
CALL centre(14, blancbrill, "Essayez de relancez le programme.")
CLOSE
w$ = INPUT$(1)
COLOR , noir: CLS
END

END SELECT

CALL centre(14, blancbrill, "Corrigez puis tapez " + rt$ + " [Echap] = Fin")
CALL getinvimouse(r)
IF r = 27 THEN COLOR , noir: CLS : END
COLOR , bleu: CLS : RUN programme$
RESUME


DEFINT A-Z
SUB attendre (tx!)
tx! = tx! * 2
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
debut! = TIMER
DO
fin! = TIMER
IF INKEY$ <> "" THEN EXIT DO
LOOP WHILE fin! - debut! < tx!
tx! = tx! / 2
END SUB

DEFINT A-Z
SUB bilan (ma$(), niveaux(), eleve, VarEnreg AS TypeEnreg, rt$, noir, bleu, rouge, vertclair, cyanclair, rougeclair, jaune, blancbrill)

ma = 21
DIM t$(100), moy$(ma), bi$(21)
FOR i = 1 TO 21: bi$(i) = ma$(i): NEXT

ll$ = STRING$(30, ".")
pt$ = MID$(ll$, 1, 15)
ni$ = "Niveau " + CHR$(26) + " 1 2 3 4"

COLOR , noir: CLS
'lecture des notes
OPEN "fichier.dat" FOR RANDOM AS #1 LEN = LEN(VarEnreg)
GET #1, eleve, VarEnreg
nom$ = RTRIM$(VarEnreg.nom)
pre$ = RTRIM$(VarEnreg.prenom)
'math niv 1 est en 3°
nbexo$ = LTRIM$(MID$(VarEnreg.nbexo, 7, 3))

IF VAL(nbexo$) = 0 THEN CLOSE : EXIT SUB

resultat$ = MID$(VarEnreg.notes, 801, 400)
CLOSE

CALL titre("BILAN")

j = 1
FOR i = 1 TO 200 STEP 2 '===
t$(j) = MID$(resultat$, i, 2)
j = j + 1
NEXT

CALL calmoy(t$(), moy$(), niveaux())

'moy générale
tt = 0: nt = 0
FOR j = 1 TO ma
IF moy$(j) <> "" THEN tt = tt + VAL(moy$(j)): nt = nt + 1
NEXT j
IF nt = 0 THEN moygen$ = " " ELSE moygen$ = LTRIM$(STR$(INT((tt / nt) * 10) / 10))

z$ = pre$ + " " + nom$ + " a fait" + STR$(VAL(nbexo$)) + " exercice"
IF VAL(nbexo$) > 1 THEN z$ = z$ + "s"
z$ = z$ + " de mathématiques (niveau I)"
COLOR , marron
CALL centre(4, blancbrill, " " + z$ + " ")
COLOR , bleu
LOCATE 6, 16: COLOR vertclair: PRINT ni$: COLOR jaune: LOCATE 6, 36: PRINT "Moy"
COLOR vertclair: LOCATE 6, 57: PRINT ni$: COLOR jaune: LOCATE 6, 77: PRINT "Moy"
COLOR , rouge

v = 7: h = 1: debut = 8: fin = 18: GOSUB cadre2
v = 7: h = 42: debut = 8: fin = 17: GOSUB cadre2
LOCATE 8
FOR i = 1 TO 11
LOCATE , 2: PRINT bi$(i); " "; LEFT$(ll$, 20 - LEN(bi$(i)))
NEXT
LOCATE 8
FOR i = 12 TO ma
LOCATE , 43: PRINT bi$(i); " "; LEFT$(ll$, 20 - LEN(bi$(i)))
NEXT

'affichage des moyennes
LOCATE 8
FOR i = 1 TO 11
LOCATE , 36
IF moy$(i) = "" THEN
PRINT
ELSEIF VAL(moy$(i)) = 9 OR VAL(moy$(i)) = 10 THEN
COLOR blancbrill
PRINT moy$(i);
COLOR vertclair
LOCATE , 38
PRINT "A"
ELSEIF VAL(moy$(i)) = 7 OR VAL(moy$(i)) = 8 THEN
COLOR blancbrill
PRINT moy$(i);
COLOR vert
LOCATE , 38
PRINT "B"
ELSEIF VAL(moy$(i)) = 6 OR VAL(moy$(i)) = 5 THEN
COLOR blancbrill
PRINT moy$(i);
LOCATE , 38
COLOR jaune
PRINT "C"
ELSE
COLOR blancbrill
PRINT moy$(i);
COLOR rougeclair
LOCATE , 38
PRINT "D"
END IF
NEXT
LOCATE 8
FOR i = 12 TO ma
LOCATE , 77
IF moy$(i) = "" THEN
PRINT
ELSEIF VAL(moy$(i)) = 9 OR VAL(moy$(i)) = 10 THEN
COLOR blancbrill
PRINT moy$(i);
COLOR vertclair
LOCATE , 79
PRINT "A"
ELSEIF VAL(moy$(i)) = 7 OR VAL(moy$(i)) = 8 THEN
COLOR blancbrill
PRINT moy$(i);
COLOR vert
LOCATE , 79
PRINT "B"
ELSEIF VAL(moy$(i)) = 5 OR VAL(moy$(i)) = 6 THEN
COLOR blancbrill
PRINT moy$(i);
LOCATE , 79
COLOR jaune
PRINT "C"
ELSE
COLOR blancbrill
PRINT moy$(i);
COLOR rougeclair
LOCATE , 79
PRINT "D"
END IF
NEXT
COLOR blanc

'++++++++++++++
v = 8
debut = 1
FOR Valeur = 1 TO 11
fin = debut + (niveaux(Valeur) - 1)
h = 24: GOSUB place
debut = fin + 1: v = v + 1
NEXT

v = 8
FOR Valeur = 12 TO ma
fin = debut + (niveaux(Valeur) - 1)
h = 65: GOSUB place
debut = fin + 1: v = v + 1
NEXT
'++++++++++
COLOR , bleu
IF VAL(moygen$) <> 0 THEN
COLOR cyanclair: LOCATE 19, 43
moygen = INT(VAL(moygen$))
'CALL convertir(moygen$)
PRINT "Moyenne générale :"; moygen; "sur 10"
END IF
CALL entree(noir, noir)

EXIT SUB

place:
LOCATE v
FOR i = debut TO fin
LOCATE , h
IF VAL(t$(i)) < 10 THEN PRINT " ";
IF t$(i) <> " " THEN PRINT LTRIM$(t$(i)); ELSE PRINT "-";
h = h + 3
NEXT
RETURN

cadre2:
COLOR blancbrill
LOCATE v, h: PRINT "┌─────────────────────┬──┬──┬──┬──┬───┐"
FOR i = debut TO fin
LOCATE , h: PRINT "│ │ │ │ │ │ │"
NEXT i
LOCATE , h: PRINT "└─────────────────────┴──┴──┴──┴──┴───┘"
RETURN


END SUB

DEFINT A-Z
SUB cadre (v, h, l, nli, c)
'c est l'intérieur
'le fond écran est bleu

v2 = v

'cadre
COLOR c, bleu

LOCATE v2, h
PRINT STRING$(l + 2, 220)
FOR i = 1 TO nli - 1
v2 = v2 + 1: LOCATE v2, h
PRINT STRING$(l + 2, 219)
NEXT

COLOR , bleu
LOCATE v2 + 1, h: PRINT CHR$(223)

COLOR , 0
LOCATE v + 1
FOR i = 1 TO nli
LOCATE , h + l + 2
PRINT " "
NEXT
LOCATE v2 + 1, h + 1
PRINT STRING$(l + 1, 223)
COLOR blancbrill
END SUB

DEFINT A-Z
SUB cadre1 (v, h, l, nli, c, c2, c3)

'c est l'intérieur
'c2 est la couleur du fond de la bande
'c3 est la couleur de la bande
COLOR c3, c2
LOCATE v, h: PRINT CHR$(220); STRING$(l, 220); CHR$(220)
FOR i = 1 TO nli - 1
v = v + 1
LOCATE v, h
COLOR , c2: PRINT CHR$(219); : COLOR , c: PRINT SPACE$(l); : COLOR , c2: PRINT CHR$(219)
NEXT
LOCATE v + 1, h: PRINT CHR$(223); STRING$(l, 223); CHR$(223)
COLOR blancbrill, c

END SUB

DEFINT A-Z
SUB cadre3 (v, h, nb, coul)
'inversion de v et h !
LINE (((h - 1) * 8) - 5, ((v - 1) * 14) - 2)-(((h - 1 + nb) * 8) + 5, (v * 14) + 2), coul, B

END SUB

DEFINT A-Z
SUB calmoy (t$(), moy$(), niveaux())
'29/3/95
debut = 1
FOR Valeur = 1 TO 21
fin = debut + (niveaux(Valeur) - 1)
GOSUB calcul
debut = fin + 1
NEXT

EXIT SUB

calcul:
tt = 0: nt = 0
FOR j = debut TO fin
IF t$(j) <> " " THEN tt = tt + VAL(t$(j)): nt = nt + 1
NEXT j
IF nt = 0 THEN moy$(Valeur) = "" ELSE moy$(Valeur) = LTRIM$(STR$(INT(INT(tt / nt) * 10) / 10))
RETURN
END SUB

DEFINT A-Z
SUB centre (v, cc, ph$)
COLOR cc
LOCATE v, INT((80 / 2) + 1 - LEN(ph$) / 2)
PRINT ph$
COLOR 15
END SUB

DEFINT A-Z
SUB chiffres (fond)
'31/5/95
DIM c(80), x$(80)
f = 0
'on mémorise la zone quitter
LOCATE 23, 1, 0
COLOR rougeclair, noir
FOR i = 1 TO 80
x$(i) = CHR$(SCREEN(23, i))
c(i) = SCREEN(23, i, 1): IF c(i) > 15 THEN f = 1 'erreur à cause du fond
NEXT

LOCATE 23, 1: PRINT SPACE$(80)

DEF SEG = 0: POKE 1050, PEEK(1052): DEF SEG
BEEP

CALL centre(23, rougeclair, "Des chiffres !")

CALL attendre(1)

'on restitue la zone quitter
LOCATE 23, 1
FOR i = 1 TO 80
IF f = 0 THEN
COLOR c(i)
END IF
PRINT x$(i);
NEXT
PRINT
COLOR , fond
END SUB

DEFINT A-Z
SUB claviernumerique (z$)
CALL titre(titr$)
CALL cadre(4, 5, 70, 15, marron)
COLOR , marron
w$ = "Avec les touches du clavier numérique, tu vas devoir"
IF eleve <> 0 THEN
CALL centre(6, blancbrill, pre$ + ","): w$ = LCASE$(w$)
CALL centre(8, blancbrill, w$)
ELSE
CALL centre(7, blancbrill, w$)
END IF
CALL centre(9, blancbrill, z$)
LOCATE 11: h = 35
LOCATE , h: PRINT "7 8 9"
LOCATE , h: PRINT " \ │ /"
LOCATE , h: PRINT "4───┼───6"
LOCATE , h: PRINT " / │ \"
LOCATE , h: PRINT "1 2 3"
CALL centre(17, blancbrill, "Tu peux corriger tes erreurs avec la touche " + CHR$(27) + "- ou la touche suppr.")

CALL entree(noir, noir)
z$ = "": w$ = ""

END SUB

DEFINT A-Z
SUB consigne (nl, w$, z$, y$)

CALL titre(titr$)
l = LEN(w$)
IF LEN(z$) > l THEN l = LEN(z$)
IF LEN(y$) > l THEN l = LEN(y$)

l = l + 6
h = INT(40 - l / 2)

IF eleve <> 0 THEN nl = nl + 1

IF nl = 1 OR nl = 2 THEN
v = 8
ELSEIF nl = 3 THEN
v = 7
ELSEIF nl = 4 THEN
v = 6
END IF

CALL cadre(v, h, l, 4 + (nl * 2), marron)
COLOR , marron
IF eleve <> 0 THEN
CALL centre(v + 3, blancbrill, pre$ + ","): w$ = LCASE$(w$)
CALL centre(v + 5, blancbrill, w$)
CALL centre(v + 7, blancbrill, z$)
CALL centre(v + 10, blancbrill, y$)
ELSE
CALL centre(v + 3, blancbrill, w$)
CALL centre(v + 5, blancbrill, z$)
CALL centre(v + 8, blancbrill, y$)
END IF
CALL entree(noir, noir)
w$ = "": z$ = "": y$ = ""

END SUB

DEFINT A-Z
SUB convertir (z$)
'convertir les . en ,
s = INSTR(1, z$, ".")
IF s <> 0 THEN z$ = MID$(z$, 1, s - 1) + "," + MID$(z$, s + 1)
END SUB

DEFINT A-Z
SUB entree (x, y)
COLOR blanc, x
CALL centre(23, blanc, rt$)
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
r$ = ""
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
r$ = CHR$(13)
CALL attendre(.5)
END IF
LOOP WHILE r$ = ""

COLOR , y
END SUB

DEFINT A-Z
SUB erreur2 (tx!)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, rougeclair, "Erreur")
CALL attendre(tx!)
CALL centre(23, blancbrill, SPACE$(10))
END SUB

DEFINT A-Z
SUB erreur3 (tx!)
COLOR , noir
CALL centre(23, noir, SPACE$(6))
CALL centre(23, rougeclair, "Erreur"): CALL attendre(tx!)
CALL centre(23, blancbrill, " ")

END SUB

DEFINT A-Z
SUB exact2 (tx!)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, jaune, "Exact"): CALL attendre(tx!)
CALL centre(23, blancbrill, " ")
END SUB

DEFINT A-Z
SUB exact3 (tx!)
COLOR , noir
CALL centre(23, noir, SPACE$(5))
CALL centre(23, jaune, "Exact"): CALL attendre(tx!)
CALL centre(23, blancbrill, " ")

END SUB

DEFINT A-Z
SUB fleches (v, h, w$(), np, r, drap, v2, h2)
coul = rouge
'PRINT v2, h2
'v2 et h2 sont la ligne colonne des fleches
DIM p$(np)

LOCATE , , 0
FOR i = 1 TO np: p$(i) = w$(i): NEXT
l2 = 0
FOR i = 1 TO np
l1 = LEN(p$(i)): IF l2 < l1 THEN l2 = l1
NEXT
FOR i = 1 TO np
p$(i) = p$(i) + SPACE$(l2 - LEN(p$(i)))
NEXT

IF h2 > 0 THEN
COLOR blanc, noir
LOCATE v2, h2: PRINT gg$
END IF

'souris
v_mini = v: v_maxi = v_mini + np - 1
h_mini = h - 1: h_maxi = LEN(p$(1)) + h_mini + 1
'LOCATE 22, 1: PRINT v_mini, v_maxi, h_mini, h_maxi '===
'cadre
IF drap = 1 THEN
CALL cadre(v - 1, h - 3, l2 + 4, np + 1, coul)
END IF
COLOR blancbrill, coul

LOCATE v
FOR i = 1 TO np
LOCATE , h - 1: PRINT " "; p$(i); " "
NEXT
vt = v - 1
LOCATE v, h - 1
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(1); " "
COLOR blancbrill, coul
DO
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
'LOCATE 21, 1: PRINT "Position de la souris : "; v_mouse; ", "; h_mouse '===
IF lButton THEN
IF v_mouse >= v_mini AND v_mouse <= v_maxi THEN
IF h_mouse >= h_mini AND h_mouse <= h_maxi THEN
LOCATE v_mini
FOR i = 1 TO np
LOCATE , h_mini: PRINT " "; p$(i); " "
NEXT
calcul = v_mouse - v_mini + 1
LOCATE v_mouse, h_mini
COLOR coul, blancbrill
PRINT " "; p$(calcul); " "
CALL attendre(.3)
r = calcul
EXIT SUB
ELSE
BEEP
END IF
ELSEIF v_mouse = v2 AND h_mouse = h2 THEN
rr = 72 'fleche haut
souris = 1
CALL attendre(.2)
EXIT DO
ELSEIF v_mouse = v2 AND h_mouse = h2 + 2 THEN
rr = 80 'fleche bas
souris = 1
CALL attendre(.2)
EXIT DO
ELSEIF v_mouse = v2 AND (h_mouse >= h2 + 9 AND h_mouse <= h2 + 11) THEN
rr = 13
souris = 1
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF

LOOP WHILE r$ = ""

IF souris = 0 THEN
IF LEN(r$) < 2 THEN
rr = ASC(r$)
ELSE
rr = ASC(RIGHT$(r$, 1))
END IF
END IF

IF rr = 27 THEN
CALL quitter(coul)
END IF

LOCATE v, h - 1: PRINT " "; p$(v - vt); " "
IF rr = 72 THEN v = v - 1: IF v = vt THEN v = vt + np
IF rr = 80 THEN v = v + 1: IF v = vt + np + 1 THEN v = vt + 1
LOCATE v, h - 1
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(v - vt); " "
COLOR blancbrill, coul
LOOP WHILE rr <> 13
r = v - vt
COLOR blancbrill

END SUB

DEFINT A-Z
SUB fleches2 (v%, h%, ll%, nm%, h2%, w$(), r, coul)
DIM p$(nm%)
CONST gauche = 75, droite = 77, bas = 80, haut = 72

'on met des espaces à la fin
FOR i = 1 TO nm
p$(i) = w$(i)
NEXT
l2 = 0
FOR i = 1 TO nm
l1 = LEN(p$(i)): IF l2 < l1 THEN l2 = l1
NEXT
FOR i = 1 TO nm
p$(i) = p$(i) + SPACE$(l2 - LEN(p$(i)))
NEXT
'+++
n! = nm / 2
paire = 0: IF n! = INT(nm / 2) THEN paire = 1
vv = v: hh = h: r = 1
GOSUB affiche

'fleches
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
LOCATE v, h - 1
PRINT " "; p$(1); " "
COLOR blancbrill, coul

DO
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE &H417, (PEEK(&H417) AND &HBF) 'minus
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
'LOCATE 22, 1: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF v_mouse >= vv AND v_mouse <= vv + ll - 1 THEN
FOR nombre = 1 TO nm
IF v_mouse = vv + nombre - 1 THEN
IF h_mouse >= h AND h_mouse <= h + l2 THEN
GOSUB affiche
LOCATE v_mouse, h - 1
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(nombre); " "
COLOR blancbrill, coul
CALL attendre(.3)
r = nombre
EXIT SUB

ELSEIF h_mouse >= h2 AND h_mouse <= h2 + l2 THEN
GOSUB affiche
LOCATE v_mouse, h2 - 1
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(nombre + ll); " "
COLOR blancbrill, coul
CALL attendre(.3)
r = nombre + ll
EXIT SUB
END IF
END IF
NEXT

ELSEIF v_mouse = 23 THEN
IF h_mouse = 33 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 35 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 39 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 46 AND h_mouse <= 48 THEN
'entree
rr = 13
CALL attendre(.3)
souris = 1
EXIT DO

END IF
ELSE
BEEP
END IF
END IF

LOOP WHILE r$ = ""

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

IF rr = 27 THEN
CALL quitter(coul)
END IF

LOCATE v, hh - 1
PRINT " "; p$(r); " "

GOSUB fldirect
LOCATE v, hh - 1
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
COLOR blancbrill, coul
LOOP WHILE rr <> 13

EXIT SUB

fldirect:
IF rr = gauche THEN r = r - ll: IF hh = h2 THEN hh = h ELSE IF hh = h THEN hh = h2 'gauche
IF rr = droite THEN
IF paire = 0 AND r = ll + 1 THEN
r = r + ll + 1
ELSE
r = r + ll
END IF
IF hh = h2 THEN hh = h ELSE IF hh = h THEN hh = h2 'droite
END IF
IF rr = haut THEN v = v - 1: r = r - 1 'haut
IF rr = bas THEN v = v + 1: r = r + 1 'bas

IF r = ll + 1 THEN v = vv: hh = h2
IF r = ll THEN v = ll + (vv - 1): hh = h
IF r = 2 * ll THEN v = ll + (vv - 1): hh = h2
IF r > nm THEN r = 1: v = vv: hh = h
IF r >= 1 THEN RETURN
r = nm
v = (vv - 1) + nm - ll: hh = h2
RETURN

affiche:
COLOR , coul
LOCATE vv
FOR i = 1 TO ll: LOCATE , h - 1: PRINT " "; p$(i); " ": NEXT
LOCATE vv
FOR i = ll + 1 TO nm: LOCATE , h2 - 1: PRINT " "; p$(i); " ": NEXT
RETURN
END SUB

DEFINT A-Z
SUB flechesmenu (w$(), r, coul)
nm = 21 '===
DIM p$(nm)
CONST gauche = 75, droite = 77, bas = 80, haut = 72
h1 = 6: h2 = 32: h3 = 58

'on met des espaces à la fin
FOR i = 1 TO nm
p$(i) = w$(i)
NEXT
l2 = 0
FOR i = 1 TO nm
l1 = LEN(p$(i)): IF l2 < l1 THEN l2 = l1
NEXT
FOR i = 1 TO nm
p$(i) = p$(i) + SPACE$(l2 - LEN(p$(i)))
NEXT
'+++

h = h1: v = 7
r = 1

DO

IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
LOCATE v, h - 1
PRINT " "; p$(r); " "
COLOR blancbrill, coul

hh = h: vv = v

'fleches
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE &H417, (PEEK(&H417) AND &HBF) 'minus
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 1: PRINT "Position de la souris : "; v_mouse; ", "; h_mouse '===
IF lButton THEN
'ligne fleches et entree
IF v_mouse = 22 THEN
IF h_mouse = 33 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 35 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 39 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 46 AND h_mouse <= 48 THEN
'entree
rr = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 3 AND h_mouse <= 15 THEN
'ligne echap et *
rr = 27
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 68 AND h_mouse <= 78 THEN
rr = 42
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
END IF

'lignes noms des activités
IF v_mouse = 7 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 1
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 8
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 15
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF
ELSEIF v_mouse = 9 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 2
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 9
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 16
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSE
BEEP
END IF
ELSEIF v_mouse = 11 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 3
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 10
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 17
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF
ELSEIF v_mouse = 13 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 4
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 11
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 18
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF
ELSEIF v_mouse = 15 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 5
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 12
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 19
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF
ELSEIF v_mouse = 17 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 6
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 13
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 20
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF

ELSEIF v_mouse = 19 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 7
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 14
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 21
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP

END IF

ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 0 AND LEN(r$) < 2 THEN
rr = ASC(r$)
ELSEIF souris = 0 THEN
rr = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE rr

CASE gauche
h = h - 26
IF h < h1 THEN
v = v - 2: h = h3
END IF
IF v < 7 THEN
v = 19
END IF

CASE droite
h = h + 26
IF h > h3 THEN
v = v + 2: h = h1
END IF
IF v > 19 THEN
v = 7
END IF

CASE bas
v = v + 2
IF v > 19 THEN
IF h = h1 THEN
h = h2: v = 7
ELSEIF h = h2 THEN
h = h3: v = 7
ELSEIF h = h3 THEN
h = h1: v = 7
END IF
END IF

CASE haut
v = v - 2
IF v < 7 THEN
IF h = h3 THEN
h = h2: v = 19
ELSEIF h = h2 THEN
h = h1: v = 19
ELSEIF h = h1 THEN
h = h3: v = 19
END IF
END IF

CASE 13
GOSUB calculr
EXIT SUB

CASE 27
r = 0
EXIT SUB

CASE 42, 36, 56, 230, 43
IF eleve <> 0 THEN
'l'étoile
r = 42
EXIT SUB
END IF

END SELECT

COLOR blancbrill, coul
LOCATE vv, hh - 1
PRINT " "; p$(r); " "

GOSUB calculr

LOOP

EXIT SUB

calculr:
IF h = h1 THEN
r = ((v - 7) / 2) + 1
ELSEIF h = h2 THEN
r = ((v - 7) / 2) + 8
ELSEIF h = h3 THEN
r = ((v - 7) / 2) + 15
END IF
RETURN

afficheliste:
'affiche liste exo
h1 = 5: h2 = 31: h3 = 57
COLOR blancbrill
LOCATE 7
FOR i = 1 TO 7
LOCATE , h1: PRINT " "; p$(i); " ": PRINT
NEXT
LOCATE 7
FOR i = 8 TO 14
LOCATE , h2: PRINT " "; p$(i); " ": PRINT
NEXT
LOCATE 7
FOR i = 15 TO 21
LOCATE , h3: PRINT " "; p$(i); " ": PRINT
NEXT
RETURN

END SUB

DEFINT A-Z
SUB getinvi (rr%)
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
LOOP WHILE r$ = ""
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END SUB

DEFINT A-Z
SUB getinvimouse (rr)
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
r$ = CHR$(13)
CALL attendre(.5)
END IF
LOOP WHILE r$ = ""
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))


END SUB

DEFINT A-Z
SUB inputgen (nl%, r$, deb%, fin%, fond%)
'3/12/96
DIM re$(nl + 1)

inpdebut:
r$ = ".": xx = 0
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
ligne = CSRLIN
col = POS(0)
LOCATE ligne, col, 1
IF (deb% = 65 OR deb% = 32) AND prog <> 5 THEN PRINT LEFT$(SPACE$(80), nl)
'pour orth math =====

IF prog = 9 THEN PRINT " " 'pour classement nombres ===
IF prog = 17 THEN PRINT " " 'pour compter ===
IF prog = 21 OR prog = 18 THEN PRINT " " 'pour heures & coordonnées ni = 2 ===
LOCATE ligne, col, 1

FOR ii = 1 TO nl + 1

input0:
IF fond = blanc THEN COLOR noir, blanc

IF ii <= 0 THEN ii = 1
DO
re$(ii) = INKEY$
LOOP WHILE re$(ii) = ""

IF ASC(re$(ii)) = 27 THEN
IF prog = 8 OR prog = 21 OR prog = 18 THEN '===
CALL quitter(fond)
IF prog = 21 OR prog = 18 THEN LOCATE 22 '=== heures & coordonnées ni = 2
ELSE
CALL quitter(fond) '===
END IF
xx = 1: EXIT FOR
END IF

IF LEN(re$(ii)) = 2 THEN z2 = ASC(RIGHT$(re$(ii), 1)): IF ii > 1 AND (z2 = 75 OR z2 = 83 OR z2 = 15) THEN PRINT CHR$(29); " "; CHR$(29); : ii = ii - 1: z2 = 0: GOTO input0 ELSE GOTO input0

IF re$(ii) = "+" AND prog = 1 THEN EXIT FOR 'pour décomposition ===

IF ASC(re$(ii)) = 13 THEN EXIT FOR

IF ii > 1 AND ASC(re$(ii)) = 8 THEN PRINT CHR$(29); " "; CHR$(29); : ii = ii - 1: GOTO input0 ELSE IF ASC(re$(ii)) = 8 THEN GOTO input0

IF ASC(re$(ii)) < deb OR ASC(re$(ii)) > fin THEN
IF deb = 48 THEN
IF prog = 21 OR prog = 18 THEN 'coord et heures
CALL chiffres(fond)
LOCATE 22
ELSE
CALL chiffres(fond)
END IF
ELSE
IF prog = 21 THEN 'coord
CALL lettres(fond)
LOCATE 22
ELSE
CALL lettres(fond)
END IF
END IF
xx = 1: EXIT FOR
END IF

IF ii = nl + 1 THEN BEEP: GOTO input0

PRINT re$(ii);

NEXT ii

PRINT

r$ = "": FOR JJ = 1 TO ii - 1: r$ = r$ + re$(JJ): NEXT
r$ = LTRIM$(r$): r$ = RTRIM$(r$)
IF r$ = "" OR LEN(r$) = 1 THEN GOTO inp3
'épure espace
l = LEN(r$)
ik = 1
DO
IF ASC(MID$(r$, ik, 1)) = 32 THEN
IF ASC(MID$(r$, ik + 1, 1)) = 32 THEN
r$ = MID$(r$, 1, ik) + MID$(r$, ik + 2): l = l - 1: ik = ik - 1
END IF
END IF
ik = ik + 1
LOOP WHILE ik <> l

'guillemet
z = INSTR(1, r$, " '")
IF z <> 0 THEN
r$ = MID$(r$, 1, z - 1) + "'" + MID$(r$, z + 2)
END IF
z = INSTR(1, r$, "' ")
IF z <> 0 THEN
r$ = MID$(r$, 1, z - 1) + "'" + MID$(r$, z + 2)
END IF

inp3:
r$ = LCASE$(r$)
IF fin% = 125 AND r$ = "" AND xx <> 1 THEN LOCATE , , 0: EXIT SUB
IF r$ = "" OR xx = 1 THEN
IF xx = 1 THEN xx = 1 ELSE BEEP
LOCATE ligne, col, 1: GOTO inpdebut
END IF
LOCATE , , 0
END SUB

DEFINT A-Z
SUB lettres (fond)
'31/5/95
DIM c(80), x$(80)
f = 0
'on mémorise la zone quitter
LOCATE 23, 1, 0
COLOR rougeclair, noir
FOR i = 1 TO 80
x$(i) = CHR$(SCREEN(23, i))
c(i) = SCREEN(23, i, 1): IF c(i) > 15 THEN f = 1 'erreur à cause du fond
NEXT

LOCATE 23, 1: PRINT SPACE$(80)

DEF SEG = 0: POKE 1050, PEEK(1052): DEF SEG
BEEP

CALL centre(23, rougeclair, "Des lettres !")

CALL attendre(1)

'on restitue la zone quitter
LOCATE 23, 1
FOR i = 1 TO 80
IF f = 0 THEN
COLOR c(i)
END IF
PRINT x$(i);
NEXT
PRINT
COLOR , fond
END SUB

DEFINT A-Z
SUB ligne23 (x, y)
COLOR , x
LOCATE 23, 1, 0: PRINT SPACE$(80): LOCATE 23
COLOR , y
END SUB

DEFINT A-Z
SUB niv (limit, xx)
COLOR noir, vert
LOCATE 21, 2: PRINT " Niveau"; ni
LOCATE 21, 76: PRINT " "
IF limit + 1 - xx > 9 THEN LOCATE 21, 76 ELSE LOCATE 21, 77
PRINT limit + 1 - xx
COLOR blancbrill, bleu

END SUB

DEFINT A-Z
SUB Niveau (ni, np)
DIM p$(4)
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE &H417, (PEEK(&H417) AND &HBF) 'minus
DEF SEG

CALL titre(titr$)
CALL cadre(7, 25, 30, 2, vert)
COLOR , vert
CALL centre(8, blancbrill, "Niveau de difficulté")
p$(1) = "1": p$(2) = "2": p$(3) = "3": p$(4) = "4"
CALL fleches(13, 80 / 2, p$(), np, ni, 1, 23, 35)
END SUB

DEFINT A-Z
SUB ouinon (r$)
h = POS(0)
v = CSRLIN

DIM regs AS RegType
regs.ax = &HF00
INTERRUPT &H10, regs, regs ' &H10 renvoie informations
' sur vidéo.
sWidth = (regs.ax AND &HFF00) \ 256 ' Octet fort de AX (AH).
sMode = regs.ax AND &HFF ' Octet faible de AX (AL).

SELECT CASE sMode ' Fait correspondre numéros
CASE 3 ' de mode vidéo MS-DOS et
sMode = 0 ' modes affichage Basic.
CASE 16
sMode = 9
MouseInit
END SELECT

MouseShow
LOCATE v, h
COLOR blanc: PRINT "["; : COLOR jaune: PRINT "O"; : COLOR blanc: PRINT "]ui ou ["; : COLOR jaune: PRINT "N"; : COLOR blanc: PRINT "]on ?"

DO
r$ = ""
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF sMode = 9 THEN
'matrice 14 x 8 = transforme en coord écran
v_mouse = INT(v_mouse / 14) + 1
h_mouse = INT(h_mouse / 8) + 1
END IF
IF lButton THEN
IF v_mouse = v AND (h_mouse >= h AND h_mouse <= h + 5) THEN
r$ = "o"
CALL attendre(.3)
ELSEIF v_mouse = v AND (h_mouse >= h + 10 AND h_mouse <= h + 14) THEN
r$ = "n"
CALL attendre(.3)
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

r$ = UCASE$(r$)
LOOP UNTIL r$ = "O" OR r$ = "N" OR r$ = CHR$(27) OR r$ = CHR$(13)

END SUB

DEFINT A-Z
SUB place (v, h, p$, c)
COLOR c
LOCATE v, h: PRINT p$

END SUB

DEFINT A-Z
SUB quitter (fond)
'31/5/95
DIM c(80), x$(80)
MouseHide
f = 0
'on mémorise la zone quitter
LOCATE 23, 1, 0
COLOR blanc, noir
FOR i = 1 TO 80
x$(i) = CHR$(SCREEN(23, i))
c(i) = SCREEN(23, i, 1): IF c(i) > 15 THEN f = 1 'erreur à cause du fond
NEXT

LOCATE 23, 1: PRINT SPACE$(80)

LOCATE 23, (80 / 2) + 1 - 13
BEEP: PRINT "Quitter ";
CALL ouinon(r$)
IF r$ = "O" THEN SCREEN 0: COLOR , 0: CLS : RUN "exo_ma1" '===

'on restitue la zone quitter
LOCATE 23, 1
FOR i = 1 TO 80
IF f = 0 THEN
COLOR c(i)
END IF
PRINT x$(i);
NEXT
PRINT
COLOR 15, fond
END SUB

DEFINT A-Z
SUB resultats (re, ni, nbniv)

tit$ = titr$
titr$ = "Résultats"
CALL titre(titr$)
MouseInit
MouseShow

w! = LEN(tit$) / 2
IF w! = INT(LEN(tit$) / 2) THEN n = 4 ELSE n = 2
CALL cadre(5, 38 - INT(LEN(tit$) / 2), INT(LEN(tit$)) + n, 2, blanc)
COLOR , blanc
CALL centre(6, noir, tit$)
COLOR , bleu

IF re > 8 THEN
cc = vertclair: z$ = "Acquis"
ELSEIF re > 4 AND re < 9 THEN
cc = jaune: z$ = "En cours d'acquisition"
ELSE
cc = rougeclair: z$ = "Non acquis"
END IF

IF nbniv <> 1 THEN
s$ = " au niveau" + RTRIM$(STR$(ni))
ELSE
s$ = ""
END IF

CALL centre(10, cc, z$ + s$)
CALL cadre(12, 20, 40, 2, rouge)
LOCATE 13
i2 = 0
FOR i = 1 TO re
LOCATE , 21 + i2: PRINT "████"; '219
i2 = i2 + 4
NEXT
COLOR noir, noir
FOR i = re + 1 TO 10
LOCATE , 21 + i2: PRINT " ";
i2 = i2 + 4
NEXT
PRINT
COLOR , bleu
CALL centre(16, 15, "Pourcentage de réussite :" + STR$(re * 10) + " %")
CALL centre(18, 15, "(" + LTRIM$(STR$(re)) + " sur 10)")

END SUB

DEFINT A-Z
SUB solution (sol$)
BEEP
COLOR , noir
CALL centre(23, rougeclair, "Solution : " + LTRIM$(sol$))
COLOR blancbrill
CALL attendre(2)
CALL ligne23(noir, noir)
END SUB

DEFINT A-Z
SUB tableauexo (p$())
'tableau des exercices
CALL cadre(5, 2, 75, 16, rouge)
COLOR , bleu
LOCATE 22, 3: PRINT "["; : COLOR jaune: PRINT "Echap"; : COLOR blancbrill: PRINT "] = Fin"
CALL centre(22, blanc, gg2$)
IF eleve <> 0 THEN
COLOR blancbrill
LOCATE 22, 68: PRINT "["; : COLOR jaune: PRINT "*"; : COLOR blancbrill: PRINT "] = Bilan"
END IF


l3$ = SPACE$(24) + "│" + SPACE$(25) + "│" + SPACE$(23)
l4$ = STRING$(24, "─") + "┼" + STRING$(25, "─") + "┼" + STRING$(23, "─")
l5$ = STRING$(24, "─") + "┬" + STRING$(25, "─") + "┬" + STRING$(23, "─")
l6$ = STRING$(24, "─") + "┴" + STRING$(25, "─") + "┴" + STRING$(23, "─")

COLOR blanc, rouge
LOCATE 6
LOCATE , 3: PRINT l5$
'LOCATE , 3: PRINT l3$
FOR i = 1 TO 6
LOCATE , 3: PRINT l3$
LOCATE , 3: PRINT l4$
NEXT
LOCATE , 3: PRINT l3$
LOCATE , 3: PRINT l6$

'affiche liste exo
h1 = 6: h2 = 32: h3 = 58
COLOR blancbrill
LOCATE 7
FOR i = 1 TO 7
LOCATE , h1: PRINT p$(i): PRINT
NEXT
LOCATE 7
FOR i = 8 TO 14
LOCATE , h2: PRINT p$(i): PRINT
NEXT
LOCATE 7
FOR i = 15 TO 21
LOCATE , h3: PRINT p$(i): PRINT
NEXT


END SUB

DEFINT A-Z
SUB titre (titr$)
COLOR , noir, noir: CLS
MouseShow
LOCATE 2
COLOR , vert: PRINT SPACE$(80)
CALL centre(2, noir, titr$)
LOCATE 21, 1: PRINT SPACE$(80)
VIEW PRINT 3 TO 20: COLOR blancbrill, bleu: CLS 2: VIEW PRINT

END SUB

DEFINT A-Z
SUB titre2 (titr$)

COLOR , noir: CLS
LINE (0, 14)-(640, 27), vert, BF
CALL centre(2, jaune, " " + titr$ + " ")
LINE (0, 28)-(639, 279), bleu, BF
LINE (0, 279)-(640, 292), vert, BF
COLOR blancbrill

END SUB

DEFINT A-Z
SUB tri (n$(), no)
FOR i = 1 TO no - 1
M = 0
FOR j = 1 TO no - i
IF n$(j + 1) < n$(j) THEN SWAP n$(j), n$(j + 1)
M = 1
NEXT j
IF M = 0 THEN EXIT FOR
NEXT i

END SUB

DEFINT A-Z
SUB trouvemot (M$, M$(), nm)

JL = 1: MM$ = "": M$ = M$ + " "
FOR il = 1 TO LEN(M$)
MM$ = MM$ + MID$(M$, il, 1)
IF ASC(MID$(M$, il, 1)) = 32 THEN M$(JL) = MID$(MM$, 1, LEN(MM$) - 1): MM$ = "": JL = JL + 1: IF LEN(M$(JL - 1)) = 0 THEN JL = JL - 1
NEXT
nm = JL - 1

END SUB
 

  

DECLARE SUB niv (limit%, xx%)
DECLARE SUB avantapresniv1 (re%, ni%, rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB attendre (tx!)
DECLARE SUB chiffres (fond%)
DECLARE SUB entree (x%, y%)
DECLARE SUB erreur2 (tx!)
DECLARE SUB exact2 (tx!)
DECLARE SUB fleches (v%, h%, w$(), np%, r%, drap%, v2%, h2%)
DECLARE SUB fleches2 (v%, h%, ll%, nm%, h2%, w$(), r%, coul%)
DECLARE SUB inputgen (nl%, r$, deb%, fin%, fond%)
DECLARE SUB ligne23 (x%, y%)
DECLARE SUB Niveau (ni%, np%)
DECLARE SUB quitter (fond%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB solution (sol$)
DECLARE SUB titre (titr$)
DECLARE SUB trouvemot (M$, M$(), nm%)
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB cadre1 (v%, h%, l%, nli%, c%, c2%, c3%)
DECLARE SUB centre (v%, cc%, ph$)
DECLARE SUB consigne (nl%, w$, z$, y$)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB soustract (re%, ni%, rt$, gg$, titr$, pre$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB MouseHide ()
DECLARE SUB MousePoll (row%, col%, lButton%, rButton%)
'Exercices AAS MATH CE = module 2
'Daniel CLERC
'6/6/96
' Version 1.0


DEFINT A-Z
SUB addition (re, ni, rt$, gg$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'3/6/95
DIM a&(2)
ll$ = STRING$(10, 196)

principalad:
re = 0: cc = 0: f = 0
CALL Niveau(ni%, 4)
IF ni = 1 THEN c = 2
IF ni = 2 THEN c = 3
IF ni = 3 THEN c = 4
IF ni = 4 THEN c = 6

FOR no = 1 TO 5 '++++++++++++++++++++

CALL titre(titr$)
CALL niv(5, no)

IF ni <= 3 THEN
CALL cadre(7, 33, 14, 8, blanc)
ELSE
CALL cadre(7, 31, 16, 8, blanc)
END IF
COLOR noir, blanc
'operation posee
DO
s& = 0
FOR i = 1 TO 2
DO
a&(i) = INT(RND * (10 ^ c))
LOOP WHILE a&(i) < 10 ^ (c - 1)
s& = s& + a&(i)
NEXT i

LOOP WHILE a&(1) < a&(2)
h = 45
s$ = LTRIM$(STR$(s&))
LOCATE 10, h - LEN(STR$(a&(1))): PRINT LTRIM$(STR$(a&(1)))
LOCATE 11, (h - 3) - LEN(s$): PRINT "+"
LOCATE 11, h - LEN(STR$(a&(2))): PRINT LTRIM$(STR$(a&(2)))

lli$ = MID$(ll$, 1, LEN(s$) + 2)
LOCATE 12, (h - 3) - LEN(s$): PRINT lli$

'boucle comparaison
zz = 0
FOR k = LEN(s$) TO 1 STEP -1
a = VAL(MID$(STR$(a&(1)), LEN(STR$(a&(1))) - zz, 1)) + VAL(MID$(STR$(a&(2)), LEN(STR$(a&(2))) - zz, 1))
IF a > 9 THEN
ret = 1
ELSEIF a = 9 AND ret = 1 THEN
ret = 1
ELSE
ret = 0
END IF

ad1:
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG
COLOR , noir
CALL centre(23, blanc, "Tape la réponse")
COLOR noir, blanc
LOCATE 10 + i, ((h - 2) - LEN(s$)) + k, 1: PRINT "_"
LOCATE 10 + i, ((h - 2) - LEN(s$)) + k, 1
x$ = INPUT$(1)
IF ASC(x$) = 27 THEN CALL quitter(blanc): GOTO ad1
IF ASC(x$) < 48 OR ASC(x$) > 57 THEN CALL chiffres(blanc): GOTO ad1
x = VAL(x$): PRINT x$
q = VAL(MID$(s$, k, 1))
CALL ligne23(noir, noir)
LOCATE 23, 18
IF x = q THEN
CALL exact2(.7)
ELSE
cc = cc + 1
IF cc >= 2 THEN
CALL solution(STR$(q))
COLOR noir, blanc
ELSE
CALL erreur2(.7)
END IF
GOTO ad1
END IF
'retenue
IF ret = 1 THEN
ad2:
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG
COLOR blanc, noir
CALL centre(23, blanc, "Tape la retenue")
COLOR noir, blanc
LOCATE 9, (h - 3) - zz, 1: PRINT "_"
LOCATE 9, (h - 3) - zz, 1
r$ = INPUT$(1)
IF ASC(r$) = 27 THEN CALL quitter(blanc): GOTO ad2
IF ASC(r$) < 48 OR ASC(r$) > 57 THEN CALL chiffres(blanc): GOTO ad2
r = VAL(r$): PRINT r$
IF r <> 1 THEN
cc = cc + 1
BEEP: LOCATE , , 0: COLOR rougeclair, noir
CALL centre(23, rougeclair, " Retenue = 1 ")
CALL attendre(1): CALL ligne23(noir, blanc)
GOTO ad2
END IF
COLOR blancbrill, noir: CALL ligne23(noir, blanc)
END IF
zz = zz + 1
NEXT k

'resultats
COLOR , noir
IF cc = 0 THEN
re = re + 2
COLOR jaune
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
z$ = "Tu as fait " + LTRIM$(STR$(cc)) + " erreur": IF cc > 1 THEN z$ = z$ + "s."
CALL centre(23, rougeclair, z$)
IF cc > 3 AND ni > 1 THEN
CALL attendre(2)
BEEP
CALL centre(23, rougeclair, "Tu vas changer de niveau.")
CALL getinvimouse(w)
f = 1: EXIT FOR
END IF
END IF
cc = 0

CALL getinvimouse(w)

NEXT no '+++++++++++++++++++++
IF f = 1 THEN GOTO principalad
CALL resultats(re, ni, 4)

END SUB

DEFINT A-Z
SUB avantapres (re, ni, rt$, gg$, pre$, titr$, prog, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'31/5/95
DIM place(6), z(6), n(6)
place(1) = 8: place(2) = 18: place(3) = 28: place(4) = 48: place(5) = 58: place(6) = 68
w$ = "Un nombre va être affiché."
z$ = "Tu taperas ceux qui viennent avant et après."
CALL consigne(2, w$, z$, y$)

debutap:
CALL Niveau(ni, 3)
IF ni = 1 THEN
CALL avantapresniv1(re, ni, rt$, gg$, pre$, titr$, prog, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
EXIT SUB
END IF

c = 0: f = 0: sc = 0: er = 0

CALL titre(titr$)

'+++++++++++++++++++++
FOR ke = 1 TO 3
coul = blanc
CALL niv(3, ke)

'tirage
SELECT CASE ni
CASE 2

DO
f = 0
n(ke) = INT(RND * 95) + 1
FOR j = 1 TO ke - 1
IF n(ke) = n(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1 OR n(ke) < 10
n = n(ke)

CASE 3
DO
f = 0
n(ke) = INT(RND * 995) + 1
FOR j = 1 TO ke - 1
IF n(ke) = n(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1 OR n(ke) < 100
n = n(ke)

END SELECT


FOR i = 1 TO 6
CALL cadre(10, place(i) - 1, 3, 4, coul)
NEXT

CALL cadre(10, 38, 3, 4, coul)
LOCATE 12, 39: COLOR noir, coul: PRINT LTRIM$(STR$(n))

FOR boucle = 1 TO 6
SELECT CASE ni
CASE 2
IF boucle = 1 THEN
nombre = 4
ELSEIF boucle = 2 THEN
nombre = 5
ELSEIF boucle = 3 THEN
nombre = 6
ELSEIF boucle = 4 THEN
nombre = 3
ELSEIF boucle = 5 THEN
nombre = 2
ELSE
nombre = 1
END IF

CASE 3
GOSUB tirageap

END SELECT
coul = vert
CALL cadre(10, place(nombre) - 1, 3, 4, coul)

moi1:
COLOR blanc, noir
IF nombre = 1 OR nombre = 2 OR nombre = 3 THEN
CALL centre(23, blanc, "Tape le nombre qui vient avant")
ELSE
CALL centre(23, blanc, "Tape le nombre qui vient après")
END IF
COLOR noir, coul
LOCATE 12, place(nombre)
IF ni = 2 THEN nl = 2 ELSE nl = 3
PRINT MID$("...", 1, nl)
LOCATE 12, place(nombre)

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(nl, r$, 48, 57, coul)


CALL ligne23(noir, noir)
z = VAL(r$)
SELECT CASE nombre
CASE 1
sol = n - 3
CASE 2
sol = n - 2
CASE 3
sol = n - 1
CASE 4
sol = n + 1
CASE 5
sol = n + 2
CASE 6
sol = n + 3

END SELECT

IF z = sol THEN
CALL exact2(.7)
coul = vert
CALL cadre(10, place(nombre) - 1, 3, 4, coul)
ELSE
GOSUB moisol
GOTO moi1
END IF
er = 0
NEXT boucle

FOR nombre = 1 TO 6
COLOR noir, vert
LOCATE 12, place(nombre)

SELECT CASE nombre
CASE 1
PRINT LTRIM$(STR$(n - 3))
CASE 2
PRINT LTRIM$(STR$(n - 2))
CASE 3
PRINT LTRIM$(STR$(n - 1))
CASE 4
PRINT LTRIM$(STR$(n + 1))
CASE 5
PRINT LTRIM$(STR$(n + 2))
CASE 6
PRINT LTRIM$(STR$(n + 3))

END SELECT

NEXT
LOCATE 23
COLOR blanc, noir
IF sc <> 0 THEN
w$ = "Tu as fait " + RTRIM$(LTRIM$(STR$(sc))) + " erreur": IF sc > 1 THEN w$ = w$ + "s"
w$ = w$ + "."
CALL centre(23, rougeclair, w$)
CALL getinvimouse(w)
IF sc > 3 AND ni > 1 THEN CALL centre(23, rougeclair, "Tu vas changer de niveau."): CALL getinvimouse(w): f = 1: EXIT FOR
ELSE
CALL entree(noir, noir)
END IF
sc = 0
LOCATE 23, 1: PRINT SPACE$(80)
NEXT ke

IF f = 1 THEN GOTO debutap

re = 10 - c: IF re < 0 THEN re = 0
CALL resultats(re, ni, 3)

EXIT SUB

moisol:
sc = sc + 1: er = er + 1: IF er = 1 THEN c = c + 1
COLOR , noir
IF er = 1 THEN
CALL erreur2(.7)
ELSEIF er = 2 THEN
LOCATE 23, 36
COLOR rougeclair
SELECT CASE nombre
CASE 1
PRINT "? ="; n; "- 3"
CASE 2
PRINT "? ="; n; "- 2"
CASE 3
PRINT "? ="; n; "- 1"
CASE 4
PRINT "? ="; n; "+ 1"
CASE 5
PRINT "? ="; n; "+ 2"
CASE 4
PRINT "? ="; n; "+ 3"

END SELECT
CALL attendre(3)
ELSE
CALL solution(STR$(sol))
END IF
CALL cadre(10, place(nombre) - 1, 3, 4, rouge)
coul = rouge
RETURN

tirageap:
DO
f = 0
z(boucle) = INT(RND * 6) + 1
FOR j = 1 TO boucle - 1
IF z(boucle) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
nombre = z(boucle)

RETURN

END SUB

DEFINT A-Z
SUB avantapresniv1 (re, ni, rt$, gg$, pre$, titr$, prog, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'niveau 1
DIM place(4), z(4), n(4)
ni = 1
place(1) = 18: place(2) = 28: place(3) = 48: place(4) = 58
c = 0: f = 0: sc = 0: er = 0

debutapniv1:

CALL titre(titr$)

'+++++++++++++++++++++
FOR ke = 1 TO 3
CALL niv(3, ke)
coul = blanc

'tirage
DO
f = 0
n(ke) = INT(RND * 95) + 1
FOR j = 1 TO ke - 1
IF n(ke) = n(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1 OR n(ke) < 10
n = n(ke)

FOR i = 1 TO 4
CALL cadre(10, place(i) - 1, 3, 4, coul)
NEXT
CALL cadre(10, 38, 3, 4, coul)
LOCATE 12, 39: COLOR noir, coul: PRINT LTRIM$(STR$(n))

FOR boucle = 1 TO 4
IF boucle = 1 THEN
nombre = 3
ELSEIF boucle = 2 THEN
nombre = 4
ELSEIF boucle = 3 THEN
nombre = 2
ELSE
nombre = 1
END IF

coul = vert
CALL cadre(10, place(nombre) - 1, 3, 4, coul)

moiniv1:
COLOR blanc, noir
IF nombre = 1 OR nombre = 2 THEN
CALL centre(23, blanc, "Tape le nombre qui vient avant")
ELSE
CALL centre(23, blanc, "Tape le nombre qui vient après")
END IF
COLOR noir, coul
LOCATE 12, place(nombre)
nl = 2
PRINT MID$("...", 1, nl)
LOCATE 12, place(nombre)

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(nl, r$, 48, 57, coul)

CALL ligne23(noir, noir)
z = VAL(r$)
SELECT CASE nombre
CASE 1
sol = n - 2
CASE 2
sol = n - 1
CASE 3
sol = n + 1
CASE 4
sol = n + 2
END SELECT

IF z = sol THEN
CALL exact2(.7)
coul = vert
CALL cadre(10, place(nombre) - 1, 3, 4, coul)
ELSE
GOSUB moisolniv1
GOTO moiniv1
END IF
er = 0
NEXT boucle

FOR nombre = 1 TO 4
COLOR noir, vert
LOCATE 12, place(nombre)
SELECT CASE nombre
CASE 1
PRINT LTRIM$(STR$(n - 2))
CASE 2
PRINT LTRIM$(STR$(n - 1))
CASE 3
PRINT LTRIM$(STR$(n + 1))
CASE 4
PRINT LTRIM$(STR$(n + 2))
END SELECT

NEXT
LOCATE 23
COLOR blanc, noir
IF sc <> 0 THEN
w$ = "Tu as fait " + RTRIM$(LTRIM$(STR$(sc))) + " erreur": IF sc > 1 THEN w$ = w$ + "s"
w$ = w$ + "."
CALL centre(23, rougeclair, w$)
CALL getinvimouse(w)
ELSE
CALL entree(noir, noir)
END IF
sc = 0
LOCATE 23, 1: PRINT SPACE$(80)
NEXT ke

IF f = 1 THEN GOTO debutapniv1

re = 10 - c: IF re < 0 THEN re = 0
CALL resultats(re, ni, 3)

EXIT SUB

moisolniv1:
sc = sc + 1: er = er + 1: IF er = 1 THEN c = c + 1
COLOR , noir
IF er = 1 THEN
CALL erreur2(.7)
ELSEIF er = 2 THEN
LOCATE 23, 36
COLOR rougeclair
SELECT CASE nombre
CASE 1
PRINT "? ="; n; "- 2"
CASE 2
PRINT "? ="; n; "- 1"
CASE 3
PRINT "? ="; n; "+ 1"
CASE 4
PRINT "? ="; n; "+ 2"
END SELECT
CALL attendre(3)
ELSE
CALL solution(STR$(sol))
END IF
CALL cadre(10, place(nombre) - 1, 3, 4, rouge)
coul = rouge
RETURN

END SUB

DEFINT A-Z
SUB classernombres (re, ni, rt$, pre$, gg$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'27/1/96
DIM ph$(2), p$(2), n(5), r%(5), re$(6)
ph$(1) = "Du plus petit vers le plus grand"
ph$(2) = "Du plus grand vers le plus petit"

'presentation
w$ = "Tu vas classer 5 nombres."
CALL consigne(1, w$, z$, y$)

'niveau
CALL Niveau(ni, 3)
SELECT CASE ni
CASE 1
limit = 60
CASE 2
limit = 500
CASE 3
limit = 9999
END SELECT

FOR ne = 1 TO 2 '+++++++++++++
IF ne = 1 THEN d = 1: f = 5: s = 1 ELSE d = 5: f = 1: s = -1

CALL titre(titr$)

CALL cadre(9, 20, 40, 4, marron)
COLOR , marron
CALL centre(11, blancbrill, ph$(ne))
CALL attendre(1.5)

CALL titre(titr$)
CALL niv(2, ne)

FOR i = 1 TO 5

cla0:

n(i) = (RND * limit) + 1

n = n(i)
r%(i) = i
flag = 0
FOR l = 1 TO i - 1
IF n = n(l) THEN flag = 1: EXIT FOR
NEXT l
IF flag = 1 THEN GOTO cla0
NEXT i

'affichage
CALL cadre(4, 22, 36, 2, marron)
COLOR , marron
CALL centre(5, blancbrill, ph$(ne))

CALL cadre(8, 22, 12, 10, rouge)
COLOR blancbrill, rouge
LOCATE 9
IF ni = 1 THEN h = 31 ELSE h = 32
FOR i = 1 TO 5
LOCATE , h - LEN(LTRIM$(STR$(n(i)))): PRINT n(i): PRINT
NEXT

'tri
FOR i = 1 TO 4
flag = 0
FOR j = 1 TO 5 - i
IF n(j + 1) < n(j) THEN SWAP n(j), n(j + 1): SWAP r%(j), r%(j + 1)
flag = 1
NEXT j
IF flag = 0 THEN EXIT FOR
NEXT i

v = 9

CALL cadre(8, 45, 12, 10, blanc)
LOCATE v: COLOR noir, blanc
FOR j = d TO f STEP s
LOCATE , 46: PRINT j; CHR$(16): PRINT
NEXT

FOR ii = d TO f STEP s
cla3:
COLOR blanc, noir: CALL centre(23, blanc, "Tape le nombre n°" + LTRIM$(STR$(ii)))
COLOR noir, blanc

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

LOCATE v, 51
nl = 5: GOSUB inpute3

rep = VAL(r$)
'test si nombre dans liste
flag = 0
FOR x = 1 TO 5
IF n(x) <> rep THEN flag = flag + 1
NEXT
CALL ligne23(noir, noir)
IF flag = 5 THEN
COLOR rougeclair, noir: CALL centre(23, rougeclair, "Ce nombre n'est pas dans la liste.")
CALL attendre(1)
CALL ligne23(noir, bleu)
GOTO cla3
END IF

IF rep <> n(ii) THEN
COLOR rougeclair, noir
cc = cc + 1
IF cc >= 2 THEN
BEEP
CALL centre(23, rougeclair, "Solution :" + STR$(n(ii)))
CALL attendre(2)
ELSE
CALL centre(23, rougeclair, "Erreur")
CALL attendre(1)
END IF
GOTO cla3
ELSE
COLOR jaune, noir: CALL centre(23, jaune, "Exact")
CALL attendre(.7)
LOCATE ((r%(ii) - 1) * 2) + 9, 27
IF cc = 0 THEN COLOR vertclair ELSE COLOR rougeclair
COLOR , rouge
PRINT CHR$(4): COLOR blancbrill
IF cc = 0 THEN pt = pt + 1
cc = 0
END IF
CALL ligne23(noir, bleu)

v = v + 2
NEXT ii

CALL entree(noir, noir)

NEXT ne '++++++++++++++++++++=

re = pt
CALL resultats(re, ni, 3)

EXIT SUB

inpute3:
COLOR noir, blanc
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
ligne = CSRLIN
colon = POS(0)
LOCATE ligne, colon: PRINT " "
LOCATE ligne, colon, 1 ' ,0,7

FOR kk = 1 TO nl + 1
inp5:
IF kk <= 0 THEN kk = 1
inp6:
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
w$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
'LOCATE 22, 1: PRINT v_mouse, h_mouse'===
IF lButton AND kk > 1 THEN
BEEP
ELSEIF lButton THEN
'ligne fleches et entree
IF v_mouse >= 9 AND v_mouse <= 17 THEN
IF h_mouse >= 29 AND h_mouse <= 32 THEN
sc = SCREEN(v_mouse, h_mouse)
IF sc = 32 OR sc = 219 THEN
BEEP
ELSE
LOCATE , , 0
'on cherche les lettres à gauche jusqu'à espace ou h1=1
h1 = h_mouse
DO
sc = SCREEN(v_mouse, h1)
IF sc = 32 OR sc = 219 THEN EXIT DO
h1 = h1 - 1
LOOP WHILE h1 <> 0
h1 = h1 + 1
h2 = h1: mot$ = ""
DO
sc = SCREEN(v_mouse, h2)
IF sc = 32 OR sc = 219 THEN EXIT DO
mot$ = mot$ + CHR$(sc)
h2 = h2 + 1
LOOP WHILE h2 <> 81
mot$ = RTRIM$(LTRIM$(mot$))
LOCATE v_mouse, h1
COLOR rouge, blanc
PRINT mot$
CALL attendre(.3)
LOCATE v_mouse, h1
COLOR blancbrill, rouge
PRINT mot$
r$ = mot$
souris = 2
EXIT DO
END IF
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE w$ = ""

IF souris = 2 THEN
COLOR noir, blanc
LOCATE v, 51: PRINT r$
RETURN
END IF

IF souris = 0 THEN
IF LEN(w$) < 2 THEN rr = ASC(w$) ELSE rr = ASC(RIGHT$(w$, 1))
END IF

re$(kk) = CHR$(rr)


IF rr = 27 THEN
CALL quitter(blanc)
LOCATE v, 51, 1
GOTO inpute3
END IF

IF rr = 13 THEN
EXIT FOR
END IF

IF kk > 1 AND (rr = 8 OR rr = gauche OR rr = 83) THEN
PRINT CHR$(29); " "; CHR$(29);
kk = kk - 1
GOTO inp5
END IF

IF rr < 48 OR rr > 57 THEN
CALL chiffres(blanc)
LOCATE v, 51, 1
GOTO inpute3
END IF

IF kk = nl + 1 THEN BEEP: GOTO inp6

PRINT re$(kk);
NEXT kk

PRINT : LOCATE , , 0
r$ = "": FOR jj = 1 TO kk - 1: r$ = r$ + re$(jj): NEXT
r$ = LTRIM$(r$): r$ = RTRIM$(r$)
IF r$ = "" THEN LOCATE v, 51, 1: GOTO inpute3
COLOR , noir
RETURN


END SUB

DEFINT A-Z
SUB decompo (re, ni, rt$, gg2$, pre$, titr$, prog, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
DIM a(15), b(15), re$(4), p$(10), z(5)
'8/12/96
c = 0
'présentation

CALL titre(titr$)
COLOR , noir
CALL centre(23, jaune, "Mémorise")
CALL cadre(4, 4, 72, 15, rouge)
COLOR blancbrill, rouge

h = 8
FOR ii = 1 TO 4
DO
f = 0
z(ii) = INT(RND * 7) + 5
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
n = z(ii)

GOSUB decompo1
h = h + 18
NEXT ii

CALL getinvimouse(w)

'niveau

CALL titre(titr$)
CALL cadre(6, 25, 30, 2, vert)
COLOR , vert
CALL centre(7, blancbrill, "Nombre à décomposer")
COLOR blanc, bleu
j = 1: FOR i = 5 TO 9: p$(j) = STR$(i): j = j + 1: NEXT
FOR i = 10 TO 14: p$(j) = LTRIM$(STR$(i)): j = j + 1: NEXT
LOCATE 10, 29: PRINT "Niveau 1"
LOCATE 10, 44: PRINT "Niveau 2"
CALL cadre(12, 30, 4, 6, rouge)
CALL cadre(12, 45, 4, 6, rouge)
COLOR , noir
CALL centre(23, blanc, gg2$)
COLOR blancbrill, rouge
CALL fleches2(13, 32, 5, 10, 47, p$(), r, rouge)

n = r + 4
ni = 1
IF n > 9 THEN ni = 2
l = LEN(LTRIM$(STR$(n)))

CALL titre(titr$)
h = 36
SELECT CASE n
CASE 5, 6, 7, 8, 9
v = 7
CALL cadre(v - 2, h - 5, 18, n + 4, blanc)
CASE 10, 11, 12
v = 6
CALL cadre(v - 2, h - 5, 19, n + 3, blanc)
CASE 13, 14
v = 5
CALL cadre(v - 2, h - 5, 19, n + 3, blanc)
END SELECT

COLOR noir, blanc
LOCATE v, h
PRINT LTRIM$(STR$(n)); " = 0 + "; LTRIM$(STR$(n))
a(0) = 0: b(0) = n

'prog. princ +++++++++++++++++++++++
FOR i = 1 TO n
CALL niv(n, i)
de1:

COLOR blanc, noir: CALL centre(23, blanc, "Tape un nombre")
COLOR noir, blanc

f = 0
LOCATE i + v, h: PRINT SPACE$(11)
LOCATE i + v, h: PRINT LTRIM$(STR$(n)); : PRINT " = ";

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(2, r$, 48, 57, blanc)
a = VAL(r$)

LOCATE i + v, h + 5 + l
PRINT "+ ";

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(2, r$, 48, 57, blanc)
b = VAL(r$)

COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
LOCATE 23, 18

FOR j = 0 TO i
IF a(j) = a AND b(j) = b THEN
BEEP: COLOR rougeclair: CALL centre(23, rougeclair, "Déjà proposé")
f = 1: CALL attendre(1)
EXIT FOR
END IF
NEXT

IF f = 1 THEN GOTO de1

IF a + b = n THEN
CALL exact2(.7)
ELSE
CALL erreur2(.7): f = 1: c = c + 1
COLOR rougeclair
CALL centre(23, rougeclair, LTRIM$(STR$(a)) + " + " + LTRIM$(STR$(b) + " = " + LTRIM$(STR$(a + b))))
CALL getinvimouse(w)
END IF

IF f = 1 THEN GOTO de1
a(i) = a: b(i) = b
NEXT
CALL ligne23(noir, noir)
CALL entree(noir, noir)

FOR i = 1 TO 13
a(i) = 0: b(i) = 0
NEXT

re = 10 - c: IF re < 0 THEN re = 0

CALL resultats(re, ni, 2)

EXIT SUB

decompo1:
LOCATE 6
n$ = LTRIM$(STR$(n)): l = LEN(n$)
FOR i = 0 TO n
i$ = LTRIM$(STR$(i))
LOCATE , h: PRINT n$; " = "; : IF i < 10 AND n > 9 THEN PRINT " "; i$; ELSE PRINT i$;
LOCATE , (l * 2) + h + 4: PRINT "+ "; LTRIM$(STR$(n - i))
NEXT

RETURN
END SUB

DEFDBL A-Z
SUB lettre (re%, ni%, un$(), di$(), ex$(), ch$(), mot$(), rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'31/5/95
DIM p(2), TR$(20), re$(120), z(10), nb(18), nb$(18), M$(50), M2$(50), m3$(50), m4$(50)

z$ = "0000000000"
s$ = "xxxxxx"
ct% = 0
CALL Niveau(ni%, 3)
IF ni% = 1 THEN ti% = 1
IF ni% = 2 THEN ti% = 19
IF ni% = 3 THEN ti% = 37

j% = 1
FOR i% = ti% TO ti% + 17
nb(j%) = VAL(ch$(i%))
nb$(j%) = ch$(i%)
j% = j% + 1
NEXT

LOCATE , , 0
MouseHide
FOR ii% = 1 TO 5

COLOR , noir%, noir%: CLS
LOCATE 2
COLOR , vert%: PRINT SPACE$(80)
CALL centre(2, noir%, titr$)
LOCATE 20, 1: PRINT SPACE$(80)
VIEW PRINT 3 TO 19: COLOR blancbrill%, bleu%: CLS 2: VIEW PRINT
COLOR noir%, vert%
LOCATE 20, 2: PRINT " Niveau"; ni%
LOCATE 20, 77
PRINT 6 - ii%
COLOR blancbrill%, bleu%

c% = 0
'tirage
DO
f = 0
z(ii%) = INT(RND * 18) + 1
FOR j% = 1 TO ii% - 1
IF z(ii%) = z(j%) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
n = nb(z(ii%))
nb$ = nb$(z(ii%))
IF LEN(nb$) > 3 THEN
nb$ = LEFT$(nb$, 1) + " " + MID$(nb$, 2)
END IF

'transforme
n$ = LTRIM$(STR$(n)): n$ = LEFT$(z$, 10 - LEN(n$)) + n$: n2$ = ""
i = 0: FOR j = 1 TO 7 STEP 3
TR$(i) = MID$(n$, 9 - j, 3)
i = i + 1
NEXT
'unités simples
f = 0: TR$ = TR$(0): IF VAL(TR$) = 0 THEN GOTO let4
GOSUB letanalyse
n2$ = no$
'mille
let4:
f = 1: TR$ = TR$(1): IF VAL(TR$) = 0 THEN GOTO let5
IF VAL(TR$) = 1 THEN n2$ = "mille " + n2$: GOTO let5
GOSUB letanalyse
n2$ = no$ + "mille " + n2$
'million
let5:
TR$ = TR$(2): IF VAL(TR$) = 0 THEN GOTO let6
IF VAL(TR$) = 1 THEN n2$ = "un million " + n2$: GOTO let6
GOSUB letanalyse
n2$ = no$ + "millions " + n2$
let6:
n2$ = MID$(n2$, 1, LEN(n2$) - 1)
COLOR vertclair%, bleu%

CALL cadre(6, 37, LEN(nb$) + 2, 4, rouge%)
COLOR jaune%, rouge%
LOCATE 8, 39: PRINT nb$
COLOR , bleu%
CALL centre(13, blanc%, "Tape ce nombre en lettres")

let8:
CALL cadre(15, 4, 72, 2, blanc%)
LOCATE 16, 6
COLOR noir%, blanc%

DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE &H417, (PEEK(&H417) AND &HBF) 'minus
DEF SEG

CALL inputgen(65, r$, 32, 254, blanc%)

COLOR blancbrill%, noir%
b$ = LCASE$(r$): IF b$ = CHR$(13) OR LEN(b$) < 2 THEN GOTO let8
lo = LEN(b$)
'analyse-
'enlève les guillemets
FOR ik = 1 TO LEN(b$)
IF MID$(b$, ik, 1) = "-" THEN
b$ = MID$(b$, 1, ik - 1) + " " + MID$(b$, ik + 1)
END IF
NEXT
'enlève les espaces
ik = 1
DO
IF ASC(MID$(b$, ik, 1)) = 32 THEN
IF ASC(MID$(b$, ik + 1, 1)) = 32 THEN
b$ = MID$(b$, 1, ik) + MID$(b$, ik + 2): lo = lo - 1: ik = ik - 1
END IF
END IF
ik = ik + 1
LOOP WHILE ik <> lo

IF ASC(b$) < 65 THEN LOCATE 22, 3: COLOR , noir%: PRINT "Des lettres !"; SPACE$(80): CALL attendre(1): LOCATE 22: PRINT SPACE$(80): GOTO let8

COLOR , noir%
LOCATE 21, 1: FOR i = 1 TO 3: PRINT SPACE$(80): NEXT
LOCATE 22, 3

IF b$ <> n2$ THEN
IF c% = 0 THEN ct% = ct% + 1
c% = c% + 1

IF c% > 2 THEN
LOCATE 22, 3: COLOR rougeclair%: BEEP: PRINT "Solution : "; n2$
ELSE
LOCATE 21, 3: PRINT "Ta réponse : "; : COLOR blancbrill%: PRINT r$
COLOR rougeclair%
CALL trouvemot(b$, M$(), nm%): b$ = MID$(b$, 1, LEN(b$) - 1)
CALL trouvemot(n2$, M2$(), nm2%): n2$ = MID$(n2$, 1, LEN(n2$) - 1)
LOCATE 22, 3
IF nm% < nm2% THEN PRINT "Il manque des mots..."
IF nm% > nm2% THEN PRINT "Il y a trop de mots..."
z = 0
FOR j = 1 TO nm%
f = 0
FOR i = 1 TO 33
IF mot$(i) = M$(j) THEN f = 1: EXIT FOR
NEXT i
IF f = 0 THEN z = z + 1: m3$(z) = M$(j)
NEXT j
LOCATE 23, 3
COLOR jaune%

IF z = 0 THEN
z2 = 0
FOR i = 1 TO nm2%
IF M2$(i) <> M$(i) THEN z2 = z2 + 1: m4$(z2) = M2$(i)
NEXT
f = 0
FOR i = 1 TO nm%
IF M$(i) = "zéro" OR M$(i) = "zero" THEN f = 1
NEXT
IF f = 1 THEN COLOR rougeclair%: PRINT "Pas de zéro...": z2 = 0
IF z2 <> 0 THEN PRINT "Aide : "; : COLOR rougeclair%: FOR i = 1 TO z2: PRINT m4$(i); ", "; : NEXT: PRINT CHR$(29); CHR$(29); " "
ELSEIF z = 1 THEN
PRINT "Mot mal orthographié : "; : COLOR rougeclair%: PRINT m3$(1)
ELSE
temp$ = "": FOR i = 1 TO z: temp$ = temp$ + m3$(i) + ", ": NEXT
IF LEN(temp$) > 55 THEN
'rien
ELSE
PRINT "Mots mal orthographiés : "; : COLOR rougeclair%
FOR i = 1 TO z: PRINT m3$(i); ", "; : NEXT: PRINT CHR$(29); CHR$(29); " "
END IF
END IF

END IF
GOTO let8

END IF


LOCATE 21, 1: PRINT SPACE$(80): PRINT SPACE$(80)
LOCATE 22, 38
CALL exact2(.7)
NEXT ii%

'Résultats
re% = 10 - (ct% * 2): IF re% < 0 THEN re% = 0
CALL resultats(re%, ni%, 3)

EXIT SUB


letanalyse:
no$ = ""
FOR i = 2 TO 0 STEP -1
p(i) = VAL(MID$(TR$, 3 - i, 1))
NEXT
'centaine
IF p(2) = 0 THEN GOTO let1
IF p(2) = 1 THEN no$ = "cent ": GOTO let1
no$ = un$(p(2)) + "cent"
IF p(0) <> 0 OR p(1) <> 0 THEN GOTO let2
IF f = 0 THEN no$ = no$ + "s"
let2:
no$ = no$ + " "
let1: 'dizaine
IF p(1) = 0 THEN GOTO let3
IF p(1) = 7 AND p(0) = 1 THEN no$ = no$ + di$(p(1) - 1) + "et " + ex$(p(0)): RETURN
IF p(1) = 1 AND (p(0) > 0 AND p(0) < 7) THEN no$ = no$ + ex$(p(0)): RETURN
IF (p(1) = 7 OR p(1) = 9) AND (p(0) > 0 AND p(0) < 7) THEN no$ = no$ + di$(p(1) - 1) + ex$(p(0)): RETURN
IF p(0) = 1 AND (p(1) <> 0 AND p(1) <> 8) THEN no$ = no$ + di$(p(1)) + "et ": GOTO let3
no$ = no$ + di$(p(1))
IF f = 0 AND (p(1) = 8 AND p(0) = 0) THEN no$ = LEFT$(no$, LEN(no$) - 1) + "s "
let3: 'unités
IF p(0) = 0 THEN RETURN
no$ = no$ + un$(p(0))
RETURN

END SUB

DEFINT A-Z
SUB multiplications (re, ni, rt$, gg$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'3/12/96
ll$ = STRING$(10, 196)

princmulti:
re = 0: cc = 0: f = 0
CALL Niveau(ni, 4)

FOR no = 1 TO 5
CALL titre(titr$)
CALL niv(5, no)

'tirage
SELECT CASE ni

CASE 1
a = INT(RND * 20) + 15
b = INT(RND * 2) + 3

CASE 2
a = INT(RND * 40) + 50
b = INT(RND * 3) + 4

CASE 3
a = INT(RND * 300) + 400
b = INT(RND * 2) + 6

CASE 4
a = INT(RND * 300) + 2800
b = INT(RND * 3) + 4

END SELECT

la = LEN(LTRIM$(STR$(a)))
LB = LEN(LTRIM$(STR$(b)))
res$ = LTRIM$(STR$(b * a))

CALL cadre(7, 26, 28, b + 6, blanc)
COLOR noir, blanc
'operation posee addition
h = 37: LOCATE 10
FOR i = 1 TO b
LOCATE , h - la: PRINT LTRIM$(STR$(a))
LOCATE , h - (la + 2): PRINT "+";
NEXT i
LOCATE , h - (la + 2)
lli$ = MID$(ll$, 1, la + 2)
PRINT lli$

v = CSRLIN: v = v - 3
h = 48

'oper posee multi
LOCATE v, h - la: PRINT a
LOCATE , h - (LB + 2): PRINT "x "; b
LOCATE , (h - (la + LB))
PRINT LEFT$(ll$, la + LB + 1)

v = CSRLIN: h = 0
zz = 0: retenue = 0
'+++++++++++++++++++++++++++++++++++
FOR j = LEN(res$) TO 1 STEP -1

retenue1 = INT(((VAL(MID$(STR$(a), LEN(STR$(a)) - zz, 1)) * b) + retenue) / 10)
retenue = retenue1

IF retenue1 <> 0 THEN
ret = 1
ELSE
ret = 0
END IF

multi1:
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG
COLOR blanc, noir: CALL centre(23, blanc, "Tape la réponse")
COLOR noir, blanc
LOCATE v, 36 - h: PRINT "_"
LOCATE v, 48 - h: PRINT "_"
re$ = INPUT$(1)
IF ASC(re$) = 27 THEN CALL quitter(blanc): GOTO multi1
IF ASC(re$) < 48 OR ASC(re$) > 57 THEN CALL chiffres(blanc): GOTO multi1
LOCATE v, 36 - h: PRINT re$
LOCATE v, 48 - h: PRINT re$

CALL ligne23(noir, noir)

IF re$ <> MID$(res$, j, 1) THEN
cc = cc + 1
IF cc >= 2 THEN
CALL solution(MID$(res$, j, 1))
COLOR noir, blanc
ELSE
CALL erreur2(.7)
END IF
COLOR , blanc
GOTO multi1
ELSE
CALL exact2(.7)
END IF

'retenue
COLOR noir, blanc: LOCATE 12, 32: PRINT " "
IF ret = 1 AND la <> zz + 1 THEN

multi12:
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG
COLOR blanc, noir: CALL centre(23, blanc, "Tape la retenue")
COLOR noir, blanc
LOCATE 9, 35 - zz: PRINT "_"
LOCATE 12, 52: PRINT "_"
r$ = INPUT$(1)
IF ASC(r$) = 27 THEN CALL quitter(blanc): GOTO multi12
IF ASC(r$) < 48 OR ASC(r$) > 57 THEN CALL chiffres(blanc): GOTO multi12
r = VAL(r$)
LOCATE 9, 35 - zz: PRINT r$
LOCATE 12, 52: PRINT r$
IF r <> retenue1 THEN
CALL ligne23(noir, noir)
BEEP: COLOR rougeclair: CALL centre(23, rougeclair, "Retenue =" + STR$(retenue1)): CALL attendre(1): CALL ligne23(noir, blanc)
GOTO multi12
END IF
COLOR blancbrill, noir: CALL ligne23(noir, blanc)
END IF

h = h + 1
zz = zz + 1
NEXT j
'++++++++++++++

'resultats
COLOR , noir
IF cc = 0 THEN
re = re + 2
COLOR jaune
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
COLOR rougeclair
LOCATE 23, 32
PRINT "Tu as fait"; cc; "erreur"; : IF cc > 1 THEN PRINT "s";
PRINT "."
IF cc > 3 AND ni > 1 THEN
CALL attendre(2)
BEEP
CALL centre(23, rougeclair, "Tu vas changer de niveau.")
CALL getinvimouse(w)
f = 1: EXIT FOR
END IF
END IF
cc = 0

CALL getinvimouse(w)
NEXT no

IF f = 1 THEN GOTO princmulti
CALL resultats(re, ni, 4)

END SUB

DEFINT A-Z
SUB nombrechiffre (re%, ni%, un$(), di$(), ex$(), rt$, gg$, pre$, titr$, prog%, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
DIM re$(12), p(2), TR$(3), M$(40)
'7/12/96 ===
zero$ = "0000000000"

ct = 0
w$ = "Tu vas devoir taper les nombres"
z$ = "en chiffres."
CALL consigne(2, w$, z$, y$)

CALL Niveau(ni, 3)
IF ni = 1 THEN ti = 2
IF ni = 2 THEN ti = 3
IF ni = 3 THEN ti = 4

FOR boucle = 1 TO 5 '++++++++++++++++++++++++

CALL titre(titr$)

c = 0
CALL niv(5, boucle)
GOSUB chiftirage: GOSUB chiftrans
CALL cadre(8, 5, 70, 4, rouge)
COLOR blancbrill, rouge
LOCATE 10: M$ = n2$ + " ": GOSUB chiftrouvemot
CALL centre(10, blancbrill, M$)

chif4:
COLOR , bleu

CALL centre(14, blanc, "Tape le nombre en chiffres")
COLOR blancbrill
CALL cadre(16, 35, 10, 2, blanc)
COLOR noir, blanc
LOCATE 17, 39: PRINT "_"
LOCATE 17, 39

nl = LEN(n$)

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(nl, r$, 48, 57, blanc)

IF ASC(r$) = 13 OR ASC(r$) = 27 THEN GOTO chif4
zz = VAL(r$): IF zz = 0 THEN GOTO chif4
b$ = LTRIM$(STR$(zz))
COLOR , noir: LOCATE 22: PRINT SPACE$(80): PRINT SPACE$(80)
IF zz = resultat THEN
LOCATE 23, 18: CALL exact2(.7)
ELSE

c = c + 1
IF c < 3 THEN
IF c = 1 THEN ct = ct + 2
LOCATE 23, 18: COLOR , noir: CALL erreur2(.7)
GOSUB chifaide2
ELSE
CALL solution(STR$(resultat))
END IF
GOTO chif4
END IF
NEXT boucle

re = 10 - ct: IF re < 0 THEN re = 0
CALL resultats(re, ni, 3)

EXIT SUB

chifanalyse:
no$ = ""
FOR i = 2 TO 0 STEP -1
p(i) = VAL(MID$(TR$, 3 - i, 1))
NEXT
IF p(2) = 0 THEN GOTO chif10
IF p(2) = 1 THEN no$ = "cent ": GOTO chif10
no$ = un$(p(2)) + "cent"
IF p(0) <> 0 OR p(1) <> 0 THEN no$ = no$ + " ": GOTO chif10
IF f = -1 THEN no$ = no$ + "s"
no$ = no$ + " "
chif10:
IF p(1) = 0 THEN GOTO chif11
IF p(1) = 7 AND p(0) = 1 THEN no$ = no$ + di$(p(1) - 1) + "et " + ex$(p(0)): RETURN
IF p(1) = 1 AND (p(0) > 0 AND p(0) < 7) THEN no$ = no$ + ex$(p(0)): RETURN
IF (p(1) = 7 OR p(1) = 9) AND (p(0) > 0 AND p(0) < 7) THEN no$ = no$ + di$(p(1) - 1) + ex$(p(0)): RETURN
IF p(0) = 1 AND (p(1) <> 0 AND p(1) <> 8) THEN no$ = no$ + di$(p(1)) + "et ": GOTO chif11
no$ = no$ + di$(p(1))
IF f = -1 AND (p(1) = 8 AND p(0) = 0) THEN no$ = LEFT$(no$, LEN(no$) - 1) + "s "
chif11:
IF p(0) = 0 THEN RETURN
no$ = no$ + un$(p(0))
RETURN

chiftrans:
n$ = MID$(STR$(resultat), 2): n1$ = LEFT$(zero$, 10 - LEN(n$)) + n$: n2$ = ""
i = 0
FOR j = 1 TO 7 STEP 3
TR$(i) = MID$(n1$, 9 - j, 3)
i = i + 1
NEXT
'_unités simples_
f = -1: TR$ = TR$(0)
IF VAL(TR$) = 0 THEN GOTO chif12
GOSUB chifanalyse
n2$ = no$
chif12:
f = 0: TR$ = TR$(1): IF VAL(TR$) = 0 THEN GOTO chif13
IF VAL(TR$) = 1 THEN n2$ = "mille " + n2$: GOTO chif13
GOSUB chifanalyse
n2$ = no$ + "mille " + n2$
chif13:
TR$ = TR$(2): IF VAL(TR$) = 0 THEN GOTO chif14
IF VAL(TR$) = 1 THEN n2$ = "un million " + n2$: GOTO chif14
GOSUB chifanalyse
n2$ = no$ + "millions " + n2$
chif14:
n2$ = MID$(n2$, 1, LEN(n2$) - 1)
RETURN

chiftirage:
DO
z = INT(RND * 10 ^ ti) + 1
LOOP WHILE z = resultat
resultat = z
IF ni = 2 AND resultat < 100 THEN GOTO chiftirage
IF ni = 3 AND resultat < 1000 THEN GOTO chiftirage
RETURN

chifaide2:
z1 = 0
FOR ii = 1 TO LEN(n$)
IF MID$(n$, ii, 1) = "0" THEN z1 = z1 + 1
NEXT
z2 = 0
FOR ii = 1 TO LEN(b$)
IF MID$(b$, ii, 1) = "0" THEN z2 = z2 + 1
NEXT
IF LEN(n$) = LEN(b$) AND z1 <= z2 THEN RETURN
IF zz > 0 THEN CALL centre(22, blanc, "Ta réponse : " + b$)
f = 0: f2 = 0
IF LEN(n$) <> LEN(b$) THEN
sol$ = "Il faut" + STR$(LEN(n$)) + " chiffres."
f = 1
END IF
IF z1 AND (z1 - z2) > 0 THEN
sol2$ = STR$(z1 - z2) + " zéro": IF z1 - z2 > 1 THEN sol2$ = sol2$ + "s"
sol2$ = sol2$ + " oublié": IF z1 - z2 > 1 THEN sol2$ = sol2$ + "s."
f2 = 1
END IF

IF f = 1 AND f2 = 0 THEN
CALL centre(23, rougeclair, sol$)
ELSEIF f = 0 AND f2 = 1 THEN
CALL centre(23, rougeclair, sol2$)
ELSEIF f = 1 AND f2 = 1 THEN
CALL centre(23, rougeclair, sol$ + " " + sol2$)
END IF
COLOR blancbrill
RETURN

chiftrouvemot:
j = 1: MM$ = ""
FOR i = 1 TO LEN(M$)
MM$ = MM$ + MID$(M$, i, 1)
IF ASC(MID$(M$, i, 1)) = 32 THEN M$(j) = MID$(MM$, 1, LEN(MM$) - 1): MM$ = "": j = j + 1: IF LEN(M$(j - 1)) = 0 THEN j = j - 1
NEXT
nm = j - 1
RETURN

END SUB

DEFINT A-Z
SUB orthmath (re, ni, mo1$(), mo2$(), rt$, gg$, pre$, titr$, prog, nom$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
DIM p2$(5), z(10), p$(2), mot$(24)
'23/4/97
p2$(1) = "très lente": p2$(2) = "lente": p2$(3) = "moyenne"
p2$(4) = "rapide": p2$(5) = "très rapide"
lp$ = STRING$(22, ".")
'debut
c = 0: re = 0

w$ = "L'ordinateur va afficher des mots à l'écran."
z$ = "Mémorise-les bien car tu devras les retaper."
CALL consigne(2, w$, z$, y$)

p$(1) = "Les nombres": p$(2) = "Les mots"

CALL titre(titr$)

CALL fleches(11, 36, p$(), 2, ni, 1, 23, 35)

IF ni = 1 THEN
vit = 3
FOR i = 1 TO 24: mot$(i) = mo1$(i): NEXT
ELSE
vit = 2
FOR i = 1 TO 14: mot$(i) = mo2$(i): NEXT
END IF

CALL titre(titr$)
IF ni = 2 THEN
CALL cadre(4, 30, 20, 15, marron)
COLOR blancbrill, marron
LOCATE 5
FOR i = 1 TO 14
LOCATE , 35: PRINT mot$(i)
NEXT
ELSE
CALL cadre(5, 20, 40, 13, marron)
COLOR blancbrill, marron
LOCATE 6
FOR i = 1 TO 12
LOCATE , 30: PRINT mot$(i)
NEXT
LOCATE 6
FOR i = 13 TO 24
LOCATE , 44: PRINT mot$(i)
NEXT
END IF
COLOR , noir
CALL centre(23, blanc, "Mémorise l'orthographe des mots")
COLOR blancbrill
CALL getinvimouse(r)

'prg principal_
FOR ii = 1 TO 10 '++++++++++++++++++++++++++++++++
CALL titre(titr$)
CALL cadre(10, 28, 24, 4, blanc)

erreurs = 0
IF ni = 1 THEN limite = 24 ELSE limite = 14
DO
f = 0
z(ii) = INT(RND * limite) + 1 'pour ce1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
nn = z(ii)

s$ = mot$(nn)
CALL niv(10, ii)

or0:
CALL cadre(6, 28, 24, 2, vert)
COLOR , vert
CALL centre(7, blancbrill, "Vitesse " + p2$(vit))
CALL attendre(.5)

COLOR , blanc

IF erreurs = 0 THEN
SELECT CASE ii
CASE 1, 3, 5, 7, 9
CALL centre(12, noir, s$)
CALL attendre(2 / vit)

CASE ELSE
'flash
FOR x = 1 TO 3
CALL centre(12, noir, s$)
CALL attendre(.09)
CALL centre(12, noir, SPACE$(LEN(s$)))
CALL attendre(.15)
NEXT
END SELECT

ELSE
CALL centre(12, noir, s$)
CALL attendre(2 / vit)

END IF

h = INT(41 - LEN(s$) / 2)
CALL centre(12, noir, MID$(lp$, 1, LEN(s$)))

COLOR , noir
CALL centre(23, blanc, "Tape le mot")
nl = LEN(s$): LOCATE 12, h

COLOR noir, blanc
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE &H417, (PEEK(&H417) AND &HBF) 'minus
DEF SEG

CALL inputgen(nl, r$, 65, 165, blanc)
r$ = LCASE$(r$)

IF r$ = s$ THEN
cc = cc + 1: CALL exact2(.7)
IF erreurs = 0 THEN re = re + 1
erreurs = 0
ELSE
CALL erreur2(.7): cc = 0: c = c + 1:
erreurs = 1
IF c = 2 THEN c = 0: vit = vit - 1: IF vit < 1 THEN vit = 1
'_________________
'mettre en rouge là où c'est faux
COLOR , blanc
LOCATE 12, INT(41 - (LEN(s$) / 2))
FOR i = 1 TO LEN(r$)
IF MID$(s$, i, 1) = MID$(r$, i, 1) THEN
COLOR noir
ELSE
COLOR rouge
END IF
PRINT MID$(r$, i, 1);
NEXT
PRINT
LOCATE 13, INT(41 - (LEN(s$) / 2))
'on compte les erreurs
flag2 = 0
FOR i = 1 TO LEN(r$)
IF MID$(s$, i, 1) <> MID$(r$, i, 1) THEN
flag2 = flag2 + 1
END IF
NEXT

IF flag2 < 3 THEN
FOR i = 1 TO LEN(r$)
IF MID$(s$, i, 1) = MID$(r$, i, 1) THEN
PRINT " ";
ELSE
COLOR rouge
PRINT CHR$(24);
END IF
NEXT
ELSE
CALL centre(13, noir, SPACE$(LEN(s$)))
END IF
CALL attendre(1)

'________________
CALL ligne23(noir, noir): GOTO or0
END IF

IF vit = 1 AND cc = 2 THEN vit = 2: cc = 0
IF vit = 2 AND cc = 2 THEN vit = 3: cc = 0
IF vit = 3 AND cc = 3 THEN vit = 4: cc = 0
IF vit = 4 AND cc = 3 THEN vit = 5: cc = 0
NEXT ii

CALL resultats(re, ni, 2)

END SUB

DEFINT A-Z
SUB regle (re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'31/5/95
CONST gauche = 75, droite = 77
fh$ = CHR$(4): l2$ = SPACE$(71)
g$ = CHR$(27) + " " + CHR$(26) + " puis " + rt$
re = 0
CALL Niveau(ni, 2)

IF ni = 1 THEN
w$ = "Avec les flèches, tu vas devoir"
z$ = "chercher un nombre sur une règle."
CALL consigne(2, w$, z$, y$)
ELSE
w$ = "Tu vas taper le nombre indiqué"
z$ = "par une flèche sur une règle."
CALL consigne(2, w$, z$, y$)
END IF

SELECT CASE ni '+++++++++++++++++++++++++++++++
CASE 1
ne = 0

FOR nf = 1 TO 10
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

CALL titre(titr$)
CALL niv(10, nf)

n = INT(RND * 75) + 10
alea = INT(RND * 14) + 1
n2 = alea + n
n2$ = LTRIM$(STR$(n2))
CALL cadre(5, 25, 30, 2, marron)
COLOR , marron
CALL centre(6, blancbrill, "Cherche le nombre : " + n2$)
CALL cadre1(9, 1, 78, 7, noir, bleu, rouge)

'dessin des traits
LOCATE 12, 4
FOR i = 0 TO 14
z = INT(RND * 2)
IF i = 0 THEN
PRINT n + i; " ";
ELSEIF z = 1 AND i <> alea AND i <> alea + 1 AND i <> alea - 1 THEN
PRINT n + i; " ";
ELSE
PRINT " ";
END IF
NEXT
LOCATE 13, 5
FOR i = 1 TO 15: PRINT CHR$(179); " "; : NEXT
COLOR , bleu
reg1:
h = 5
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

COLOR , noir: CALL centre(23, blanc, g$)
COLOR , bleu
DO
LOCATE 14, 5: PRINT l2$: LOCATE 14, h: PRINT fh$

DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 22, 1: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF v_mouse = 23 THEN
IF h_mouse = 35 THEN
'fleche gauche
rr = gauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche droite
rr = droite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 44 AND h_mouse <= 46 THEN
'entree
rr = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSEIF v_mouse >= 12 AND v_mouse <= 14 THEN
IF h_mouse >= 5 AND h_mouse <= 75 THEN
FOR ij = 5 TO 75 STEP 5
IF h_mouse = ij THEN
h = h_mouse
LOCATE 14, 5: PRINT l2$: LOCATE 14, h: PRINT fh$: COLOR blancbrill
CALL attendre(.3)
souris = 2
EXIT DO
END IF
NEXT
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN EXIT DO

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF


SELECT CASE rr
CASE gauche
IF h = 5 THEN
h = 75
ELSEIF h > 5 THEN
h = h - 5
END IF

CASE droite
IF h = 75 THEN
h = 5
ELSEIF h < 75 THEN
h = h + 5
END IF

CASE 27
CALL quitter(noir)
COLOR , bleu

CASE 13
EXIT DO

END SELECT

LOOP

COLOR , noir
n3 = n + (h / 5) - 1
n3$ = LTRIM$(STR$(n3))
IF n2 <> n3 THEN
LOCATE 23, 20: COLOR rougeclair: PRINT "Tu as indiqué le nombre "; : COLOR jaune: PRINT n3$;
COLOR rougeclair: PRINT " au lieu de "; : COLOR jaune: PRINT n2$
CALL getinvimouse(w)
LOCATE 23: PRINT l2$
ne = ne + 1
COLOR , bleu
GOTO reg1
END IF
CALL exact2(1)
IF ne = 0 THEN re = re + 1
ne = 0
NEXT nf

CALL resultats(re, ni, 2)

CASE 2 '++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ne = 0

FOR nf = 1 TO 10
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

CALL titre(titr$)
CALL niv(10, nf)

'tirage
n = INT(RND * 75) + 10
alea = INT(RND * 14) + 1
n2 = alea + n
n2$ = LTRIM$(STR$(n2)) 'réponse

CALL cadre1(7, 1, 78, 7, noir, bleu, rouge)

'dessin des traits
LOCATE 10, 4
FOR i = 0 TO 14
z = INT(RND * 2)
IF i = 0 THEN
PRINT n + i; " ";
ELSEIF z = 1 AND i <> alea AND i <> alea + 1 AND i <> alea - 1 THEN
PRINT n + i; " ";
ELSE
PRINT " ";
END IF
NEXT
LOCATE 11, 5
FOR i = 1 TO 15: PRINT CHR$(179); " "; : NEXT
COLOR , bleu

LOCATE 12, 5: PRINT l2$
LOCATE 12, (alea * 5) + 5: PRINT CHR$(24)

reg2:
COLOR , noir
CALL centre(23, blanc, "Tape le nombre indiqué par la flèche")
COLOR , bleu

CALL cadre(16, 36, 6, 2, blanc)
COLOR noir, blanc
LOCATE 17, 39: PRINT "_"
LOCATE 17, 39
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(3, r$, 48, 57, blanc)

COLOR , noir
IF r$ = n2$ THEN
CALL exact2(1)
IF ne = 0 THEN re = re + 1
ne = 0
ELSE
CALL erreur2(1)
ne = ne + 1
IF ne > 1 THEN
CALL solution(n2$)
END IF
GOTO reg2
END IF
NEXT nf

CALL resultats(re, ni, 2)
END SELECT

END SUB

DEFINT A-Z
SUB soustractions (re, ni, flagscreengraph, rt$, gg$, titr$, pre$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'3/6/95

ll$ = STRING$(10, 196)
ret$ = "Attention aux retenues !"

princsousti:
cc = 0: re = 0: f = 0
CALL Niveau(ni%, 4)
SELECT CASE ni
CASE 1
n1 = 1: n2 = 1
CASE 2
n1 = 2: n2 = 2
CASE 3
IF flagscreengraph = 0 THEN
CALL soustract(re, ni, rt$, gg$, titr$, pre$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
EXIT SUB
ELSE
n1 = 3: n2 = 2
END IF
CASE 4
IF flagscreengraph = 0 THEN
CALL soustract(re, ni, rt$, gg$, titr$, pre$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
EXIT SUB
ELSE
n1 = 4: n2 = 3
END IF

END SELECT

IF ni = 3 THEN
CALL titre(titr$)
IF pre$ <> "" THEN
CALL centre(10, blancbrill, pre$)
END IF
CALL centre(12, blancbrill, ret$)

CALL entree(noir, noir)
END IF

FOR no = 1 TO 5
CALL titre(titr$)
CALL niv(5, no)

'tirage
sousti0:
DO
a = INT(RND * (10 ^ n1))
a$ = LTRIM$(STR$(a))
LOOP WHILE LEN(a$) <> n1
DO
b = INT(RND * (10 ^ n2))
b$ = LTRIM$(STR$(b))
LOOP WHILE LEN(b$) <> n2
IF a < b THEN GOTO sousti0
IF ni = 2 THEN
DO
b = b - 1
b$ = LTRIM$(STR$(b))
LOOP WHILE RIGHT$(a$, 1) < RIGHT$(b$, 1)
IF LEN(b$) <> n2 THEN GOTO sousti0
END IF

CALL cadre(7, 32, 16, 9, blanc)
COLOR noir, blanc

'oper posee
LOCATE 10, 42 - n1: PRINT a
LOCATE 12, 41 - n1: PRINT "-"; SPC(n1 - n2); b
LOCATE 13, 41 - n1: PRINT MID$(ll$, 1, n1 + 2)
'boucle comparaison
cc = 0
r$ = LTRIM$(STR$(a - b))
l = LEN(r$)
IF l + 1 = n1 THEN r$ = "0" + r$: l = l + 1
IF l + 2 = n1 THEN r$ = "00" + r$: l = l + 2
IF l + 3 = n1 THEN r$ = "000" + r$: l = l + 3
b$ = "0" + b$
boucle = 0
FOR j = l TO 1 STEP -1

r1$ = MID$(r$, j, 1)

a1$ = MID$(a$, LEN(a$) - boucle, 1)
b1$ = MID$(b$, LEN(b$) - boucle, 1)

soust1:
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG
LOCATE 23: COLOR blanc, noir
IF VAL(r1$) <> VAL(a1$) - VAL(b1$) THEN
CALL centre(23, blancbrill, ret$)
ELSE
CALL centre(23, blanc, "Tape la réponse")
END IF

COLOR noir, blanc
LOCATE 14, 42 - l + j, 1: PRINT "_"
LOCATE 14, 42 - l + j, 1
re$ = INPUT$(1)
IF ASC(re$) = 27 THEN CALL quitter(blanc): GOTO soust1
IF ASC(re$) < 48 OR ASC(re$) > 57 THEN CALL chiffres(blanc): GOTO soust1
LOCATE , , 0: PRINT re$
CALL ligne23(noir, noir)
LOCATE 23, 38, 0: COLOR , noir

IF re$ = r1$ THEN
CALL exact2(.7)
ELSE
cc = cc + 1
IF cc >= 2 THEN
CALL solution(r1$)
COLOR noir, blanc
ELSE
CALL erreur2(.7)
END IF
GOTO soust1
END IF

boucle = boucle + 1

NEXT j

'resultats
COLOR , noir
IF cc = 0 THEN
re = re + 2
COLOR jaune
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
COLOR rougeclair
LOCATE 23, 32
PRINT "Tu as fait"; cc; "erreur"; : IF cc > 1 THEN PRINT "s";
PRINT "."
IF cc > 3 AND ni > 1 THEN
CALL attendre(2)
BEEP
CALL centre(23, rougeclair, "Tu vas changer de niveau.")
CALL getinvimouse(w)
f = 1: EXIT FOR
END IF
END IF
cc = 0

CALL getinvimouse(w)
NEXT no '++++++++++++++++++

IF f = 1 THEN GOTO princsousti
CALL resultats(re, ni, 4)


END SUB

DEFINT A-Z
SUB tableauplus (re%, ni%, rt$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DIM re$(3 + 1), ca(5, 5), n(71), d(71), p$(4), z(11)
'26/11/96
CONST gauche = 75, droite = 77, bas = 80, haut = 72

l1$ = " ─┼────┼────┼────┼────┼────┼────┤"

l0$ = " │ │ │ │ │ │ │"

l4$ = " ─┴────┴────┴────┴────┴────┴────┘"

ff$ = CHR$(24) + " " + CHR$(25) + " " + CHR$(27) + " " + CHR$(26)
FOR i = 0 TO 5
FOR j = 0 TO 5
ca(i, j) = 0
NEXT j, i

re = 10
CALL titre(titr$)
'niveau
p$(1) = "Tableau de 0 à 5"
p$(2) = "Tableau de 6 à 11"
p$(3) = "Tableau de 20 à 25"
p$(4) = "Tableau de 30 à 35"

CALL cadre(7, 25, 30, 2, vert)
COLOR , vert

CALL centre(8, blancbrill, "Niveau de difficulté")

CALL fleches(12, 32, p$(), 4, ni, 1, 23, 35)

FOR ii = 1 TO 6
DO
f = 0
z(ii) = INT(RND * 6)
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT j
LOOP WHILE f = 1
NEXT ii
FOR i = 1 TO 6
IF ni = 1 THEN
n(i - 1) = z(i)
ELSEIF ni = 2 THEN
n(i + 5) = z(i) + 6
ELSEIF ni = 3 THEN
n(i + 19) = z(i) + 20
ELSE
n(i + 29) = z(i) + 30
END IF
NEXT

FOR ii = 1 TO 6
DO
f = 0
z(ii) = INT(RND * 6)
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT j
LOOP WHILE f = 1
NEXT ii
FOR i = 1 TO 6
IF ni = 1 THEN
d(i - 1) = z(i)
ELSEIF ni = 2 THEN
d(i + 5) = z(i) + 6
ELSEIF ni = 3 THEN
d(i + 19) = z(i) + 20
ELSE
d(i + 29) = z(i) + 30

END IF
NEXT

CALL titre(titr$)

CALL cadre(4, 21, 36, 15, rouge)
LOCATE 6, , 0
COLOR blanc, rouge
h = 24
LOCATE , h: PRINT l1$
FOR i = 1 TO 5
LOCATE , h: PRINT l0$: LOCATE , h: PRINT l1$
NEXT
LOCATE , h: PRINT l0$: LOCATE , h: PRINT l4$

COLOR jaune, rouge
v = 7: h = 23
FOR i = 0 TO 5
IF ni = 1 THEN
LOCATE v, h: PRINT RTRIM$(STR$(n(i)))
ELSEIF ni = 2 THEN
LOCATE v, (h + 1) - LEN(LTRIM$(STR$(n(i + 6)))): PRINT RTRIM$(STR$(n(i + 6)))
ELSEIF ni = 3 THEN
LOCATE v, (h + 1) - LEN(LTRIM$(STR$(n(i + 20)))): PRINT RTRIM$(STR$(n(i + 20)))
ELSE
LOCATE v, (h + 1) - LEN(LTRIM$(STR$(n(i + 30)))): PRINT RTRIM$(STR$(n(i + 30)))
END IF
v = v + 2
NEXT

LOCATE 5, h: COLOR vertclair: PRINT " +"; : COLOR jaune
h = 24
FOR i = 0 TO 5
LOCATE , h + 3 + (i * 5)
IF ni = 1 THEN
PRINT d(i);
ELSEIF ni = 2 THEN
PRINT d(i + 6);
ELSEIF ni = 3 THEN
PRINT d(i + 20);
ELSE
PRINT d(i + 30);
END IF

NEXT

v = 7: h = 28: total = 1

ta2:
CALL niv(36, total)

souris = 0
x1 = (v - 7) / 2: y1 = (h - 28) / 5
IF ca(x1, y1) = 0 THEN
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

LOCATE , , 0
COLOR , noir
CALL centre(23, blanc, "Tape la réponse ou " + ff$)
LOCATE , , 1
DO
LOCATE v, h: nl = 3
GOSUB inpute
LOOP WHILE r$ = CHR$(13) AND souris = 2
IF souris = 2 THEN GOTO ta2

ELSE
COLOR , noir
LOCATE 23, 1, 0: PRINT SPACE$(80)
CALL centre(23, blanc, ff$)
LOCATE v, h, 1
COLOR blancbrill

DO
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 1: PRINT "Position de la souris : "; v_mouse; ", "; h_mouse '===
IF lButton AND ii > 1 THEN
BEEP
ELSEIF lButton THEN
'ligne fleches et entree
IF v_mouse = 23 THEN
IF h_mouse = 37 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 39 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 41 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 43 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSEIF v_mouse = 7 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF
ELSEIF v_mouse = 9 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 11 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 13 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 15 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 17 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN GOTO ta2

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF


IF rr = gauche OR rr = droite OR rr = haut OR rr = bas THEN
r$ = CHR$(rr)
EXIT DO
END IF
IF rr = 27 THEN
CALL quitter(noir)
LOCATE v, h, 1
END IF
LOOP
END IF

SELECT CASE ASC(r$)

CASE gauche
h = h - 5
IF h < 28 THEN v = v - 2: h = 53
IF v < 7 THEN v = 17: BEEP
GOTO ta2

CASE droite
h = h + 5
IF h > 53 THEN v = v + 2: h = 28
IF v > 17 THEN v = 7: BEEP
GOTO ta2

CASE bas
v = v + 2
IF v > 17 THEN v = 7: BEEP
GOTO ta2

CASE haut
v = v - 2
IF v < 7 THEN v = 17: BEEP
GOTO ta2

END SELECT

r = VAL(r$)
IF ni = 1 THEN x = (v - 7) / 2: y = (h - 28) / 5
IF ni = 2 THEN x = ((v - 7) / 2) + 6: y = ((h - 28) / 5) + 6
IF ni = 3 THEN x = ((v - 7) / 2) + 20: y = ((h - 28) / 5) + 20
IF ni = 4 THEN x = ((v - 7) / 2) + 30: y = ((h - 28) / 5) + 30
COLOR , noir
IF r = n(x) + d(y) THEN
LOCATE 23, 1: PRINT SPACE$(80)
CALL exact2(.7)
ELSE
COLOR noir, rouge
LOCATE v, h - 1: PRINT " "
LOCATE v, h - 1: PRINT "="; LTRIM$(STR$(d(y) + n(x)))
COLOR blancbrill, noir: er = er + 1
END IF

x1 = (v - 7) / 2: y1 = (h - 28) / 5: ca(x1, y1) = 1

'test si fin
f = 0: total = 0
FOR i = 0 TO 5
FOR j = 0 TO 5
IF ca(i, j) = 0 THEN
f = 1
total = total + 1
END IF
NEXT j
NEXT i

total = 37 - total

IF f = 0 THEN
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL entree(noir, noir)
re = 10 - er: IF re < 0 THEN re = 0
CALL resultats(re, ni, 4)
EXIT SUB '+++++
END IF

DO
h = h + 5
IF h > 53 THEN v = v + 2: h = 28
IF v > 17 THEN v = 7
x1 = (v - 7) / 2: y1 = (h - 28) / 5
LOOP WHILE ca(x1, y1) = 1

GOTO ta2

'++++++++++++++++++++++

inpute:
COLOR , rouge
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

ligne = CSRLIN
colon = POS(0)
LOCATE ligne, colon: PRINT " "
LOCATE ligne, colon, 1, 0, 7

FOR ii = 1 TO nl + 1
ta5:
IF ii <= 0 THEN ii = 1
ta6:
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 1: PRINT v_mouse; ", "; h_mouse '===
IF lButton THEN
'ligne fleches et entree
IF v_mouse = 23 THEN
IF h_mouse = 47 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 49 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 51 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 53 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF

ELSEIF v_mouse = 7 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF
ELSEIF v_mouse = 9 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 11 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 13 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 15 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 17 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN
x1 = (v - 7) / 2: y1 = (h - 28) / 5
IF ca(x1, y1) = 0 THEN
LOCATE v, h, 1
GOTO inpute '===
ELSE
RETURN '===
END IF
END IF

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

re$(ii) = CHR$(rr)

IF rr = 27 THEN
CALL quitter(bleu)
LOCATE v, h, 1
GOTO inpute
END IF

IF rr = 13 OR rr = droite THEN
EXIT FOR
END IF

IF (rr = gauche OR rr = droite OR rr = haut OR rr = bas) AND ii = 1 THEN
EXIT FOR
END IF

IF ii > 1 AND (rr = 8 OR rr = gauche OR rr = 83) THEN
PRINT CHR$(29); " "; CHR$(29);
ii = ii - 1
GOTO ta5
END IF

IF rr < 48 OR rr > 57 THEN
CALL chiffres(bleu)
LOCATE v, h, 1
GOTO inpute
END IF

IF ii = nl + 1 THEN BEEP: GOTO ta6

PRINT re$(ii);
NEXT ii

PRINT : LOCATE , , 0
r$ = "": FOR jj = 1 TO ii - 1: r$ = r$ + re$(jj): NEXT
r$ = LTRIM$(r$): r$ = RTRIM$(r$)
IF r$ = "" THEN r$ = CHR$(rr)
COLOR , noir
RETURN
END SUB

DEFINT A-Z
SUB tablesmulti (re%, ni%, rt$, gg2$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'31/5/95
DIM p$(15), z(10)

c = 0
tit$ = "Tables de multiplication"
CALL titre(tit$)

'niveau
CALL cadre(8, 25, 30, 2, vert)
COLOR , vert

CALL centre(9, blancbrill, "Table à travailler")
COLOR blanc, bleu
FOR i = 1 TO 9: p$(i) = STR$(i): NEXT
p$(10) = LTRIM$(STR$(10))
LOCATE 13, 20: PRINT "Niveau 1"
LOCATE 15, 20: PRINT "Niveau 2"
LOCATE 13, 54: PRINT "Niveau 3"
LOCATE 15, 54: PRINT "Niveau 4"

CALL cadre(12, 30, 4, 6, rouge)
CALL cadre(12, 45, 4, 6, rouge)
COLOR , noir
CALL centre(23, blanc, gg2$)
COLOR blancbrill, rouge
CALL fleches2(13, 32, 5, 10, 47, p$(), ta, rouge)

COLOR , bleu
ta$ = RTRIM$(LTRIM$(STR$(ta)))
SELECT CASE ta
CASE 1, 2
ni = 1
CASE 3, 4, 5
ni = 2
CASE 6, 7
ni = 3
CASE ELSE
ni = 4
END SELECT

CALL titre(tit$)
CALL cadre(6, 30, 20, 2, vert)
COLOR , vert
CALL centre(7, blancbrill, "Table des " + ta$)
flag = 1: GOSUB tables

CALL titre(tit$)
'questions
FOR ii = 1 TO 10 '++++++++++++++++++++++
CALL niv(10, ii)
CALL cadre(6, 30, 20, 2, vert)
COLOR , vert
CALL centre(7, blancbrill, "Table des " + ta$)

DO
f = 0
z(ii) = INT(RND * 10) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
ha = z(ii)
ha$ = LTRIM$(STR$(ha))
tab0:
COLOR , bleu: VIEW PRINT 13 TO 20: CLS 2: VIEW PRINT

CALL cadre(9, 30, 20, 4, blanc)

COLOR , noir: CALL centre(23, blanc, "Tape la réponse"): COLOR noir, blanc
LOCATE 11, 36: PRINT ha$; " x "; ta$; " = _"
LOCATE 11, 36: PRINT ha$; " x "; ta$; " = ";

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(3, r$, 48, 57, blanc)
r = VAL(r$)

COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF r = (ta * ha) THEN
CALL exact2(.7): COLOR blancbrill, bleu
ELSE
c = c + 1
flag = 2: GOSUB tables
CALL ligne23(noir, bleu)
GOTO tab0
END IF
NEXT ii

re = 10 - c: IF re < 0 THEN re = 0

CALL resultats(re, ni, 4)
EXIT SUB

tables:
COLOR , noir
CALL centre(23, blanc, "Mémorise"): COLOR blancbrill, bleu
IF flag = 2 THEN
CALL cadre(14, 10, 60, 6, rouge)
v = 15
ELSE
CALL cadre(10, 10, 60, 6, rouge)
v = 11
END IF
COLOR blancbrill, rouge
LOCATE v
FOR j = 1 TO 5
LOCATE , (22 - LEN(STR$(j))): PRINT j; "x "; ta$; " = ";
LOCATE , (30 + LEN(ta$)) - LEN(LTRIM$(STR$(ta * j))): PRINT LTRIM$(STR$(ta * j))
NEXT
LOCATE v
FOR j = 6 TO 10
LOCATE , (51 - LEN(STR$(j))): PRINT j; "x "; ta$; " = ";
LOCATE , (59 + LEN(ta$)) - LEN(LTRIM$(STR$(ta * j))): PRINT LTRIM$(STR$(ta * j))
NEXT
CALL getinvimouse(w)
RETURN
END SUB

DEFINT A-Z
SUB tablesplus (re%, ni%, rt$, gg2$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'14/12/96
DIM p$(15), z(10)

c = 0
tit$ = "Tables d'additions"
CALL titre(tit$)

'niveau
CALL cadre(8, 25, 30, 2, vert)
COLOR , vert

CALL centre(9, blancbrill, "Table à travailler")
COLOR blanc, bleu
FOR i = 1 TO 9: p$(i) = STR$(i): NEXT
p$(10) = LTRIM$(STR$(10))
LOCATE 13, 20: PRINT "Niveau 1"
LOCATE 15, 20: PRINT "Niveau 2"
LOCATE 13, 54: PRINT "Niveau 3"
LOCATE 15, 54: PRINT "Niveau 4"

CALL cadre(12, 30, 4, 6, rouge)
CALL cadre(12, 45, 4, 6, rouge)
COLOR , noir
CALL centre(23, blanc, gg2$)
COLOR blancbrill, rouge
CALL fleches2(13, 32, 5, 10, 47, p$(), ta, rouge)

COLOR , bleu
ta$ = RTRIM$(LTRIM$(STR$(ta)))
SELECT CASE ta
CASE 1, 2
ni = 1
CASE 3, 4, 5
ni = 2
CASE 6, 7
ni = 3
CASE ELSE
ni = 4
END SELECT

CALL titre(tit$)
CALL cadre(6, 30, 20, 2, vert)
COLOR , vert
CALL centre(7, blancbrill, "Table des " + ta$)
flag = 1: GOSUB tablespl

CALL titre(tit$)
'questions
FOR ii = 1 TO 10
CALL niv(10, ii)

CALL cadre(6, 30, 20, 2, vert)
COLOR , vert

CALL centre(7, blancbrill, "Table des " + ta$)
DO
f = 0
z(ii) = INT(RND * 10) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
ha = z(ii)
ha$ = LTRIM$(STR$(ha))
tabp0:
COLOR , bleu
VIEW PRINT 13 TO 20
CLS 2
VIEW PRINT

CALL cadre(9, 30, 20, 4, blanc)

COLOR blanc, noir: CALL centre(23, blanc, "Tape la réponse"): COLOR noir, blanc
LOCATE 11, 36: PRINT ha$; " + "; ta$; " = _"
LOCATE 11, 36: PRINT ha$; " + "; ta$; " = ";

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(3, r$, 48, 57, blanc)
r = VAL(r$)

COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF r = (ta + ha) THEN
CALL exact2(.7): COLOR blancbrill, bleu
ELSE
c = c + 1
flag = 2: GOSUB tablespl
CALL ligne23(noir, bleu)
GOTO tabp0
END IF
NEXT ii

re = 10 - c: IF re < 0 THEN re = 0

CALL resultats(re, ni, 4)
EXIT SUB

tablespl:
COLOR , noir
CALL centre(23, blanc, "Mémorise")
IF flag = 2 THEN
CALL cadre(14, 10, 60, 6, rouge)
v = 15
ELSE
CALL cadre(10, 10, 60, 6, rouge)
v = 11
END IF
COLOR blancbrill, rouge

LOCATE v
FOR j = 1 TO 5
LOCATE , (20 - LEN(STR$(j))): PRINT j; "+ "; ta$; " = ";
LOCATE , (28 + LEN(ta$)) - LEN(LTRIM$(STR$(ta + j))): PRINT LTRIM$(STR$(ta + j))
NEXT
LOCATE v
FOR j = 6 TO 10
LOCATE , (49 - LEN(STR$(j))): PRINT j; "+ "; ta$; " = ";
LOCATE , (59 + LEN(ta$)) - LEN(LTRIM$(STR$(ta + j))): PRINT LTRIM$(STR$(ta + j))
NEXT
CALL getinvimouse(w)
RETURN

END SUB

DEFINT A-Z
SUB valeurchiffre (re, ni, rt$, pre$, gg$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'27/1/96
CONST gauche = 75, droite = 77
DIM ta$(4)
g$ = CHR$(27) + " " + CHR$(26) + " puis " + rt$
fh$ = CHR$(24)
ta$(1) = "mille": ta$(2) = "centaines": ta$(3) = "dizaines": ta$(4) = "unités"

CALL Niveau(ni, 2)


ne = 0: nu = 0


FOR nf = 1 TO 10
CALL titre(titr$)
CALL niv(10, nf)

SELECT CASE ni
CASE 1
DO
nr = RND * 1000
LOOP WHILE nr < 100
CALL cadre(10, 30, 19, 4, rouge)
COLOR blancbrill, rouge: LOCATE 12, 38: PRINT nr
DO
zz = INT(RND * 3) + 2 'pas de mille
LOOP WHILE zz = nu
nu = zz

CASE 2
DO
nr = RND * 10000
LOOP WHILE nr < 1000
CALL cadre(10, 29, 20, 4, rouge)
COLOR blancbrill, rouge: LOCATE 12, 37: PRINT nr
DO
zz = INT(RND * 4) + 1
LOOP WHILE zz = nu
nu = zz

END SELECT


dec2:
CALL cadre(6, 20, 40, 2, marron)
COLOR , marron
CALL centre(7, blancbrill, "Indique le chiffre des " + ta$(nu))
COLOR blancbrill, rouge: h = 42
LOCATE 13, 34: PRINT LEFT$(SPACE$(80), 11)

DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG
flag = 1
DO
COLOR blancbrill, rouge: LOCATE 13, 36: PRINT LEFT$(SPACE$(80), 11)
LOCATE 13, h: PRINT fh$
COLOR blanc, noir: LOCATE 23, 35: PRINT g$

DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
MousePoll v_mouse, h_mouse, lButton, rButton
'LOCATE 22, 1: PRINT v_mouse, h_mouse '===
IF lButton THEN
IF v_mouse = 12 OR v_mouse = 13 THEN
SELECT CASE ni
CASE 1
IF h_mouse = 39 OR h_mouse = 40 OR h_mouse = 41 THEN
h = h_mouse
COLOR blancbrill, rouge
LOCATE 13, 35: PRINT SPACE$(12)
LOCATE 13, h: PRINT fh$
CALL attendre(.3)
flag = 0
souris = 2
EXIT DO
ELSE
BEEP
END IF

CASE 2
IF h_mouse = 38 OR h_mouse = 39 OR h_mouse = 40 OR h_mouse = 41 THEN
h = h_mouse
COLOR blancbrill, rouge
LOCATE 13, 35: PRINT SPACE$(12)
LOCATE 13, h: PRINT fh$
CALL attendre(.3)
flag = 0
souris = 2
EXIT DO
ELSE
BEEP
END IF
END SELECT
ELSEIF v_mouse = 23 THEN
IF h_mouse = 35 THEN
'fleche gauche
x = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche droite
x = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 44 AND h_mouse <= 46 THEN
'entree
x = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN
EXIT DO
END IF

IF souris = 0 THEN
IF LEN(r$) < 2 THEN x = ASC(r$) ELSE x = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE x

CASE gauche
flag = 0
SELECT CASE ni
CASE 1
IF h > 39 THEN h = h - 1 '===
CASE 2
IF h > 38 THEN h = h - 1
END SELECT

CASE droite
IF flag = 1 THEN
BEEP
ELSE
IF h < 41 THEN h = h + 1
END IF

CASE 27
CALL quitter(rouge)

CASE 13
IF flag = 1 THEN
BEEP
ELSE
EXIT DO
END IF

CASE ELSE
BEEP

END SELECT

LOOP

h = h - 37
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
IF h = nu THEN
CALL exact2(.7)
ELSE
COLOR rougeclair: BEEP
CALL centre(23, rougeclair, "Tu as montré le chiffre des " + ta$(h))
CALL getinvimouse(w)
CALL ligne23(noir, noir)
ne = ne + 1: GOTO dec2
END IF
NEXT nf

re = 10 - ne: IF re < 0 THEN re = 0

CALL resultats(re, ni, 1)


END SUB
 

 

DECLARE SUB niv (limit%, xx%)
DECLARE SUB claviernumerique (z$)
DECLARE SUB attendre (tx!)
DECLARE SUB cadre3 (v%, h%, nb%, coul%)
DECLARE SUB entree (x%, y%)
DECLARE SUB erreur2 (tx!)
DECLARE SUB erreur3 (tx!)
DECLARE SUB exact2 (tx!)
DECLARE SUB exact3 (tx!)
DECLARE SUB inputgen (nl%, r$, deb%, fin%, fond%)
DECLARE SUB Niveau (ni%, np%)
DECLARE SUB quitter (fond%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB solution (sol$)
DECLARE SUB titre (titr$)
DECLARE SUB titre2 (titr$)
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB centre (v%, cc%, ph$)
DECLARE SUB consigne (nl%, w$, z$, y$)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB MouseBorder (row1%, col1%, row2%, col2%)
DECLARE SUB MouseHide ()
DECLARE SUB MousePoll (row%, col%, lButton%, rButton%)
DECLARE SUB MouseShow ()
'Exercices AAS MATH CE = module 3
'Daniel CLERC
'6/6/96
'Version 1.0


DEFINT A-Z
SUB doubles (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'18/12/2001 ===
DIM re$(20), z(5), nombre(5)

'niveau
CALL Niveau(ni, 3)
SELECT CASE ni
CASE 1
limit = 30: limit2 = 15
CASE 2
limit = 60: limit2 = 30
CASE 3
limit = 150: limit2 = 50
END SELECT

re = 0

cc = 0
CALL titre(titr$)

MouseHide
'tirage
FOR ii = 1 TO 5
DO
DO
f = 0
z(ii) = INT(RND * limit) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
LOOP WHILE z(ii) < limit2
nombre(ii) = z(ii)
NEXT ii

'dessin des cadres
v = 6: h = 10
FOR i = 1 TO 5
CALL cadre(v, h, 4, 4, rouge)
IF nombre(i) >= 100 THEN
LOCATE v + 2, h + 1
ELSE
LOCATE v + 2, h + 2
END IF
COLOR , rouge
PRINT LTRIM$(RTRIM$(STR$(nombre(i))))
h = h + 14
NEXT
v = 14: h = 10
FOR i = 1 TO 5
COLOR vertclair, bleu
LOCATE v - 2, h + 2: PRINT CHR$(25)
CALL cadre(v, h, 4, 4, blanc)
h = h + 14
NEXT
COLOR vertclair, bleu
LOCATE v + 2, 2: PRINT "Double"
COLOR , noir

h = 12
FOR boucle = 1 TO 5 '/////////////
CALL niv(5, boucle)
resultat = nombre(boucle) * 2

DO
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H20) 'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG
COLOR noir, blanc
IF resultat >= 100 THEN
LOCATE 16, h - 1: PRINT "_ "
LOCATE 16, h - 1
ELSE
LOCATE 16, h: PRINT "_ "
LOCATE 16, h
END IF

CALL inputgen(3, r$, 48, 57, blanc)

z = VAL(r$)
z$ = STR$(nombre(boucle)) + " +" + STR$(nombre(boucle)) + " =" + STR$(resultat)

COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF z = resultat THEN
CALL exact2(1)
IF cc = 0 THEN re = re + 2
cc = 0
EXIT DO
ELSE
cc = cc + 1
IF cc = 1 THEN
BEEP
IF z = (nombre(boucle) / 2) THEN
CALL centre(23, rougeclair, "Tu as tapé la moitié !")
CALL attendre(2)
ELSE
CALL erreur2(.7)
END IF
ELSE
CALL solution(z$)
END IF
END IF

LOOP
h = h + 14
NEXT boucle '//////////

CALL resultats(re, ni, 3)

END SUB

DEFINT A-Z
SUB frise (re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur, coef1!, coef2!, nbniv)
'17/3/94
DIM dessin$(10), solu$(10), x(10), y(10), x2(10), z(5), lo(10)
DIM cercle(1 TO 50) AS INTEGER

CONST gauche = 75, droite = 77
CONST haut = 72, bas = 80, hautgauche = 71, hautdroite = 73, basgauche = 79, basdroite = 81
ll$ = SPACE$(80)
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

dessin$(1) = "r25 u25 l25 u25 r25 u75 r25 u25 r25 d50 l25 d25 r25 d25 l25 d25 r25 d25 r25"
solu$(1) = "dhghdhhhdhdbbgbdbgbdbd"
x(1) = 50: y(1) = 175: x2(1) = 250: lo(1) = 100
dessin$(2) = "r25 d75 l25 d25 r50 u50 r25 u25 l25 u50 l25 u50 r25 d25 r25 d50 r25"
solu$(2) = "dbbbgbddhhdhghhghhdbdbbd"
x(2) = 50: y(2) = 75: x2(2) = 250: lo(2) = 100
dessin$(3) = "r25 d50 l25 d50 r25 d50 l25 d25 r25 d25 r25 u25 r25 u25 l25 u25 r25 u75 l25 u25 r25 u25 r25"
solu$(3) = "dbbgbbdbbgbdbdhdhghdhhhghdhd"
x(3) = 50: y(3) = 0: x2(3) = 250: lo(3) = 100
dessin$(4) = "r25 d75 r50 u50 l25 u50 l50 u50 r25 u25 r25 u25 r25 d50 l25 d25 r25 d50 r25"
solu$(4) = "dbbbddhhghhgghhdhdhdbbgbdbbd"
x(4) = 50: y(4) = 125: x2(4) = 250: lo(4) = 100
dessin$(5) = "r25 u25 r25 d50 l25 d50 l25 d25 r25 d75 r25 u50 r25 u25 l25 u50 r25 u50 r25"
solu$(5) = "dhdbbgbbgbdbbbdhhdhghhdhhd"
x(5) = 50: y(5) = 25: x2(5) = 250: lo(5) = 100

'niveau 2
dessin$(6) = "r50 d25 m-25,+25 d50 r25 u25 m+25,-25 r25 u50"
solu$(6) = "ddbmbbdhkdhh"
x(6) = 50: y(6) = 75: x2(6) = 250: lo(6) = 100
dessin$(7) = "d50 m+25,+25 d25 r25 u50 m+25,-25 u25 r25"
solu$(7) = "bblbdhhkhd"
x(7) = 50: y(7) = 50: x2(7) = 250: lo(7) = 100
dessin$(8) = "m+25,-25 m-25,-25 u25 r25 m+25,-25 d50 r25 d75 m+25,-25"
solu$(8) = "kjhdkbbdbbbk"
x(8) = 50: y(8) = 150: x2(8) = 250: lo(8) = 100
dessin$(9) = "m+25,+25 d25 m+25,+25 u50 m-25,-25 m+25,-25 u25 m+50,+50"
solu$(9) = "lblhhjkhll"
x(9) = 50: y(9) = 100: x2(9) = 250: lo(9) = 100
dessin$(10) = "m+25,-25 m-25,-25 u25 m+50,-50 r25 d25 m-25,+25 m+25,+25 d25 m+25,+25"
solu$(10) = "kjhkkdbmlbl"
x(10) = 50: y(10) = 175: x2(10) = 250: lo(10) = 100

CALL Niveau(ni, 2)
IF ni = 1 THEN nombre = 0 ELSE nombre = 5
re = 0

GOSUB frise40 'présentation

SCREEN 9
x = 635: y = 35
CIRCLE (x, y), 4, jaune, , , coef2!
GET (x - 4, y - 4)-(x + 4, y + 4), cercle

FOR jj = 1 TO 3
erreurs = 0
GOSUB frise6 'tirage

frise13:
CALL titre2(titr$)
IF ni = 1 THEN COLOR vertclair: LOCATE 22: PRINT "Niveau"; ni: LOCATE 22, 77: PRINT 4 - jj
x = x(choix) + 20: y = y(choix) + 55
FOR i = 1 TO 5
DRAW "TA0 B m=" + VARPTR$(x) + ",=" + VARPTR$(y)
IF i = 3 THEN cc = bleu ELSE cc = cyanclair
IF i = 3 AND erreurs > 2 AND couleur = 1 THEN cc = rougeclair
DRAW "c=" + VARPTR$(cc) + dessin$(choix)
x = x + lo(choix)
NEXT

'fenetre
VIEW (20, 55)-(630, 260)
GOSUB frise1

IF ni = 1 OR erreurs > 0 THEN
flag2 = 1
LINE (50, 0)-(550, 200), blancbrill, B, &H8888
LINE (150, 0)-(150, 200), blancbrill, , &H8888
LINE (250, 0)-(350, 200), blancbrill, B, &H8888
LINE (450, 0)-(450, 200), blancbrill, , &H8888
END IF

x = x2(choix): y = y(choix)
GOSUB frise2

GOSUB frise14
flag = 0: reponse$ = ""

GOSUB friseprog

VIEW

LOCATE 22: PRINT ll$: PRINT ll$

IF solu$(choix) = reponse$ THEN
CALL exact2(1)
IF erreurs = 0 THEN re = re + 3
ELSE
erreurs = erreurs + 1
IF erreurs > 1 THEN
CALL centre(23, rougeclair, "Regarde...")
x = x(choix) + 20 + (2 * lo(choix)): y = y(choix) + 55
DRAW "TA0 B m=" + VARPTR$(x) + ",=" + VARPTR$(y)
DRAW "c=" + VARPTR$(rougeclair) + dessin$(choix)
CALL getinvimouse(r): IF r = 27 THEN CALL quitter(noir)
ELSE
CALL erreur2(1)
END IF
LOCATE 23: PRINT ll$
GOTO frise13
END IF

NEXT jj

'résultats
SCREEN 0
re = re + 1
CALL resultats(re, ni, nbniv)

EXIT SUB

'++++++++++++++++++++++++

frise1:
FOR x = 50 TO 550 STEP 25
FOR y = 0 TO 200 STEP 25
PSET (x, y), rougeclair
NEXT y
NEXT x
RETURN

frise14:
IF ni = 1 THEN
CALL centre(23, blanc, CHR$(27) + " " + CHR$(26) + " " + CHR$(24) + " " + CHR$(25) + " = tracer <-- = corriger " + rt$ + " = valider")
ELSE
COLOR blanc
LOCATE 23, 23: PRINT "= tracer <-- = corriger " + rt$ + " = valider"
LOCATE 21, 10: PRINT "[7] [8] [9]"
LOCATE 22, 10: PRINT "[4] [6]"
LOCATE 23, 10: PRINT "[1] [2] [3]"
END IF
RETURN

frise2:
PUT (x - 4, y - 4), cercle, XOR
IF ni = 1 OR erreurs > 0 THEN PSET (x, y), rougeclair
RETURN

frise5:
flag = flag - 1
r$ = RIGHT$(reponse$, 1)
reponse$ = MID$(reponse$, 1, LEN(reponse$) - 1)
GOSUB frise2
IF r$ = "g" THEN
xx = x + 25: yy = y
ELSEIF r$ = "d" THEN
xx = x - 25: yy = y
ELSEIF r$ = "h" THEN
xx = x: yy = yy + 25
ELSEIF r$ = "b" THEN
xx = x: yy = yy - 25
END IF
LINE (x, y)-(xx, yy), bleu
RETURN

frise6:
'tirage
DO
f = 0
z(jj) = INT(RND * 5) + 1
FOR j = 1 TO jj - 1
IF z(jj) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
choix = z(jj) + nombre
RETURN

friseprog:
DO
frise31:
IF ni = 1 THEN
MouseBorder 308, 10, 320, 630
MouseShow
souris = 0
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 1: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF v_mouse >= 308 AND v_mouse <= 320 THEN
'fleches
IF h_mouse >= 100 AND h_mouse <= 112 THEN
'gauche
valtouche = gauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 116 AND h_mouse <= 128 THEN
'droite
valtouche = droite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 133 AND h_mouse <= 145 THEN
'haut
valtouche = haut
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 150 AND h_mouse <= 160 THEN
'bas
valtouche = bas
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 270 AND h_mouse <= 380 THEN
'del
valtouche = 8
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 420 AND h_mouse <= 528 THEN
'return
valtouche = 13
CALL attendre(.2)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

MouseHide

IF souris = 0 THEN
IF LEN(r$) < 2 THEN valtouche = ASC(r$) ELSE valtouche = ASC(RIGHT$(r$, 1))
END IF


ELSEIF ni = 2 THEN
MouseBorder 282, 75, 320, 630
MouseShow
souris = 0
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 40: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF (v_mouse >= 282 AND v_mouse <= 292) AND (h_mouse >= 73 AND h_mouse <= 93) THEN
valtouche = hautgauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 282 AND v_mouse <= 292) AND (h_mouse >= 106 AND h_mouse <= 126) THEN
valtouche = haut
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 282 AND v_mouse <= 292) AND (h_mouse >= 136 AND h_mouse <= 156) THEN
valtouche = hautdroite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 296 AND v_mouse <= 306) AND (h_mouse >= 73 AND h_mouse <= 93) THEN
valtouche = gauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 296 AND v_mouse <= 306) AND (h_mouse >= 136 AND h_mouse <= 156) THEN
valtouche = droite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 310 AND v_mouse <= 320) AND (h_mouse >= 73 AND h_mouse <= 93) THEN
valtouche = basgauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 310 AND v_mouse <= 320) AND (h_mouse >= 106 AND h_mouse <= 126) THEN
valtouche = bas
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 310 AND v_mouse <= 320) AND (h_mouse >= 136 AND h_mouse <= 156) THEN
valtouche = basdroite
CALL attendre(.2)
souris = 1
EXIT DO
END IF
'ok
IF v_mouse >= 308 AND v_mouse <= 320 THEN
IF h_mouse >= 280 AND h_mouse <= 390 THEN
'del
valtouche = 8
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 440 AND h_mouse <= 540 THEN
'return
valtouche = 13
CALL attendre(.2)
souris = 1
EXIT DO
ELSE
BEEP
END IF
END IF
END IF

LOOP WHILE r$ = ""

MouseHide

IF souris = 0 THEN
IF LEN(r$) < 2 THEN valtouche = ASC(r$) ELSE valtouche = ASC(RIGHT$(r$, 1))
END IF

END IF

IF (valtouche = 8 OR valtouche = 83) AND flag = 0 THEN BEEP: GOTO frise31

SELECT CASE ni
CASE 1
IF valtouche = 50 THEN valtouche = bas
IF valtouche = 52 THEN valtouche = gauche
IF valtouche = 54 THEN valtouche = droite
IF valtouche = 56 THEN valtouche = haut
CASE 2
IF valtouche = 49 OR valtouche = 38 THEN valtouche = basgauche
IF valtouche = 50 OR valtouche = 130 THEN valtouche = bas
IF valtouche = 51 OR valtouche = 34 THEN valtouche = basdroite
IF valtouche = 52 OR valtouche = 39 THEN valtouche = gauche
IF valtouche = 54 OR valtouche = 45 THEN valtouche = droite
IF valtouche = 55 OR valtouche = 138 THEN valtouche = hautgauche
IF valtouche = 56 OR valtouche = 95 THEN valtouche = haut
IF valtouche = 57 OR valtouche = 135 THEN valtouche = hautdroite
END SELECT

SELECT CASE valtouche

CASE gauche
IF flag2 = 1 THEN LINE (250, 0)-(350, 200), blancbrill, B, &H8888
IF RIGHT$(reponse$, 1) = "d" THEN GOSUB frise5: GOTO frise32
xx = x - 25: yy = y
GOSUB frise2
IF xx < 250 THEN
xx = 250: BEEP
ELSE
reponse$ = reponse$ + "g"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE droite
IF flag2 = 1 THEN LINE (250, 0)-(350, 200), blancbrill, B, &H8888
IF RIGHT$(reponse$, 1) = "g" THEN GOSUB frise5: GOTO frise32
xx = x + 25: yy = y
GOSUB frise2
IF xx > 350 THEN
xx = 350: BEEP
ELSE
reponse$ = reponse$ + "d"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE haut
IF flag2 = 1 THEN LINE (250, 0)-(350, 200), blancbrill, B, &H8888
IF RIGHT$(reponse$, 1) = "b" THEN GOSUB frise5: GOTO frise32
xx = x: yy = y - 25
GOSUB frise2
IF yy < 0 THEN
yy = 0: BEEP
ELSE
reponse$ = reponse$ + "h"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE bas
IF flag2 = 1 THEN LINE (250, 0)-(350, 200), blancbrill, B, &H8888
IF RIGHT$(reponse$, 1) = "h" THEN GOSUB frise5: GOTO frise32
xx = x: yy = y + 25
GOSUB frise2
IF yy > 200 THEN
yy = 200: BEEP
ELSE
reponse$ = reponse$ + "b"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE hautgauche
IF RIGHT$(reponse$, 1) = "l" THEN GOSUB frise35: GOTO frise32
xx = x - 25: yy = y - 25
GOSUB frise2
IF yy < 0 OR xx < 250 THEN
IF yy < 0 THEN
yy = 0: xx = xx + 25: BEEP
ELSEIF xx < 250 THEN
xx = 250: yy = yy + 25: BEEP
END IF
ELSE
reponse$ = reponse$ + "j"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE hautdroite
IF RIGHT$(reponse$, 1) = "m" THEN GOSUB frise35: GOTO frise32
xx = x + 25: yy = y - 25
GOSUB frise2
IF yy < 0 OR xx > 350 THEN
IF yy < 0 THEN
yy = 0: xx = xx - 25: BEEP
ELSEIF xx > 350 THEN
xx = 350: yy = yy + 25: BEEP
END IF
ELSE
reponse$ = reponse$ + "k"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE basgauche
IF RIGHT$(reponse$, 1) = "k" THEN GOSUB frise35: GOTO frise32
xx = x - 25: yy = y + 25
GOSUB frise2
IF yy > 200 OR xx < 250 THEN
IF yy > 200 THEN
yy = 200: xx = xx + 25: BEEP
ELSEIF xx < 250 THEN
xx = 250: yy = yy - 25: BEEP
END IF
ELSE
reponse$ = reponse$ + "m"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE basdroite
IF RIGHT$(reponse$, 1) = "j" THEN GOSUB frise35: GOTO frise32
xx = x + 25: yy = y + 25
GOSUB frise2
IF yy > 200 OR xx > 350 THEN
IF yy > 200 THEN
yy = 200: xx = xx - 25: BEEP
ELSEIF xx > 350 THEN
xx = 350: yy = yy - 25: BEEP
END IF
ELSE
reponse$ = reponse$ + "l"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE 8, 83 'correction
r$ = RIGHT$(reponse$, 1)
IF r$ = "h" OR r$ = "b" OR r$ = "g" OR r$ = "d" THEN
GOSUB frise5
ELSE
GOSUB frise35
END IF
IF flag2 = 1 THEN LINE (250, 0)-(350, 200), blancbrill, B, &H8888

CASE 27
CALL quitter(noir): GOSUB frise14: GOTO frise31
CASE 13
IF reponse$ = "" THEN GOTO frise31
EXIT DO
CASE ELSE
BEEP

END SELECT

frise32:
IF valtouche = 71 OR valtouche = 73 OR valtouche = 79 OR valtouche = 81 OR valtouche = 8 OR valtouche = 83 OR valtouche = gauche OR valtouche = droite OR valtouche = haut OR valtouche = bas THEN
IF ni = 1 OR erreurs > 0 THEN PSET (x, y), rougeclair
x = xx: y = yy
GOSUB frise2
END IF

LOOP

RETURN

frise35:
flag = flag - 1
r$ = RIGHT$(reponse$, 1)
reponse$ = MID$(reponse$, 1, LEN(reponse$) - 1)
GOSUB frise2
IF r$ = "j" THEN
xx = x + 25: yy = y + 25
ELSEIF r$ = "k" THEN
xx = x - 25: yy = y + 25
ELSEIF r$ = "m" THEN
xx = x + 25: yy = yy - 25
ELSEIF r$ = "l" THEN
xx = x - 25: yy = yy - 25
END IF
LINE (x, y)-(xx, yy), bleu
RETURN

frise40:

IF ni = 1 THEN
w$ = "Avec les flèches " + CHR$(27) + " " + CHR$(26) + " " + CHR$(24) + " " + CHR$(25) + ", tu vas compléter une frise."
z$ = "Tu peux corriger tes erreurs avec la touche " + CHR$(27) + "-"
CALL consigne(2, w$, z$, y$)

ELSE

z$ = "compléter une frise en partie effacée."
CALL claviernumerique(z$)
END IF
RETURN

END SUB

DEFINT A-Z
SUB heure (re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'21/1/94

DIM cercle(1 TO 50) AS INTEGER

CONST pi = 3.141592653589# ' , x = 320, y = 170
re = 0
ll$ = SPACE$(80)
rayon = 30
anglefin! = 90 * (pi / 180)
DIM z(5), rep(12), an(12), ang(60)
'choix de la difficulté
CALL Niveau(ni, 2)

rep(1) = 30: rep(2) = 60: rep(3) = 90: rep(4) = 120
rep(5) = 150: rep(6) = 180: rep(7) = 210: rep(8) = 240
rep(9) = 270: rep(10) = 300: rep(11) = 330: rep(12) = 360

an(1) = 330: an(2) = 300: an(3) = 270: an(4) = 240
an(5) = 210: an(6) = 180: an(7) = 150: an(8) = 120
an(9) = 90: an(10) = 60: an(11) = 30: an(12) = 0

FOR i = 0 TO 60
ang(i) = 360 - (6 * i)
NEXT

'début programme
SCREEN 9
x = 635: y = 35
CIRCLE (x, y), 4, jaune
GET (x - 4, y - 4)-(x + 4, y + 4), cercle
'++++++++++++++++++++++++++++++++ niveau 1
IF ni = 1 THEN

FOR jj = 1 TO 5

erreurs = 0
var! = 0
flag = 0: flag2 = 0
'tirage
DO
f = 0
z(jj) = INT(RND * 11) + 1
FOR j = 1 TO jj - 1
IF z(jj) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
choix = z(jj)
reponse = rep(choix)
CALL titre2(titr$)
GOSUB horloge

'les heures
LOCATE 22: PRINT ll$
DO
GOSUB ang6

LOCATE 22, 77: COLOR vertclair: PRINT 6 - jj

angle = an(flag2)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(bleu) + " u67"

angle = an(flag)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(vertclair) + "u67"
PUT (320 - 4, 155 - 4), cercle, OR
GOSUB ang6

flag2 = flag

ang2:
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG
MouseBorder 44, 160, 320, 470
MouseShow

DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 1: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF v_mouse >= 50 AND v_mouse <= 75 THEN
IF h_mouse >= 310 AND h_mouse <= 330 THEN
flag = 12
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 60 AND v_mouse <= 80 THEN
IF h_mouse >= 375 AND h_mouse <= 390 THEN
flag = 1
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 250 AND h_mouse <= 260 THEN
flag = 11
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 100 AND v_mouse <= 115 THEN
IF h_mouse >= 425 AND h_mouse <= 445 THEN
flag = 2
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 195 AND h_mouse <= 215 THEN
flag = 10
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 150 AND v_mouse <= 160 THEN
IF h_mouse >= 430 AND h_mouse <= 460 THEN
flag = 3
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 180 AND h_mouse <= 205 THEN
flag = 9
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 195 AND v_mouse <= 210 THEN
IF h_mouse >= 425 AND h_mouse <= 445 THEN
flag = 4
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 195 AND h_mouse <= 215 THEN
flag = 8
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 230 AND v_mouse <= 250 THEN
IF h_mouse >= 375 AND h_mouse <= 390 THEN
flag = 5
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 250 AND h_mouse <= 260 THEN
flag = 7
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 235 AND v_mouse <= 255 THEN
IF h_mouse >= 310 AND h_mouse <= 330 THEN
flag = 6
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF

IF v_mouse >= 308 AND v_mouse <= 320 THEN
'fleches
IF h_mouse >= 160 AND h_mouse <= 246 THEN
'haut
touche = 72
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 264 AND h_mouse <= 350 THEN
'bas
touche = 80
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 368 AND h_mouse <= 470 THEN
'return
touche = 13
CALL attendre(.2)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

MouseHide

IF souris = 2 THEN
angle = an(flag2)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(bleu) + " u67"

angle = an(flag)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(vertclair) + "u67"
PUT (320 - 4, 155 - 4), cercle, OR
flag2 = flag

touche = 13
END IF

IF souris = 0 THEN
IF LEN(r$) < 2 THEN touche = ASC(r$) ELSE touche = ASC(RIGHT$(r$, 1))
END IF


SELECT CASE touche
CASE 27
CALL quitter(noir)

CASE 72 'haut
flag = flag - 1: IF flag < 0 THEN flag = 0: BEEP: GOTO ang2

CASE 80 'bas
flag = flag + 1: IF flag > 12 THEN flag = 12: BEEP: GOTO ang2

CASE 13
LOCATE 22: PRINT ll$
IF flag = choix THEN
CALL exact2(.7): LOCATE 23: PRINT ll$: fixe! = angle
IF erreurs = 0 THEN re = re + 1
EXIT DO
ELSE
erreurs = erreurs + 1
CALL erreur2(.5)
IF rep(flag) = 30 OR rep(flag) = 0 THEN z$ = " heure." ELSE z$ = " heures."
CALL centre(23, rougeclair, "Tu as indiqué" + STR$(rep(flag) / 30) + z$)
CALL attendre(2)
END IF
LOCATE 23: PRINT ll$
GOSUB ang6
GOTO ang2
EXIT DO

CASE ELSE
BEEP: GOTO ang2

END SELECT

LOOP WHILE valtouche$ <> CHR$(13)

'les minutes
flag = 0: flag2 = 0: var = 0
'tirage
DO
f = 0
z(jj) = INT(RND * 11) + 1
FOR j = 1 TO jj - 1
IF z(jj) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
choix = z(jj)
reponse = rep(choix)
LOCATE 22: PRINT ll$
GOSUB horloge2

DO
GOSUB ang10
GOSUB ang11 'dessin des heures
angle = an(flag2)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(bleu) + " u80"

angle = an(flag)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(jaune) + "u80"
GOSUB ang10
GOSUB ang11 'dessin des heures

flag2 = flag
ang7:
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

MouseBorder 44, 160, 320, 470
MouseShow
souris = 0
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 1: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF v_mouse >= 50 AND v_mouse <= 75 THEN
IF h_mouse >= 310 AND h_mouse <= 330 THEN
flag = 12
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 60 AND v_mouse <= 80 THEN
IF h_mouse >= 375 AND h_mouse <= 390 THEN
flag = 1
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 250 AND h_mouse <= 260 THEN
flag = 11
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 100 AND v_mouse <= 115 THEN
IF h_mouse >= 425 AND h_mouse <= 445 THEN
flag = 2
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 195 AND h_mouse <= 215 THEN
flag = 10
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 150 AND v_mouse <= 160 THEN
IF h_mouse >= 430 AND h_mouse <= 460 THEN
flag = 3
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 180 AND h_mouse <= 205 THEN
flag = 9
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 195 AND v_mouse <= 210 THEN
IF h_mouse >= 425 AND h_mouse <= 445 THEN
flag = 4
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 195 AND h_mouse <= 215 THEN
flag = 8
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 230 AND v_mouse <= 250 THEN
IF h_mouse >= 375 AND h_mouse <= 390 THEN
flag = 5
souris = 2
CALL attendre(.3)
EXIT DO
ELSEIF h_mouse >= 250 AND h_mouse <= 260 THEN
flag = 7
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF
IF v_mouse >= 235 AND v_mouse <= 255 THEN
IF h_mouse >= 310 AND h_mouse <= 330 THEN
flag = 6
souris = 2
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF

IF v_mouse >= 308 AND v_mouse <= 320 THEN
'fleches
IF h_mouse >= 160 AND h_mouse <= 246 THEN
'haut
touche = 72
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 264 AND h_mouse <= 350 THEN
'bas
touche = 80
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 368 AND h_mouse <= 470 THEN
'return
touche = 13
CALL attendre(.2)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

MouseHide

IF souris = 2 THEN

'effacer l'aiguille des minutes
angle = an(flag2)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(bleu) + " u80"
'dessin aiguille minutes
angle = an(flag)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(jaune) + "u80"
'effacer aiguille heure
angle2! = fixe! + var!
DRAW "b m320,155 ta=" + VARPTR$(angle2!) + "c=" + VARPTR$(bleu) + "u67"
PUT (320 - 4, 155 - 4), cercle, OR
'dessin des heures
var! = 0
FOR i = 1 TO flag
var! = var! - 2.5
NEXT
GOSUB ang11 'dessin des heures

flag2 = flag
touche = 13
END IF

IF souris = 0 THEN
IF LEN(r$) < 2 THEN touche = ASC(r$) ELSE touche = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE touche
CASE 27
CALL quitter(noir)

CASE 72 'haut
flag = flag - 1: IF flag < 0 THEN flag = 0: BEEP: GOTO ang7
GOSUB ang12: var! = var! + 2.5

CASE 80 'bas
flag = flag + 1: IF flag > 12 THEN flag = 12: BEEP: GOTO ang7
GOSUB ang12: var! = var! - 2.5

CASE 13
LOCATE 22: PRINT ll$
IF flag = choix THEN
CALL exact2(1.5): LOCATE 23: PRINT ll$
IF erreurs = 0 THEN re = re + 1
EXIT DO
ELSE
erreurs = erreurs + 1
CALL erreur2(.5)
IF rep(flag) = 0 THEN z$ = " minute." ELSE z$ = " minutes."
CALL centre(23, rougeclair, "Tu as indiqué" + STR$(rep(flag) / 6) + z$)
CALL attendre(2)
END IF
LOCATE 23: PRINT ll$
GOSUB ang10
GOTO ang7
EXIT DO

CASE ELSE
BEEP: GOTO ang7

END SELECT

LOOP WHILE valtouche$ <> CHR$(13)

NEXT jj

'++++++++++++++++++++++++++++++++++ niveau 2
ELSE

FOR jj = 1 TO 5

erreurs = 0
'tirage
DO
f = 0
z(jj) = INT(RND * 11) + 1
FOR j = 1 TO jj - 1
IF z(jj) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
choix = z(jj)
CALL titre2(titr$)

GOSUB horloge
LOCATE 22, 1: PRINT ll$
LOCATE 22, 77: COLOR vertclair: PRINT 6 - jj
'dessin des minutes
choix2 = INT(RND * 11) + 1
angle = an(choix2)
DRAW "b m320,155 ta=" + VARPTR$(angle) + "c=" + VARPTR$(jaune) + " u80"
'dessin des heures
var! = 0
FOR i = 1 TO choix2
var! = var! - 2.5
NEXT
angle! = an(choix) + var!
DRAW "b m320,155 ta=" + VARPTR$(angle!) + "c=" + VARPTR$(vertclair) + " u67"

heure1:
COLOR blancbrill
IF choix > 1 THEN
LOCATE 22, 20: PRINT "Heures : "
ELSE
LOCATE 22, 21: PRINT "Heure : "
END IF
CALL cadre3(22, 29, 2, blancbrill)
COLOR blancbrill: LOCATE 22, 29

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(2, r$, 48, 57, 0)
r = VAL(r$)
IF r = choix OR r = choix + 12 THEN
CALL exact3(.7)
IF erreurs = 0 THEN re = re + 1
ELSE
erreurs = erreurs + 1
CALL erreur3(.5)
IF erreurs >= 2 THEN
CALL centre(23, rougeclair, "Solution :" + STR$(choix))
CALL attendre(1)
CALL centre(23, rougeclair, SPACE$(14))
END IF
GOTO heure1
END IF
CALL cadre3(22, 29, 2, blancbrill)
erreurs = 0
'les minutes
GOSUB horloge2
heure3:
COLOR blancbrill: LOCATE 22, 50: PRINT "Minutes : "
CALL cadre3(22, 60, 2, blancbrill)
LOCATE 22, 60
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL inputgen(2, r$, 48, 57, 0)

r = VAL(r$)
IF r = choix2 * 5 THEN
CALL exact3(.7)
IF erreurs = 0 THEN re = re + 1
ELSE
erreurs = erreurs + 1
CALL erreur3(.5)
IF erreurs >= 2 THEN
CALL centre(23, rougeclair, "Solution :" + STR$(choix2 * 5))
CALL attendre(1)
CALL centre(23, rougeclair, SPACE$(14))
END IF

GOTO heure3
END IF
LOCATE 21: COLOR rouge: PRINT STRING$(80, 196): PRINT ll$: PRINT ll$
NEXT jj

END IF
'++++++++++++++++++++++ fin programme

'résultats
SCREEN 0
CALL resultats(re, ni, nbniv)
EXIT SUB


ang6:
IF reponse = 30 THEN z$ = " heure" ELSE z$ = " heures"
CALL centre(22, jaune, STR$(reponse / 30) + z$)
CALL centre(23, blanc, CHR$(24) + " = reculer " + CHR$(25) + " = avancer " + rt$ + " = valider")
RETURN

ang10:
IF reponse = 1 THEN z$ = " minute" ELSE z$ = " minutes"
CALL centre(22, jaune, STR$(reponse / 6) + z$)
CALL centre(23, blanc, CHR$(24) + " = reculer " + CHR$(25) + " = avancer " + rt$ + " = valider")
RETURN

horloge:
CIRCLE (320, 155), 150, vertclair
FOR a = 0 TO 360 STEP 90
DRAW "b m320,155 ta=" + VARPTR$(a) + "c=" + VARPTR$(blancbrill) + "b u85 u15"
NEXT
FOR a = 0 TO 360 STEP 30
DRAW "b m320,155 ta=" + VARPTR$(a) + "c=" + VARPTR$(blancbrill) + "b u90 u10"
NEXT
PUT (320 - 4, 155 - 4), cercle, OR
RETURN

horloge2:
CIRCLE (320, 155), 150, vertclair
FOR a = 0 TO 60
ang = ang(a)
DRAW "b m320,155 ta=" + VARPTR$(ang) + "c=" + VARPTR$(rougeclair) + "b u95 u4"
NEXT
FOR a = 0 TO 360 STEP 30
DRAW "b m320,155 ta=" + VARPTR$(a) + "c=" + VARPTR$(blancbrill) + "b u90 u10"
NEXT
PUT (320 - 4, 155 - 4), cercle, OR
RETURN

ang11:
angle2! = fixe! + var!
DRAW "b m320,155 ta=" + VARPTR$(angle2!) + "c=" + VARPTR$(vertclair) + "u67"
PUT (320 - 4, 155 - 4), cercle, OR
RETURN

ang12:
angle2! = fixe! + var!
DRAW "b m320,155 ta=" + VARPTR$(angle2!) + "c=" + VARPTR$(bleu) + "u67"
PUT (320 - 4, 155 - 4), cercle, OR
RETURN

END SUB
 

 

DECLARE SUB niv (limit%, xx%)
DECLARE SUB claviernumerique (z$)
DECLARE SUB fleches (v%, h%, w$(), np%, r%, drap%, v2%, h2%)
DECLARE SUB solution (sol$)
DECLARE SUB attendre (tx!)
DECLARE SUB cadre3 (v%, h%, nb%, coul%)
DECLARE SUB chiffres (fond%)
DECLARE SUB convertir (z$)
DECLARE SUB entree (x%, y%)
DECLARE SUB erreur2 (tx!)
DECLARE SUB erreur3 (tx!)
DECLARE SUB exact2 (tx!)
DECLARE SUB exact3 (tx!)
DECLARE SUB inputgen (nl%, r$, deb%, fin%, fond%)
DECLARE SUB ligne23 (x%, y%)
DECLARE SUB Niveau (ni%, np%)
DECLARE SUB quitter (fond%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB titre (titr$)
DECLARE SUB titre2 (titr$)
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB centre (v%, cc%, ph$)
DECLARE SUB consigne (nl%, w$, z$, y$)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB MouseBorder (row1%, col1%, row2%, col2%)
DECLARE SUB MouseHide ()
DECLARE SUB MousePoll (row%, col%, lButton%, rButton%)
DECLARE SUB MouseShow ()
'Exercices AAS MATH CE = module 4
'Daniel CLERC
'6/6/96
'Version 1.0


DEFINT A-Z
SUB compter (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DIM p$(15), z(10), ta(3)
'22/12/96
re = 1: cc = 0

CALL titre(titr$)
'niveau
p$(1) = "Compter de 2 en 2"
p$(2) = "Compter de 5 en 5"
p$(3) = "Compter de 10 en 10"
p$(4) = "Compter à l'envers"
CALL cadre(7, 25, 30, 2, vert)
COLOR , vert

CALL centre(8, blancbrill, "Niveau de difficulté")
CALL fleches(12, 32, p$(), 4, ni, 1, 23, 35)

CALL titre(titr$)
MouseHide
COLOR blancbrill
'dessin des cadres
v = 10: h = 2
IF ni <> 4 THEN
FOR i = 1 TO 10
COLOR vertclair, bleu
LOCATE v - 1, h + 1: PRINT i
CALL cadre(v, h, 4, 4, blanc)
h = h + 8
NEXT
ELSE
FOR i = 10 TO 1 STEP -1
COLOR vertclair, bleu
LOCATE v - 1, h + 1: PRINT i
CALL cadre(v, h, 4, 4, blanc)
h = h + 8
NEXT

END IF
'tirage
SELECT CASE ni
CASE 1
ha = 2
CASE 2
ha = 5
CASE 3
ha = 10
CASE 4
z = INT(RND * 3) + 1
SELECT CASE z
CASE 1
ha = 2
CASE 2
ha = 5
CASE 3
ha = 10
END SELECT
END SELECT

ha$ = LTRIM$(STR$(ha))


CALL cadre(5, 20, 40, 2, rouge)
COLOR , rouge

IF ni <> 4 THEN
CALL centre(6, blancbrill, "Compte de " + ha$ + " en " + ha$)
ELSE
CALL centre(6, blancbrill, "Compte de " + ha$ + " en " + ha$ + " à l'envers")
END IF
COLOR noir, blanc

LOCATE 12, 4
IF ni <> 4 THEN
PRINT ha$
ELSE
PRINT LTRIM$(STR$(10 * ha))
reponse = 10 * ha
END IF

h = 12
FOR boucle = 2 TO 10 '/////////////
CALL niv(10, boucle)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")

DO
COLOR noir, blanc

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H20) 'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG

LOCATE 12, h

CALL inputgen(3, r$, 48, 57, blanc)
r = VAL(r$)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF ni <> 4 THEN
reponse = boucle * ha
ELSE
reponse2 = reponse
reponse = (11 - boucle) * ha
END IF

IF r = reponse THEN
CALL exact2(.7)
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
ELSE
cc = cc + 1
IF cc = 1 THEN
CALL erreur2(.7)
IF ni <> 4 THEN
w$ = "": w2$ = ""
IF boucle > 2 THEN
w2$ = LTRIM$(STR$(ha * (boucle - 1))) + " + " + LTRIM$(STR$(ha)) + " = "
END IF
FOR k = 1 TO boucle - 1
w$ = w$ + LTRIM$(STR$(ha)) + " + "
NEXT
w$ = w$ + LTRIM$(STR$(ha)) + " = "

w$ = w2$ + w$ + LTRIM$(STR$(ha)) + " x " + LTRIM$(STR$(boucle))
CALL centre(23, rougeclair, w$)
CALL attendre(1)
ELSE
CALL centre(23, rougeclair, LTRIM$(STR$(reponse2)) + " - " + LTRIM$(STR$(ha)))
CALL attendre(1)
END IF
ELSE
CALL solution(STR$(reponse))
END IF
END IF
LOOP
h = h + 8
NEXT boucle '//////////

'résultats

CALL resultats(re, ni, 3)

END SUB

DEFINT A-Z
SUB coord (re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur, coef1!, coef2!, nbniv)
'4/12/96 souris

DIM z(5), z2(5), y(11, 5), x(11, 5), xx(11), yy(11)
DIM cercle(1 TO 100) AS INTEGER
CONST gauche = 75, droite = 77
CONST haut = 72, bas = 80
LL$ = SPACE$(80)
er = 0: re = 0

x(0, 1) = 4: y(0, 1) = 1
x(1, 1) = 3: y(1, 1) = 4
x(2, 1) = 8: y(2, 1) = 5
x(3, 1) = 13: y(3, 1) = 4
x(4, 1) = 12: y(4, 1) = 1
x(5, 1) = 8: y(5, 1) = 3
x(6, 1) = 4: y(6, 1) = 1
x(11, 1) = 6

x(0, 2) = 7: y(0, 2) = 5
x(1, 2) = 6: y(1, 2) = 6
x(2, 2) = 3: y(2, 2) = 2
x(3, 2) = 7: y(3, 2) = 1
x(4, 2) = 11: y(4, 2) = 2
x(5, 2) = 8: y(5, 2) = 6
x(6, 2) = 7: y(6, 2) = 5
x(11, 2) = 6

x(0, 3) = 8: y(0, 3) = 1
x(1, 3) = 4: y(1, 3) = 6
x(2, 3) = 3: y(2, 3) = 2
x(3, 3) = 8: y(3, 3) = 5
x(4, 3) = 13: y(4, 3) = 2
x(5, 3) = 12: y(5, 3) = 6
x(6, 3) = 8: y(6, 3) = 1
x(11, 3) = 6

x(0, 4) = 8: y(0, 4) = 3
x(1, 4) = 6: y(1, 4) = 1
x(2, 4) = 2: y(2, 4) = 5
x(3, 4) = 5: y(3, 4) = 6
x(4, 4) = 11: y(4, 4) = 6
x(5, 4) = 14: y(5, 4) = 5
x(6, 4) = 10: y(6, 4) = 1
x(7, 4) = 8: y(7, 4) = 3
x(11, 4) = 7

x(0, 5) = 1: y(0, 5) = 1
x(1, 5) = 10: y(1, 5) = 6
x(2, 5) = 14: y(2, 5) = 4
x(3, 5) = 14: y(3, 5) = 3
x(4, 5) = 10: y(4, 5) = 1
x(5, 5) = 1: y(5, 5) = 6
x(6, 5) = 1: y(6, 5) = 1
x(11, 5) = 6

CALL Niveau(ni, 3)

DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

SELECT CASE ni
CASE 1
GOSUB cooniveau1
CASE 2
GOSUB cooniveau2
CASE 3
GOSUB cooniveau3
END SELECT
VIEW

'résultats
SCREEN 0
CALL resultats(re, ni, nbniv)

EXIT SUB

cooniveau1:
GOSUB coo40 'présentation
'GOSUB coo50 'quadrillage

FOR jj = 1 TO 5
GOSUB coo50 'quadrillage
erreurs = 0
GOSUB coo6 'tirage

COLOR vertclair: LOCATE 22, 77: PRINT 6 - jj
x = 0: y = 0
GOSUB coo2
coo13:
GOSUB coo14
CALL centre(22, jaune, "Coordonnées : (" + LTRIM$(STR$(colonne)) + "," + CHR$(ligne + 65) + ")")
GOSUB coo0

LOCATE 22: PRINT LL$: PRINT LL$

IF (colonne = x / 32) AND (ligne = y / 28) THEN
CALL exact2(1.2): IF souris <> 2 THEN GOSUB coo2
IF erreurs = 0 THEN re = re + 2
ELSE
erreurs = erreurs + 1
IF erreurs > 2 THEN
GOSUB coo2
x2 = x: y2 = y
x = colonne * 32: y = ligne * 28
CALL centre(23, rougeclair, "Regarde la bonne réponse : (" + LTRIM$(STR$(colonne)) + "," + CHR$(ligne + 65) + ")")
GOSUB coo2
CALL getinvimouse(r): IF r = 27 THEN CALL quitter(noir)
GOSUB coo2
x = x2: y = y2: GOSUB coo2: GOTO coo13
ELSE
CALL erreur2(.8)
CALL centre(23, rougeclair, "Tu as choisi le couple (" + LTRIM$(STR$(x / 32)) + "," + CHR$(y / 28 + 65) + ")")
CALL getinvimouse(r): IF r = 27 THEN CALL quitter(noir)
GOTO coo13
END IF
END IF

NEXT jj
RETURN '+++++++++++++++

cooniveau2:
GOSUB coo40
GOSUB coo50

FOR jj = 1 TO 5
erreurs = 0
GOSUB coo6 'tirage
x = colonne * 32: y = ligne * 28
GOSUB coo2

coo20:
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H20)'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG

LOCATE 22, 1: PRINT LL$: PRINT LL$
COLOR vertclair: LOCATE 22, 77: PRINT 6 - jj: COLOR blancbrill
LOCATE 22, 19: PRINT "Colonne : "
VIEW: CALL cadre3(22, 29, 2, blancbrill)

LOCATE 22, 29
CALL inputgen(2, r$, 48, 57, 0)
xx = VAL(r$)
IF xx = colonne THEN
CALL exact3(.7)
IF erreurs = 0 THEN re = re + 1
ELSE
erreurs = erreurs + 1
IF erreurs > 2 THEN
CALL centre(23, rougeclair, "Solution :" + STR$(colonne))
CALL attendre(2)
CALL centre(23, rougeclair, SPACE$(14))
GOTO coo20
ELSE
CALL erreur3(.8): GOTO coo20
END IF
END IF
erreurs = 0
coo21:
LOCATE 22, 49: PRINT "Ligne : "
CALL cadre3(22, 57, 2, blancbrill)
LOCATE 22, 57: CALL inputgen(1, r$, 65, 122, 0)
r$ = UCASE$(r$)
IF r$ = CHR$(ligne + 65) THEN
CALL exact3(.7)
IF erreurs = 0 THEN re = re + 1
ELSE
erreurs = erreurs + 1
IF erreurs > 2 THEN
CALL centre(23, rougeclair, "Solution : " + CHR$(ligne + 65))
CALL attendre(2)
CALL centre(23, rougeclair, SPACE$(14))
GOTO coo21
ELSE
CALL erreur3(.8)
GOTO coo21
END IF
END IF

VIEW (83, 77)-(563 + 6, 259 + 6): GOSUB coo2
NEXT jj
VIEW
RETURN '++++++++++++++++++++++++

cooniveau3:
GOSUB coo40 'présentation

FOR boucle = 1 TO 2
GOSUB coo50 'quadrillage

DO
f = 0
z(boucle) = INT(RND * 5) + 1
FOR j = 1 TO boucle - 1
IF z(boucle) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
tabl = z(boucle)
colonne = x(0, tabl): ligne = y(0, tabl)
x = colonne * 32: y = ligne * 28
xx(0) = colonne * 32: yy(0) = ligne * 28
GOSUB coo2: GOSUB coo31

erreurs = 0
h = 14
FOR jj = 1 TO x(11, tabl)
COLOR vertclair: LOCATE 22, 77: PRINT (x(11, tabl) + 1) - jj
colonne = x(jj, tabl): ligne = y(jj, tabl)

GOSUB coo14
LOCATE 22: COLOR blancbrill
PRINT "Coordonnées :"
cc = jaune: f = 0: GOSUB coo22: f = 1

coo51:
GOSUB coo0
IF xx(jj - 1) = x AND yy(jj - 1) = y THEN BEEP: GOTO coo51

xx(jj) = x: yy(jj) = y
IF (colonne = x / 32) AND (ligne = y / 28) THEN
cc = vertclair: GOSUB coo22
ELSE
erreurs = erreurs + 1
cc = rougeclair: GOSUB coo22
END IF
GOSUB coo2
LINE (xx(jj), yy(jj))-(xx(jj - 1), yy(jj - 1)), blancbrill
GOSUB coo31: GOSUB coo2
IF tabl = 1 THEN h = h + 6 ELSE h = h + 7
NEXT jj
GOSUB coo2

IF erreurs <> 0 THEN
LOCATE 23: PRINT LL$
PSET (x(0, tabl) * 32, y(0, tabl) * 28)
FOR i = 1 TO x(11, tabl)
x = x(i, tabl) * 32: y = y(i, tabl) * 28
LINE -(x, y), rougeclair
IF couleur = 0 THEN GOSUB coo31
NEXT
er$ = " erreur": IF erreurs > 1 THEN er$ = er$ + "s."
CALL centre(23, rougeclair, "Tu as fait" + STR$(erreurs) + er$)
CALL attendre(2)
ELSE
CALL exact2(.7)
END IF
LOCATE 23: PRINT LL$: CALL entree(noir, noir)
IF erreurs > 5 THEN erreurs = 5
er = er + erreurs
NEXT boucle
re = 10 - er: IF re < 0 THEN re = 0
RETURN '++++++++++

coo2:
PUT (x - 6, y - 6), cercle, XOR
RETURN

coo31:
CIRCLE (x, y), 3, jaune, , , coef2!
RETURN

coo6: 'tirage
DO
f = 0
z(jj) = INT(RND * 15) + 1 'tirage colonne
FOR j = 1 TO jj - 1
IF z(jj) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
colonne = z(jj)

DO
f = 0
z2(jj) = INT(RND * 7) 'tirage ligne
FOR j = 1 TO jj - 1
IF z2(jj) = z2(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
ligne = z2(jj)
RETURN

coo14:
CALL centre(23, blanc, CHR$(27) + " " + CHR$(26) + " " + CHR$(24) + " " + CHR$(25) + " = déplacer " + rt$ + " = valider")
RETURN

coo0:
DO
coo11:
MouseBorder 50, 55, 320, 575
MouseShow
souris = 0
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
'matrice 14 x 8 = transforme en coord écran
'v_graph = v_mouse: h_graph = h_mouse
v_mouse = INT(v_mouse / 14) + 1
h_mouse = INT(h_mouse / 8) + 1
'LOCATE 21, 1: PRINT v_graph, h_graph'===
'LOCATE 21, 1: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF (v_mouse >= 6 AND v_mouse <= 18) AND (h_mouse >= 11 AND h_mouse <= 71) THEN
hh = 11: f1 = 0
FOR i = 1 TO 16
IF h_mouse = hh THEN
h_coord = hh: f1 = 1: EXIT FOR
END IF
hh = hh + 4
NEXT
IF f1 = 1 THEN
vv = 6: f2 = 0
FOR i = 1 TO 7
IF v_mouse = vv THEN
v_coord = vv: f2 = 1: EXIT FOR
END IF
vv = vv + 2
NEXT
END IF
IF f1 = 1 AND f2 = 1 THEN
CALL attendre(.3)
souris = 2
EXIT DO
ELSE
BEEP
END IF
END IF

IF v_mouse = 23 THEN
'fleches
IF h_mouse = 23 THEN
'gauche
valtouche = gauche
CALL attendre(.1)
souris = 1
EXIT DO
ELSEIF h_mouse = 25 THEN
'droite
valtouche = droite
CALL attendre(.1)
souris = 1
EXIT DO
ELSEIF h_mouse = 27 THEN
'haut
valtouche = haut
CALL attendre(.1)
souris = 1
EXIT DO
ELSEIF h_mouse = 29 THEN
'bas
valtouche = bas
CALL attendre(.1)
souris = 1
EXIT DO
ELSEIF h_mouse >= 46 AND h_mouse <= 58 THEN
'return
valtouche = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

MouseHide

IF souris = 2 THEN
GOSUB coo2
y = v_coord * 14: x = h_coord * 8
VIEW
PUT (x - 11, y - 12), cercle, XOR
VIEW (83, 77)-(563 + 6, 259 + 6)
y = ((v_coord - 6) / 2): x = (h_coord - 11) / 4
x = x * 32: y = y * 28
valtouche = 13
END IF

IF souris = 0 THEN
IF LEN(r$) < 2 THEN valtouche = ASC(r$) ELSE valtouche = ASC(RIGHT$(r$, 1))
END IF


IF valtouche = 50 THEN valtouche = bas
IF valtouche = 52 THEN valtouche = gauche
IF valtouche = 54 THEN valtouche = droite
IF valtouche = 56 THEN valtouche = haut

SELECT CASE valtouche
CASE gauche
xx = x - 32: yy = y
GOSUB coo2
IF xx < 0 THEN xx = 480

CASE droite
xx = x + 32: yy = y
GOSUB coo2
IF xx > 480 THEN xx = 0

CASE haut
xx = x: yy = y - 28
GOSUB coo2
IF yy < 0 THEN yy = 168

CASE bas
xx = x: yy = y + 28
GOSUB coo2
IF yy > 168 THEN yy = 0

CASE 27
CALL quitter(noir): GOSUB coo14: GOTO coo11

CASE 13
EXIT DO

CASE ELSE
BEEP

END SELECT

IF valtouche = gauche OR valtouche = droite OR valtouche = haut OR valtouche = bas THEN
x = xx: y = yy
GOSUB coo2
END IF

LOOP

RETURN

coo40:

IF ni = 1 THEN
w$ = "Avec les flèches " + CHR$(27) + " " + CHR$(26) + " " + CHR$(24) + " " + CHR$(25) + ", tu vas devoir placer"
z$ = "un petit rond sur le quadrillage à l'endroit indiqué."
CALL consigne(2, w$, z$, y$)
ELSEIF ni = 2 THEN
w$ = "Un petit rond va être affiché dans un quadrillage."
z$ = "Tu devras taper le nombre (colonne) et la lettre (ligne)."
CALL consigne(2, w$, z$, y$)
ELSE
w$ = "Plusieurs couples vont être affichés."
z$ = "Avec les flèches " + CHR$(27) + " " + CHR$(26) + " " + CHR$(24) + " " + CHR$(25) + ", tu placeras un petit rond sur le quadrillage"
y$ = "puis tu taperas " + rt$ + ". L'ordinateur tracera alors la ligne."
CALL consigne(3, w$, z$, y$)
END IF
RETURN

coo50:
SCREEN 9 ', , 1, 0 ===
VIEW: CLS
x = 320: y = 170
CIRCLE (x, y), 6, cyanclair, , , coef2!
CIRCLE (x, y), 5, cyanclair, , , coef2!
GET (x - 6, y - 6)-(x + 6, y + 6), cercle

CALL titre2(titr$)
LINE (52, 46)-(580, 262), noir, BF
COLOR blancbrill

LOCATE 5, 10
FOR j = 0 TO 9: PRINT RTRIM$(STR$(j)); " "; : NEXT j
LOCATE , POS(0) - 1
FOR j = 10 TO 15: PRINT RTRIM$(STR$(j)); " "; : NEXT j
LOCATE 6
FOR i = 0 TO 6
LOCATE , 8: PRINT " "; CHR$(65 + i); " "
PRINT
NEXT
COLOR vertclair
VIEW (78, 77)-(563, 259)
FOR y = 0 TO 182 STEP 28
LINE (0, y)-(484, y), vertclair, , &H8888
NEXT
VIEW (83, 72)-(563, 259)
FOR x = 0 TO 480 STEP 32
LINE (x, 0)-(x, 187 - 14), vertclair, , &H8888
NEXT
VIEW (83, 77)-(563 + 6, 259 + 6)
'SCREEN 9, , 1, 1===
RETURN

coo22:
IF f = 0 THEN COLOR blancbrill ELSE COLOR noir
LOCATE 22, h: PRINT "(";
COLOR cc
PRINT LTRIM$(STR$(colonne)); ","; CHR$(ligne + 65);
IF f = 0 THEN COLOR blancbrill ELSE COLOR noir
PRINT ")"
RETURN

END SUB

DEFINT A-Z
SUB moitie (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'28/10/96
DIM re$(20), s!(3), s$(3), z(5)
re = 0

'niveau
CALL Niveau(ni, 3)


FOR ii = 1 TO 5 '++++++++
CALL titre(titr$)
MouseHide
CALL niv(5, ii)

'tirage
SELECT CASE ni
CASE 1
DO
f = 0
z(ii) = INT(RND * 5) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
n = z(ii) * 2

CASE 2, 3
IF ni = 2 THEN limit = 3 ELSE limit = 5
DO
DO
DO
di = (INT(RND * limit)) * 2
LOOP WHILE di = di2
di2 = di
DO
un = (INT(RND * 5)) * 2
LOOP WHILE un = un2
un2 = un
LOOP WHILE di = 0 OR un = 0
ha = (di * 10) + un
LOOP WHILE ha = n OR ha < 20

n = ha
END SELECT

CALL cadre(7, 25, 10, 2, vert)
COLOR blancbrill, vert
LOCATE 8, 28: PRINT "Nombre"
CALL cadre(7, 44, 10, 2, vert)
COLOR blancbrill, vert
LOCATE 8, 47: PRINT "Moitié"
COLOR , bleu
LOCATE 17
FOR i = 1 TO 3
PRINT SPACE$(80)
NEXT
COLOR jaune
LOCATE 17, 40: PRINT "?"
COLOR vertclair
LOCATE 18, 28
PRINT "0"; : COLOR blanc: PRINT "├" + STRING$(10, "─") + "┴" + STRING$(10, "─") + "┤"
COLOR vertclair
LOCATE 18, 52: PRINT LTRIM$(STR$(n)); " "

CALL cadre(10, 25, 10, 4, rouge)

LOCATE 12, 28: COLOR blancbrill, rouge: PRINT n

moi1:
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")

DO
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

CALL cadre(10, 44, 10, 4, blanc)
COLOR noir, blanc
LOCATE 12, 48: PRINT "_"
LOCATE 12, 48
CALL inputgen(5, r$, 48, 57, blanc)
CALL ligne23(noir, noir)

z! = VAL(r$)
z$ = LTRIM$(STR$(z!))

IF z! >= n OR z! < 1 THEN
CALL centre(23, rougeclair, "Tu dois taper la moitié du nombre.")
CALL attendre(1.5)
GOTO moi1
END IF

empl = INT((10 / (n / 2)) * z!)

COLOR jaune, bleu
LOCATE 17, 40: PRINT "?"
LOCATE 19, 1: PRINT SPACE$(80)
COLOR vertclair: LOCATE 18, 28: PRINT "0"; : COLOR blanc
IF z! = n / 2 THEN
PRINT "├" + STRING$(10, "─") + "┴" + STRING$(10, "─") + "┤"
COLOR jaune
IF ni = 1 THEN
LOCATE 17, 41 - LEN(z$)
ELSE
LOCATE 17, 42 - LEN(z$)
END IF
PRINT z$
ELSEIF z! < n / 2 THEN
PRINT "├";
IF empl <> 0 THEN PRINT STRING$(empl, "─");
PRINT "┬" + STRING$(9 - empl, "─") + "┴" + STRING$(10, "─") + "┤"
COLOR rougeclair
LOCATE 19, 30 + empl: PRINT z$
ELSEIF z! > n / 2 THEN
PRINT "├"; STRING$(10, "─"); "┴"; STRING$(empl - 10, "─");
PRINT "┬" + STRING$(19 - empl, "─") + "┤"
COLOR rougeclair
LOCATE 19, 31 + empl: PRINT z$
END IF
COLOR vertclair
LOCATE 18, 52: PRINT LTRIM$(STR$(n))
COLOR , noir

IF z! = n / 2 THEN
CALL exact2(1)
IF cc = 0 THEN re = re + 2
EXIT DO
ELSE
IF ni = 1 THEN
CALL erreur2(.7)
ELSE
GOSUB moisol
END IF
END IF
LOOP

cc = 0

NEXT ii '+++++++

CALL resultats(re, ni, 3)

EXIT SUB

moisol:
cc = cc + 1
n$ = LTRIM$(STR$(n)): w$ = ""

IF cc = 1 THEN
w$ = n$ + " = ": GOSUB aidesol
ELSEIF cc = 2 THEN
w$ = "Solution =": GOSUB aidesol2
ELSE
BEEP
w! = n / 2: w$ = STR$(w!)
CALL centre(23, rougeclair, "Solution :" + w$)
END IF
RETURN

aidesol:
w$ = w$ + LEFT$(n$, 1)
w$ = w$ + "0 + " + RIGHT$(n$, 1)
CALL centre(23, rougeclair, w$)
RETURN

aidesol2:
s!(1) = (VAL(LEFT$(n$, 1)) * 10) / 2
s$(1) = STR$(s!(1))
s!(2) = (VAL(RIGHT$(n$, 1))) / 2
s$(2) = STR$(s!(2))

FOR i = 1 TO LEN(n$)
w$ = w$ + s$(i)
IF i < LEN(n$) THEN w$ = w$ + " +"
NEXT
CALL centre(23, rougeclair, w$)
RETURN


END SUB

DEFINT A-Z
SUB reproduction (re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur, coef1!, coef2!, nbniv)
'3/12/96 souris
DIM dessin$(15), solut$(15), x(15), y(15), x2(15), y2(15), z(5)
DIM cercle(1 TO 50) AS INTEGER

CONST gauche = 75, droite = 77
CONST haut = 72, bas = 80, hautgauche = 71, hautdroite = 73, basgauche = 79, basdroite = 81
LL$ = SPACE$(80)
re = 0

'niveau 1 6/3/94
dessin$(1) = "r100 u50 l50 u50 l100 d50 l50 u50 l50 d50 l50 d50 r50 d50 r50 d50 r150 u50 l50"
solut$(1) = "ddhghggbghgbgbdbdbdddhg"
x(1) = 200: y(1) = 100: x2(1) = 0: y2(1) = 0
dessin$(2) = "u50 r50 u50 r100 d100 r50 d100 l50 u50 l50 u50 l50 d50 l50 d50 l50 u50 l50 u150 r50 d100"
solut$(2) = "hdhddbbdbbghghgbgbghghhhdbb"
x(2) = 100: y(2) = 100: x2(2) = 0: y2(2) = 0
dessin$(3) = "l50 u150 r100 d50 l50 d50 r50 d100 r50 u100 r50 u100 r100 d50 l50 d150 r50 u100"
solut$(3) = "ghhhddbgbdbbdhhdhhddbgbbbdhh"
x(3) = 50: y(3) = 150: x2(3) = 0: y2(3) = 0
dessin$(4) = "r50 u100 l50 u50 l100 d50 r50 d50 l150 u50 l50 d150 r50 u50 r100 d50 r50"
solut$(4) = "dhhghggbdbggghgbbbdhddbd"
x(4) = 250: y(4) = 150: x2(4) = 0: y2(4) = 0
dessin$(5) = "u50 r50 d50 r50 u50 r50 d50 r100 u50 r50 d100 l50 d50 r50 d50 l150 u100 l50 d50 l50 u50 l50 d100 r50"
solut$(5) = "hdbdhdbddhdbbgbdbggghhgbghgbbd"
x(5) = 0: y(5) = 50: x2(5) = 0: y2(5) = 0

'niveau 2 = translation
dessin$(6) = "d25 r50 u25 l25 u25 l25 u75 r25 d25 r25 u50 r50 d75 r25 d50 r25 d25 l50"
solut$(6) = "bddhghghhhdbdhhddbbbdbbdbgg"
x(6) = 25: y(6) = 150: x2(6) = 50: y2(6) = -25
dessin$(7) = "u25 l25 u75 l25 d50 l25 u25 l50 d25 r25 d75 l25 u25 l25 d25 l25 d25 r125 u25"
solut$(7) = "hghhhgbbghggbdbbbghgbgbdddddh"
x(7) = 250: y(7) = 150: x2(7) = -75: y2(7) = -50
dessin$(8) = "d25 r25 d25 l50 d50 r25 u25 r25 d50 l50 d25 r100 u25 l25 u25 r25 u25 l25 u25 r50 d25 r25 u50"
solut$(8) = "bdbggbbdhdbbggbddddhghdhghddbdhh"
x(8) = 50: y(8) = 0: x2(8) = 50: y2(8) = 50
dessin$(9) = "l100 u50 r75 u25 r25 d25 r25 u25 r25 u25 l25 u25 l25 d25 l25 u25 l75 d50 l25 d75"
solut$(9) = "gggghhdddhdbdhdhghgbghgggbbgbbb"
x(9) = 150: y(9) = 150: x2(9) = 25: y2(9) = 25
dessin$(10) = "l25 d25 r25 d25 l50 u25 l25 u25 l25 d50 r25 d50 r25 u25 r25 d50 l25 d25 l25 u25 l50 u25 l50 u25 r25 u50"
solut$(10) = "gbdbgghghgbbdbbdhdbbgbghgghgghdhh"
x(10) = 250: y(10) = 25: x2(10) = -50: y2(10) = 25

'niveau 3 angle 45 6/3/94
dessin$(11) = "u50 m-50,-50 m-100,+100 d50 m+50,+50 m+50,-50 r50 m+50,+50 r50 m+50,-50 m-50,-50 m+50,-50 m-50,-50 m-50,+50 d50"
solut$(11) = "hjmmblkdldkjkjmb"
x(11) = 150: y(11) = 100: x2(11) = 0: y2(11) = 0
dessin$(12) = "m-50,-50 m-50,+50 m-50,-50 l50 m-50,+50 m+50,+50 m-50,+50 r50 m+50,-50 r50 m-50,+50 r50 m+50,-50 r50"
solut$(12) = "jmjgmlmdkdmdkd"
x(12) = 250: y(12) = 100: x2(12) = 50: y2(12) = -50
dessin$(13) = "d50 r50 m+50,-50 m-100,-100 m-100,+100 u50 m+50,-50 l100 m-50,+50 m+50,+50 m-50,+50 r50 m-50,+50 r50 m+100,-100 d100 r100"
solut$(13) = "bdkjjmmhkggmlmdmdkkbbdd"
x(13) = 200: y(13) = 100: x2(13) = 0: y2(13) = 0
dessin$(14) = "m+50,-50 m-50,-50 u50 l50 d50 l50 u50 m-50,+50 u50 m-50,+50 u50 m-50,+50 m+50,+50 m-50,+50 r50 m+50,-50 m+50,+50 u50 m+50,+50"
solut$(14) = "kjhgbghmhmhmlmdklhl"
x(14) = 250: y(14) = 150: x2(14) = 0: y2(14) = 50
dessin$(15) = "u50 m-50,+50 u100 r50 m-50,-50 r50 m+100,+100 u50 m-50,-50 r50 m+100,+100 l50 m-50,+50 l50"
solut$(15) = "hmhhdjdllhjdllgmg"
x(15) = 100: y(15) = 150: x2(15) = -50: y2(15) = 50

CALL Niveau(ni, 3)

SELECT CASE ni
CASE 1
nombre = 0
CASE 2
nombre = 5
CASE 3
nombre = 10
END SELECT
GOSUB repro40 'présentation

SCREEN 9
x = 635: y = 35
CIRCLE (x, y), 4, jaune, , , coef2!
GET (x - 4, y - 4)-(x + 4, y + 4), cercle

'++++++++++++++++++++++++++++++++++++++++++++++++
FOR jj = 1 TO 3

DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

GOSUB repro6
erreurs = 0
repro13:
IF ni = 2 THEN
x = x(choix) + 20: y = y(choix) + 55
ELSE
x = x(choix) + 10: y = y(choix) + 55
END IF

IF x2(choix) = 0 AND y2(choix) = 0 THEN
titr$ = "Reproduction"
ELSE
titr$ = "Reproduction et translation"
END IF
LOCATE 1: PRINT LL$
CALL titre2(titr$)
COLOR vertclair: IF ni < 3 THEN LOCATE 22: PRINT "Niveau"; ni: LOCATE 22, 77: PRINT 4 - jj
LINE (320, 35)-(320, 275), blancbrill
DRAW "TA0 B m=" + VARPTR$(x) + ",=" + VARPTR$(y)
DRAW "c=" + VARPTR$(jaune) + dessin$(choix)

'fenetre gauche
IF ni = 2 THEN
VIEW (20, 55)-(295, 255)
ELSE
VIEW (10, 55)-(310, 255)
END IF
coul = rougeclair: GOSUB repro1
x = x(choix): y = y(choix)
GOSUB repro2

'fenetre droite
IF ni = 2 THEN
VIEW (345, 55)-(620 + 4, 255 + 4)
ELSE
VIEW (330, 55)-(630 + 4, 255 + 4)
END IF
coul = vertclair: IF erreurs <> 0 THEN GOSUB repro1
x = x(choix) + x2(choix): y = y(choix) + y2(choix): GOSUB repro2
IF erreurs > 1 AND couleur = 1 THEN
IF ni = 2 THEN
tempx = x(choix) + 20 + 325 + x2(choix): tempy = y(choix) + 55 + y2(choix)
ELSE
tempx = x(choix) + 20 + 310 + x2(choix): tempy = y(choix) + 55 + y2(choix)
END IF
DRAW "TA0 B m=" + VARPTR$(tempx) + ",=" + VARPTR$(tempy)
DRAW "c=" + VARPTR$(rougeclair) + dessin$(choix)
END IF

GOSUB repro14
flag = 0: reponse$ = ""

IF ni = 1 THEN
GOSUB reproniveau1
ELSEIF ni = 2 THEN
GOSUB reproniveau2
ELSE
GOSUB reproniveau3
END IF

VIEW

LOCATE 22: PRINT LL$: PRINT LL$

IF solut$(choix) = reponse$ THEN
CALL exact2(1)
IF erreurs = 0 THEN re = re + 3
ELSE
erreurs = erreurs + 1
CALL centre(23, rougeclair, "Les chemins ne sont pas identiques.")
CALL attendre(1.5)
LOCATE 23: PRINT LL$: CALL centre(23, rougeclair, "Regarde")
IF ni = 2 THEN
x = x(choix) + 20 + 325 + x2(choix): y = y(choix) + 55 + y2(choix)
ELSE
x = x(choix) + 20 + 310 + x2(choix): y = y(choix) + 55 + y2(choix)
END IF
DRAW "TA0 B m=" + VARPTR$(x) + ",=" + VARPTR$(y)
DRAW "c=" + VARPTR$(rougeclair) + dessin$(choix)
CALL getinvimouse(r): IF r = 27 THEN CALL quitter(noir)
LOCATE 23: PRINT LL$: GOTO repro13
END IF

NEXT jj
'++++++++++++++++++++++++++++++++++++++

'résultats
SCREEN 0
re = re + 1
CALL resultats(re, ni, 3)

EXIT SUB
'++++++++++++++++++++++++


repro14:
IF ni = 1 OR ni = 2 THEN
CALL centre(23, blanc, CHR$(27) + " " + CHR$(26) + " " + CHR$(24) + " " + CHR$(25) + " = tracer <-- = corriger " + rt$ + " = valider")
ELSE
COLOR blanc
LOCATE 23, 23: PRINT "= tracer <-- = corriger " + rt$ + " = valider"
LOCATE 21, 10: PRINT "[7] [8] [9]"
LOCATE 22, 10: PRINT "[4] [6]"
LOCATE 23, 10: PRINT "[1] [2] [3]"
END IF
RETURN

repro1:
IF ni = 2 THEN
FOR x = 0 TO 275 STEP 25
FOR y = 0 TO 200 STEP 25
PSET (x, y), coul
NEXT y
NEXT x
ELSE
FOR x = 0 TO 300 STEP 50
FOR y = 0 TO 200 STEP 50
PSET (x, y), coul
NEXT y
NEXT x
END IF
RETURN

repro2:
PUT (x - 4, y - 4), cercle, XOR
PSET (x, y), rougeclair
RETURN

repro5:
flag = flag - 1
r$ = RIGHT$(reponse$, 1)
reponse$ = MID$(reponse$, 1, LEN(reponse$) - 1)
GOSUB repro2
IF r$ = "g" THEN
xx = x + 25: yy = y
ELSEIF r$ = "d" THEN
xx = x - 25: yy = y
ELSEIF r$ = "h" THEN
xx = x: yy = yy + 25
ELSEIF r$ = "b" THEN
xx = x: yy = yy - 25
END IF
LINE (x, y)-(xx, yy), bleu
RETURN

repro5bis:
flag = flag - 1
r$ = RIGHT$(reponse$, 1)
reponse$ = MID$(reponse$, 1, LEN(reponse$) - 1)
GOSUB repro2
IF r$ = "g" THEN
xx = x + 50: yy = y
ELSEIF r$ = "d" THEN
xx = x - 50: yy = y
ELSEIF r$ = "h" THEN
xx = x: yy = yy + 50
ELSEIF r$ = "b" THEN
xx = x: yy = yy - 50
END IF
LINE (x, y)-(xx, yy), bleu
RETURN

repro6:
'tirage
DO
f = 0
z(jj) = INT(RND * 5) + 1
FOR j = 1 TO jj - 1
IF z(jj) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
choix = z(jj) + nombre

RETURN

reproniveau1:
DO
repro11:
MouseBorder 308, 10, 320, 630
MouseShow
souris = 0
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 1: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF v_mouse >= 308 AND v_mouse <= 320 THEN
'fleches
IF h_mouse >= 100 AND h_mouse <= 112 THEN
'gauche
valtouche = gauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 116 AND h_mouse <= 128 THEN
'droite
valtouche = droite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 133 AND h_mouse <= 145 THEN
'haut
valtouche = haut
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 150 AND h_mouse <= 160 THEN
'bas
valtouche = bas
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 270 AND h_mouse <= 380 THEN
'del
valtouche = 8
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 420 AND h_mouse <= 528 THEN
'return
valtouche = 13
CALL attendre(.2)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

MouseHide


IF souris = 0 THEN
IF LEN(r$) < 2 THEN valtouche = ASC(r$) ELSE valtouche = ASC(RIGHT$(r$, 1))
END IF

IF (valtouche = 8 OR valtouche = 83) AND flag = 0 THEN BEEP: GOTO repro11
IF valtouche = 50 THEN valtouche = bas
IF valtouche = 52 THEN valtouche = gauche
IF valtouche = 54 THEN valtouche = droite
IF valtouche = 56 THEN valtouche = haut

SELECT CASE valtouche
CASE gauche
IF RIGHT$(reponse$, 1) = "d" THEN GOSUB repro5bis: GOTO repro12
xx = x - 50: yy = y
GOSUB repro2
IF xx < 0 THEN
xx = 0: BEEP
ELSE
reponse$ = reponse$ + "g"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE droite
IF RIGHT$(reponse$, 1) = "g" THEN GOSUB repro5bis: GOTO repro12
xx = x + 50: yy = y
GOSUB repro2
IF xx > 300 THEN
xx = 300: BEEP
ELSE
reponse$ = reponse$ + "d"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE haut
IF RIGHT$(reponse$, 1) = "b" THEN GOSUB repro5bis: GOTO repro12
xx = x: yy = y - 50
GOSUB repro2
IF yy < 0 THEN
yy = 0: BEEP
ELSE
reponse$ = reponse$ + "h"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE bas
IF RIGHT$(reponse$, 1) = "h" THEN GOSUB repro5bis: GOTO repro12
xx = x: yy = y + 50
GOSUB repro2
IF yy > 200 THEN
yy = 200: BEEP
ELSE
reponse$ = reponse$ + "b"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE 8, 83 'correction
GOSUB repro5bis

CASE 27
CALL quitter(noir): GOSUB repro14: GOTO repro11

CASE 13
IF reponse$ = "" THEN GOTO repro11
EXIT DO
CASE ELSE
BEEP

END SELECT
repro12:
IF valtouche = 8 OR valtouche = 83 OR valtouche = gauche OR valtouche = droite OR valtouche = haut OR valtouche = bas THEN
PSET (x, y), rougeclair
x = xx: y = yy
GOSUB repro2
END IF

LOOP

RETURN

'++++++++++++++++++++++++++++++++++
reproniveau2: 'carreau de 25
DO
repro11bis:
MouseBorder 308, 10, 320, 630
MouseShow
souris = 0
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 1: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF v_mouse >= 308 AND v_mouse <= 320 THEN
'fleches
IF h_mouse >= 100 AND h_mouse <= 112 THEN
'gauche
valtouche = gauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 116 AND h_mouse <= 128 THEN
'droite
valtouche = droite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 133 AND h_mouse <= 145 THEN
'haut
valtouche = haut
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 150 AND h_mouse <= 160 THEN
'bas
valtouche = bas
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 270 AND h_mouse <= 380 THEN
'del
valtouche = 8
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 420 AND h_mouse <= 528 THEN
'return
valtouche = 13
CALL attendre(.2)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

MouseHide


IF souris = 0 THEN
IF LEN(r$) < 2 THEN valtouche = ASC(r$) ELSE valtouche = ASC(RIGHT$(r$, 1))
END IF

IF (valtouche = 8 OR valtouche = 83) AND flag = 0 THEN BEEP: GOTO repro11bis
IF valtouche = 50 THEN valtouche = bas
IF valtouche = 52 THEN valtouche = gauche
IF valtouche = 54 THEN valtouche = droite
IF valtouche = 56 THEN valtouche = haut

SELECT CASE valtouche
CASE gauche
IF RIGHT$(reponse$, 1) = "d" THEN GOSUB repro5: GOTO repro12bis
xx = x - 25: yy = y
GOSUB repro2
IF xx < 0 THEN
xx = 0: BEEP
ELSE
reponse$ = reponse$ + "g"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE droite
IF RIGHT$(reponse$, 1) = "g" THEN GOSUB repro5: GOTO repro12bis
xx = x + 25: yy = y
GOSUB repro2
IF xx > 275 THEN
xx = 275: BEEP
ELSE
reponse$ = reponse$ + "d"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE haut
IF RIGHT$(reponse$, 1) = "b" THEN GOSUB repro5: GOTO repro12bis
xx = x: yy = y - 25
GOSUB repro2
IF yy < 0 THEN
yy = 0: BEEP
ELSE
reponse$ = reponse$ + "h"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE bas
IF RIGHT$(reponse$, 1) = "h" THEN GOSUB repro5: GOTO repro12bis
xx = x: yy = y + 25
GOSUB repro2
IF yy > 200 THEN
yy = 200: BEEP
ELSE
reponse$ = reponse$ + "b"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE 8, 83 'correction
GOSUB repro5

CASE 27
CALL quitter(noir): GOSUB repro14: GOTO repro11bis
CASE 13
IF reponse$ = "" THEN GOTO repro11bis
EXIT DO
CASE ELSE
BEEP

END SELECT
repro12bis:
IF valtouche = 8 OR valtouche = 83 OR valtouche = gauche OR valtouche = droite OR valtouche = haut OR valtouche = bas THEN
PSET (x, y), rougeclair
x = xx: y = yy
GOSUB repro2
END IF

LOOP

RETURN

reproniveau3:
DO
repro31:
MouseBorder 282, 75, 320, 630
MouseShow
souris = 0
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
' LOCATE 21, 40: PRINT v_mouse, h_mouse'===
IF lButton THEN
IF (v_mouse >= 282 AND v_mouse <= 292) AND (h_mouse >= 73 AND h_mouse <= 93) THEN
valtouche = hautgauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 282 AND v_mouse <= 292) AND (h_mouse >= 106 AND h_mouse <= 126) THEN
valtouche = haut
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 282 AND v_mouse <= 292) AND (h_mouse >= 136 AND h_mouse <= 156) THEN
valtouche = hautdroite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 296 AND v_mouse <= 306) AND (h_mouse >= 73 AND h_mouse <= 93) THEN
valtouche = gauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 296 AND v_mouse <= 306) AND (h_mouse >= 136 AND h_mouse <= 156) THEN
valtouche = droite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 310 AND v_mouse <= 320) AND (h_mouse >= 73 AND h_mouse <= 93) THEN
valtouche = basgauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 310 AND v_mouse <= 320) AND (h_mouse >= 106 AND h_mouse <= 126) THEN
valtouche = bas
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF (v_mouse >= 310 AND v_mouse <= 320) AND (h_mouse >= 136 AND h_mouse <= 156) THEN
valtouche = basdroite
CALL attendre(.2)
souris = 1
EXIT DO
END IF
'ok
IF v_mouse >= 308 AND v_mouse <= 320 THEN
IF h_mouse >= 280 AND h_mouse <= 390 THEN
'del
valtouche = 8
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 440 AND h_mouse <= 540 THEN
'return
valtouche = 13
CALL attendre(.2)
souris = 1
EXIT DO
ELSE
BEEP
END IF
END IF
END IF

LOOP WHILE r$ = ""

MouseHide

IF souris = 0 THEN
IF LEN(r$) < 2 THEN valtouche = ASC(r$) ELSE valtouche = ASC(RIGHT$(r$, 1))
END IF

IF (valtouche = 8 OR valtouche = 83) AND flag = 0 THEN BEEP: GOTO repro31
IF valtouche = 49 OR valtouche = 38 THEN valtouche = basgauche
IF valtouche = 50 OR valtouche = 130 THEN valtouche = bas
IF valtouche = 51 OR valtouche = 34 THEN valtouche = basdroite
IF valtouche = 52 OR valtouche = 39 THEN valtouche = gauche
IF valtouche = 54 OR valtouche = 45 THEN valtouche = droite
IF valtouche = 55 OR valtouche = 138 THEN valtouche = hautgauche
IF valtouche = 56 OR valtouche = 95 THEN valtouche = haut
IF valtouche = 57 OR valtouche = 135 THEN valtouche = hautdroite

SELECT CASE valtouche

CASE gauche
IF RIGHT$(reponse$, 1) = "d" THEN GOSUB repro5bis: GOTO repro32
xx = x - 50: yy = y
GOSUB repro2
IF xx < 0 THEN
xx = 0: BEEP
ELSE
reponse$ = reponse$ + "g"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE droite
IF RIGHT$(reponse$, 1) = "g" THEN GOSUB repro5bis: GOTO repro32
xx = x + 50: yy = y
GOSUB repro2
IF xx > 300 THEN
xx = 300: BEEP
ELSE
reponse$ = reponse$ + "d"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE haut
IF RIGHT$(reponse$, 1) = "b" THEN GOSUB repro5bis: GOTO repro32
xx = x: yy = y - 50
GOSUB repro2
IF yy < 0 THEN
yy = 0: BEEP
ELSE
reponse$ = reponse$ + "h"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE bas
IF RIGHT$(reponse$, 1) = "h" THEN GOSUB repro5bis: GOTO repro32
xx = x: yy = y + 50
GOSUB repro2
IF yy > 200 THEN
yy = 200: BEEP
ELSE
reponse$ = reponse$ + "b"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE hautgauche
IF RIGHT$(reponse$, 1) = "l" THEN GOSUB repro35: GOTO repro32
xx = x - 50: yy = y - 50
GOSUB repro2
IF yy < 0 OR xx < 0 THEN
IF yy < 0 THEN
yy = 0: xx = xx + 50: BEEP
ELSEIF xx < 0 THEN
xx = 0: yy = yy + 50: BEEP
END IF
ELSE
reponse$ = reponse$ + "j"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE hautdroite
IF RIGHT$(reponse$, 1) = "m" THEN GOSUB repro35: GOTO repro32
xx = x + 50: yy = y - 50
GOSUB repro2
IF yy < 0 OR xx > 300 THEN
IF yy < 0 THEN
yy = 0: xx = xx - 50: BEEP
ELSEIF xx > 300 THEN
xx = 300: yy = yy + 50: BEEP
END IF
ELSE
reponse$ = reponse$ + "k"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE basgauche
IF RIGHT$(reponse$, 1) = "k" THEN GOSUB repro35: GOTO repro32
xx = x - 50: yy = y + 50
GOSUB repro2
IF yy > 200 OR xx < 0 THEN
IF yy > 200 THEN
yy = 200: xx = xx + 50: BEEP
ELSEIF xx < 0 THEN
xx = 0: yy = yy - 50: BEEP
END IF
ELSE
reponse$ = reponse$ + "m"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE basdroite
IF RIGHT$(reponse$, 1) = "j" THEN GOSUB repro35: GOTO repro32
xx = x + 50: yy = y + 50
GOSUB repro2
IF yy > 200 OR xx > 300 THEN
IF yy > 200 THEN
yy = 200: xx = xx - 50: BEEP
ELSEIF xx > 300 THEN
xx = 300: yy = yy - 50: BEEP
END IF
ELSE
reponse$ = reponse$ + "l"
LINE (x, y)-(xx, yy)
flag = flag + 1
END IF

CASE 8, 83 'correction
r$ = RIGHT$(reponse$, 1)
IF r$ = "h" OR r$ = "b" OR r$ = "g" OR r$ = "d" THEN
GOSUB repro5bis
ELSE
GOSUB repro35
END IF

CASE 27
CALL quitter(noir): GOSUB repro14: GOTO repro31
CASE 13
IF reponse$ = "" THEN GOTO repro31
EXIT DO
CASE ELSE
BEEP

END SELECT

repro32:
IF valtouche = 71 OR valtouche = 73 OR valtouche = 79 OR valtouche = 81 OR valtouche = 8 OR valtouche = 83 OR valtouche = gauche OR valtouche = droite OR valtouche = haut OR valtouche = bas THEN
PSET (x, y), rougeclair
x = xx: y = yy
GOSUB repro2
END IF

LOOP

RETURN

repro35:
flag = flag - 1
r$ = RIGHT$(reponse$, 1)
reponse$ = MID$(reponse$, 1, LEN(reponse$) - 1)
GOSUB repro2
IF r$ = "j" THEN
xx = x + 50: yy = y + 50
ELSEIF r$ = "k" THEN
xx = x - 50: yy = y + 50
ELSEIF r$ = "m" THEN
xx = x + 50: yy = yy - 50
ELSEIF r$ = "l" THEN
xx = x - 50: yy = yy - 50
END IF
LINE (x, y)-(xx, yy), bleu
RETURN

repro40:

IF ni = 1 OR ni = 2 THEN
w$ = "Avec les flèches " + CHR$(27) + " " + CHR$(26) + " " + CHR$(24) + " " + CHR$(25) + ", tu vas reproduire un chemin."
z$ = "Attention : au niveau 2, le point de départ n'est pas au même endroit."
y$ = "Tu peux corriger tes erreurs avec la touche " + CHR$(27) + "-"
CALL consigne(3, w$, z$, y$)
ELSE
z$ = "compléter une figure."
CALL claviernumerique(z$)

END IF
RETURN

END SUB

DEFINT A-Z
SUB soustract (re, ni, rt$, gg$, titr$, pre$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'5/6/95 'niveau avec retenues

DIM un(1 TO 30) AS INTEGER
DIM deux(1 TO 30) AS INTEGER
DIM trois(1 TO 30) AS INTEGER
DIM quatre(1 TO 30) AS INTEGER
DIM cinq(1 TO 30) AS INTEGER
DIM six(1 TO 30) AS INTEGER
DIM sept(1 TO 30) AS INTEGER
DIM huit(1 TO 30) AS INTEGER
DIM neuf(1 TO 30) AS INTEGER
DIM zero(1 TO 30) AS INTEGER
DIM moins(1 TO 30) AS INTEGER
DIM curseur(1 TO 30) AS INTEGER
DIM espace(1 TO 30) AS INTEGER
DIM retenue(1 TO 30) AS INTEGER
DIM retenue2(1 TO 30) AS INTEGER

ccc = 0: cc = 0: re = 0: f = 0
IF ni = 3 THEN
n1 = 3: n2 = 2 'retenues possibles
ELSEIF ni = 4 THEN
n1 = 4: n2 = 3 'retenues possibles
END IF
SCREEN 9, , 0, 1
'mémorisation des lettres : matrice 8 x 14
x = 0: y = 0
COLOR jaune 'blancbrill
PRINT "1 2 3 4 5 6 7 8 9 0 - _ █"
GET (x, y)-(x + 7, y + 13), un
x = x + 16
GET (x, y)-(x + 7, y + 13), deux
x = x + 16
GET (x, y)-(x + 7, y + 13), trois
x = x + 16
GET (x, y)-(x + 7, y + 13), quatre
x = x + 16
GET (x, y)-(x + 7, y + 13), cinq
x = x + 16
GET (x, y)-(x + 7, y + 13), six
x = x + 16
GET (x, y)-(x + 7, y + 13), sept
x = x + 16
GET (x, y)-(x + 7, y + 13), huit
x = x + 16
GET (x, y)-(x + 7, y + 13), neuf
x = x + 16
GET (x, y)-(x + 7, y + 13), zero
x = x + 16
GET (x, y)-(x + 7, y + 13), moins
x = x + 16
GET (x, y)-(x + 7, y + 13), curseur
x = x + 16
GET (x, y)-(x + 7, y + 13), espace

LOCATE 1: PRINT SPACE$(26)

x = 3: y = 0
LINE (x, y)-(x, y + 5), blanc
LINE (x + 1, y)-(x + 1, y + 5), blanc
LINE (x - 2, y + 2)-(x, y), blanc
GET (x - 2, y)-(x + 1, y + 5), retenue
LINE (x, y)-(x, y + 5), vertclair
LINE (x + 1, y)-(x + 1, y + 5), vertclair
LINE (x - 2, y + 2)-(x, y), vertclair
GET (x - 2, y)-(x + 1, y + 5), retenue2
LOCATE 1, 1: PRINT " "

SCREEN 9, , 0, 0

FOR no = 1 TO 5 '///////////////////////

CALL titre2(titr$)
COLOR vertclair: LOCATE 22: PRINT "Niveau"; ni
LOCATE 22, 77: PRINT 6 - no

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &H20)'numérique
DEF SEG

'tirage
soustraction0:
DO
a = INT(RND * (10 ^ n1))
a$ = LTRIM$(STR$(a))
LOOP WHILE LEN(a$) <> n1
DO
B = INT(RND * (10 ^ n2))
B$ = LTRIM$(STR$(B))
LOOP WHILE LEN(B$) <> n2
IF a < B THEN GOTO soustraction0
IF ni = 2 THEN
DO
B = B - 1
B$ = LTRIM$(STR$(B))
LOOP WHILE RIGHT$(a$, 1) < RIGHT$(B$, 1)
IF LEN(B$) <> n2 THEN GOTO soustraction0
END IF

'oper posee
'1° nombre
x = 330: y = 120
FOR i = LEN(a$) TO 1 STEP -1
n = VAL(MID$(a$, i, 1))
SELECT CASE n
CASE 1
PUT (x, y), un, OR
CASE 2
PUT (x, y), deux, OR
CASE 3
PUT (x, y), trois, OR
CASE 4
PUT (x, y), quatre, OR
CASE 5
PUT (x, y), cinq, OR
CASE 6
PUT (x, y), six, OR
CASE 7
PUT (x, y), sept, OR
CASE 8
PUT (x, y), huit, OR
CASE 9
PUT (x, y), neuf, OR
CASE 0
PUT (x, y), zero, OR

END SELECT
x = x - 16
NEXT i

'2° nombre
x = 330: y = 140
FOR i = LEN(B$) TO 1 STEP -1
n = VAL(MID$(B$, i, 1))
SELECT CASE n
CASE 1
PUT (x, y), un, OR
CASE 2
PUT (x, y), deux, OR
CASE 3
PUT (x, y), trois, OR
CASE 4
PUT (x, y), quatre, OR
CASE 5
PUT (x, y), cinq, OR
CASE 6
PUT (x, y), six, OR
CASE 7
PUT (x, y), sept, OR
CASE 8
PUT (x, y), huit, OR
CASE 9
PUT (x, y), neuf, OR
CASE 0
PUT (x, y), zero, OR

END SELECT
x = x - 16
NEXT i
x = x - 16
PUT (x, y), moins, OR

LINE (x, y + 20)-(337, y + 20), vertclair

'boucle comparaison
cc = 0
r$ = LTRIM$(STR$(a - B))
l = LEN(r$)
IF l + 1 = n1 THEN r$ = "0" + r$: l = l + 1
IF l + 2 = n1 THEN r$ = "00" + r$: l = l + 2
IF l + 3 = n1 THEN r$ = "000" + r$: l = l + 3
B$ = "0" + B$
boucle = 0

x = 330: y = 170

FOR j = l TO 1 STEP -1 '++++++++++++++++++++++++

r1$ = MID$(r$, j, 1)

a1$ = MID$(a$, LEN(a$) - boucle, 1)
b1$ = MID$(B$, LEN(B$) - boucle, 1)

'traiter les retenues
IF VAL(a1$) = VAL(b1$) + VAL(r1$) THEN '1° cas : pas de retenue
CALL centre(23, blanc, "Tape la réponse")
ph$ = a1$ + " moins " + b1$ + " est égal à..."
ELSEIF VAL(a1$) + 10 = VAL(b1$) + VAL(r1$) THEN '2° cas : retenue en haut
PUT (x - 5, 118), retenue, OR
PUT (x - (16 + 5), 138), retenue2, OR
CALL centre(23, blanc, "Attention à la retenue en haut")
ph$ = LTRIM$(STR$(VAL(a1$) + 10)) + " moins " + b1$ + " est égal à..."

ELSEIF VAL(a1$) = (VAL(b1$) + 1) + VAL(r1$) THEN '3° cas : retenue en bas
CALL centre(23, blanc, "Attention à la retenue en bas")
ph$ = a1$ + " moins " + LTRIM$(STR$(VAL(b1$) + 1)) + " est égal à..."

ELSEIF VAL(a1$) + 10 = (VAL(b1$) + 1) + VAL(r1$) THEN '4° cas : 2 retenues
PUT (x - 5, 118), retenue, OR
PUT (x - (16 + 5), 138), retenue2, OR
CALL centre(23, blanc, "Attention aux 2 retenues")
ph$ = LTRIM$(STR$(VAL(a1$) + 10)) + " moins " + LTRIM$(STR$(VAL(b1$) + 1)) + " est égal à..."
END IF

soustraction1:

PUT (x, y), curseur, OR
re$ = INPUT$(1)
PUT (x, y), curseur, XOR

IF ASC(re$) = 27 THEN
CALL quitter(noir): GOTO soustraction1
END IF
IF ASC(re$) < 48 OR ASC(re$) > 57 THEN
CALL chiffres(noir): GOTO soustraction1
END IF

n = VAL(re$)
SELECT CASE n
CASE 1
PUT (x, y), un, OR
CASE 2
PUT (x, y), deux, OR
CASE 3
PUT (x, y), trois, OR
CASE 4
PUT (x, y), quatre, OR
CASE 5
PUT (x, y), cinq, OR
CASE 6
PUT (x, y), six, OR
CASE 7
PUT (x, y), sept, OR
CASE 8
PUT (x, y), huit, OR
CASE 9
PUT (x, y), neuf, OR
CASE 0
PUT (x, y), zero, OR

END SELECT

LOCATE 23, 1: PRINT SPACE$(80)
IF re$ = r1$ THEN
CALL exact2(1)
ELSE
cc = cc + 1
ccc = ccc + 1
IF ccc > 2 THEN
BEEP
CALL centre(23, rougeclair, "Solution : " + r1$)
ELSE
CALL erreur2(1)
CALL centre(23, rougeclair, ph$)
END IF
PUT (x, y), espace, OR
PUT (x, y), espace, XOR
GOTO soustraction1
END IF

boucle = boucle + 1: ccc = 0
x = x - 16
NEXT j '++++++++++++++++++++++++++++=

'resultats
COLOR ' , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
COLOR rougeclair
LOCATE 23, 32
PRINT "Tu as fait"; cc; "erreur"; : IF cc > 1 THEN PRINT "s";
PRINT "."
END IF
cc = 0

CALL getinvimouse(w)
LOCATE 23, 1: PRINT SPACE$(80)
NEXT no '++++++++++++++++++

SCREEN 0
CALL resultats(re, ni, 4)


END SUB
 

 

Précédente Accueil Remonter Suivante