Bonjour,
Je suis nouveau sur le forum. Je pense que je publie dans la bonne categorie.
Je suis programmeur amateur.
J'essai de transcrire un programme du basic apple ii en qbasic mais j'ai un souci avec l'instruction next qui se trouve juste derriere un then.
Ce programme je l'ai recuperer dans la revue micro systeme No 44 ; il a ete creer par Philippe Larvet.
Je vous joint le listing et le fichier.
Question : quelqu'un pourrait il m'aider a transcrire le programme en qbasic.
Merci de votre aide.
Listing :
10 '===========================
20 ' Base de connaissances relationnelle
40 ' Interrogeable en langage naturel
50 '
54 ' Auteur
60 ' Philippe Larvet
70 ' Copyright 1984
80 '
90 CLS
100 np = 4' Nombre de place dans la base de connaissance
105 nm = 50' Nombre maxi de tiroir . Peut etre modifier en fonction de la taille memoire disponible
110 DIM b$(nm, np + 1)' Table de la base
120 DIM c$(np) ' mot signifiant extrait de l'assertion
130 DIM e$(50) ' Table des mots non signifiant
140 DIM s(nm, 2)' Contient pour chaque tiroir, le nombre de mots signifiant de l'assertion
150 nt = 0' Nombre de tiroir occupes
270 '
280 ' mots non-signifiants
290 '
300 ne = 0
310 READ a$
320 IF a$ = "FF" THEN GOTO 1000
330 ne = ne + 1: e$(ne) = a$
340 GOTO 310
400 DATA EST,LE,LA,DE,UN,UNE
410 DATA L,DU,D,LES,DES
412 DATA QU,QUE,QUI,SONT
414 DATA EN,OU,COMMENT,AU
420 DATA QUOI,C,CE,QUEL,QUELLE
430 DATA IL,ELLE,A,T,Y,FF
970 '
980 ' entree
990 '
1000 PRINT : ni = 0
1010 INPUT "A vous : "; a$
1020 l = LEN(a$)
1470 '
1480 ' examen de l'entree
1490 '
1500 IF LEFT$(a$, 1) = "-" THEN GOTO 11000
1510 IF a$="???" then goto 10000
1520 IF RIGHT$(a$, 1) <> "?" THEN GOTO 1990
1530 a$ = LEFT$(a$, l - 1)
1540 ni = 1
1970 '
1980 ' extraction des mots
1990 '
2000 FOR k = 2 TO np
2010 c$(k) = ""
2020 NEXT k
2030 l = LEN(a$): h$ = ""
2040 n = 1: nd = 0: j = 1
2100 i = j
2120 j = j + 1
2122 g$ = MID$(a$, j, 1)
2130 IF g$ <> " " AND g$ <> "'" AND g$ <> "-" AND j <= l THEN GOTO 2120
2132 f$ = MID$(a$, i, j - i)
2133 IF i = 1 AND LEFT$(f$, 2) = "QU" THEN n = 0
2135 FOR k = 1 TO ne
2136 IF e$(k) <> f$ THEN NEXT k
2138 IF k <= ne THEN GOTO 2160
2140 nd = nd + 1
2142 IF nd > np THEN GOTO 3500
2150 h$ = h$ + f$: c$(nd) = f$
2152 IF nd = 1 THEN j1 = j
2160 IF j > l THEN GOTO 2990 '3000
2170 j = j + 1
2180 IF MID$(a$, j, 1) = " " AND j <= l THEN GOTO 2170
2200 IF j <= l THEN GOTO 2100
2970 '
2980 ' Fin extraction
2990 '
3010 IF ni > 0 THEN GOTO 6000
3020 IF nd > 1 THEN GOTO 4000
3470 '
3480 ' Erreur
3490 '
3500 PRINT "** Je ne comprends pas **"
3510 GOTO 1000
3900 '
3910 ' Assertion
3920 '
3980 ' Controle existance assertion dans la base
3990 '
4000 IF nt = 0 THEN GOTO 5000
4100 FOR i = 1 TO nt
4110 z$ = ""
4120 FOR j = 1 TO np
4130 z$ = z$ + b$(i, j)
4140 NEXT j
4150 IF z$ <> h$ THEN NEXT i
4160 IF i > nt THEN GOTO 5000
4170 '
4180 ' Assertion deja connue
4190 '
4200 PRINT "** Assertion deja connue ! **"
4210 GOTO 1000
4970 '
4980 ' Enrichissement base
4990 '
5000 FOR i = 1 TO nm
5010 IF b$(i, 1) <> "" THEN NEXT i
5020 IF i <= nm THEN GOTO 5050
5030 PRINT "** STOP ! la base est pleine ! **"
5040 STOP
5050 FOR j = 1 TO np
5052 b$(i, j) = c$(j)
5054 NEXT j
5056 b$(i, np + 1) = a$
5058 s(i, 1) = nd: s(i, 2) = j1
5060 PRINT "** Compris **"
5070 IF i > nt THEN nt = i
5080 GOTO 1000
5970 '
5980 ' Interrogation
5990 '
5992 ' Controle existence de chacun des mots
5996 '
6000 k = 0: m = nt
6010 t = 0: k = k + 1
6100 FOR i = 1 TO nt
6110 FOR j = 1 TO s(i, 1)
6120 IF b$(i, j) <> c$(k) THEN NEXT j
6130 IF j > s(i, 1) THEN GOTO 6180
6132 t = 1
6140 IF nd > 1 THEN GOTO 6170
6142 IF j = 2 AND l > LEN(c$(k)) + 1 THEN GOTO 6162
6150 PRINT b$(i, np + 1)
6160 GOTO 6180
6162 PRINT LEFT$(b$(i, np + 1), s(i, 2))
6164 GOTO 6180
6170 a = i: i = nt
6180 ' Mot suivant
6190 NEXT i
6200 IF t = 0 THEN GOTO 9000
6210 IF nd = 1 THEN GOTO 1000
6220 IF a < m THEN m = a
6230 IF k < nd THEN GOTO 6010
6970 '
6980 ' Relation horizontale
6990 '
7000 v = 0
7010 FOR i = m TO nt
7020 t = 0: k = 0: j = 0
7030 k = k + 1
7040 IF k > nd THEN GOTO 7300
7050 j = j + 1
7060 IF j > s(i, 1) THEN GOTO 7200
7070 IF b$(i, j) <> c$(k) THEN GOTO 7050
7080 t = t + 1
7090 IF t = 1 THEN GOTO 7030
7100 GOTO 7030
7200 IF t = 0 THEN GOTO 7400
7300 IF t <> nd OR t <> s(i, 1) THEN GOTO 7330
7310 PRINT " Oui ": v = 1: i = nt
7320 GOTO 7400
7330 IF t <> nd THEN GOTO 7400
7340 v = 1
7350 IF p = 2 THEN GOTO 7380
7360 PRINT b$(i, np + 1)
7370 GOTO 7400
7380 PRINT LEFT$(b$(i, np + 1), s(i, 2))
7400 NEXT i
7410 IF v = 1 THEN GOTO 1000
7970 '
7980 ' liaison inexistante ou inversee
7990 '
8000 ' Composition de fonctions
8001 IF n = 0 THEN GOTO 8010
8002 PRINT " Non "
8004 GOTO 1000
8010 PRINT " Je l'ignore "
8070 GOTO 1000
8970 '
8980 ' Mot inconnu
8990 '
9000 PRINT "** Je ne connais pas "; "--> "; c$(k); " <-- **"
9020 GOTO 1000
9900 '
9910 ' Commandes de service
9920 '
9980 ' Listage de la base
9990 '
10000 FOR i = 1 TO nt
10010 PRINT i; " "; b$(i, np + 1)
10020 NEXT i
10030 GOTO 1000
10970 '
10980 ' Suppression
10990 '
11000 '
11004 '
11008 i = VAL(RIGHT$(a$, l - 1))
11010 FOR j = 1 TO np + 1
11020 b$(i, j) = ""
11030 NEXT j
11040 PRINT "** Assertion "; i; " supprimee **"
11050 GOTO 1000
AppleIIN44.rar
Partager