Informations sur: Base

Publié par as32 le 28/04/2006

Description

Une sommaire base de données avec une fonction recherche. Peut être facilement améliorée.

Code source (langage qbasic)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
DECLARE SUB Recherche ()
DECLARE SUB Nouveau ()
DECLARE SUB Aller ()
DECLARE SUB Liste ()
COMMON SHARED Fichier$
 
ON ERROR GOTO Correct       'Initialisation
 
TYPE TClient
  Numero AS INTEGER
  Prenom AS STRING * 30
END TYPE
 
 
Fichier$ = "profils.txt"
SCREEN 12
DO
  PRINT "  [N]ouveau client"
  PRINT "  [A]ller …"
  PRINT "  [L]iste"
  PRINT "  [R]echerche"
  PRINT "  [Q]uitter"
  DO
  Touche$ = UCASE$(INKEY$)
  LOOP UNTIL Touche$ <> ""
  SELECT CASE Touche$
  CASE "N"
    Nouveau
  CASE "A"
    Aller
  CASE "L"
    Liste
  CASE "R"
    Recherche
  CASE ELSE
    CLS
  END SELECT
LOOP UNTIL Touche$ = "Q"
END
 
Correct:                            'Cr&#8218;e le fichier stockant les infos s'il n'existe pas déja
SELECT CASE ERR
CASE 53
  CLOSE #1
  OPEN "Nombre.txt" FOR OUTPUT AS #1
  CLOSE #1
END SELECT
RESUME NEXT
 
SUB Aller
DIM client AS TClient
CLS
PRINT "*** Aller &#8230; un num&#8218;ro de profil ***"
PRINT
INPUT "Num&#8218;ro du profil &#8230; rechercher : ", Numero
 
OPEN Fichier$ FOR RANDOM AS #1 LEN = LEN(client)
  GET #1, Numero, client
CLOSE #1
 
PRINT "Pr&#8218;nom : ", client.Prenom
END SUB
 
SUB Liste
 
DIM client AS TClient
CLS
PRINT "*** Afficher une liste de profil ***"
PRINT
INPUT "Faire une liste du num&#8218;ro : ", a
INPUT "au num&#8218;ro : ", b
 
COLOR 12
PRINT ""
FOR Numero = a TO b
 
OPEN Fichier$ FOR RANDOM AS #1 LEN = LEN(client)
  GET #1, Numero, client
CLOSE #1
 
IF client.Numero <> 0 THEN
PRINT "", client.Numero; " --> ", client.Prenom
END IF
 
NEXT
COLOR 15
PRINT ""
 
END SUB
 
SUB Nouveau
DIM client AS TClient
CLS
PRINT "*** Cr&#8218;ation d'un nouveau profil ***"
PRINT
 
OPEN "Nombre.txt" FOR INPUT AS #1
INPUT #1, Num
CLOSE #1
 
IF Num = 0 THEN Num = 1
 
 
 
client.Numero = Num
INPUT "Pr&#8218;nom : ", client.Prenom
PRINT "Num&#8218;ro de profil : "; Num
DO
at$ = INKEY$
LOOP UNTIL (at$ <> "")
 
PRINT ""
OPEN Fichier$ FOR RANDOM AS #1 LEN = LEN(client)
  PUT #1, client.Numero, client
CLOSE #1
PRINT ""
 
Num = Num + 1
OPEN "Nombre.txt" FOR OUTPUT AS #1
PRINT #1, Num
CLOSE #1
 
END SUB
 
SUB Recherche
 
DIM client AS TClient
CLS
PRINT "*** Rechercher un profil ***"
PRINT
INPUT "Entrez le d&#8218;but du pr&#8218;nom &#8230; rechercher ", a$
nbletter = LEN(a$)
 
COLOR 12
PRINT ""
FOR Numero = 1 TO 100
 
OPEN Fichier$ FOR RANDOM AS #1 LEN = LEN(client)
  GET #1, Numero, client
CLOSE #1
 
startprofil$ = LEFT$(client.Prenom, nbletter)
 
IF startprofil$ = a$ THEN
PRINT "", client.Numero; " --> ", client.Prenom
END IF
 
NEXT
COLOR 15
PRINT ""
 
 
END SUB
 
v6 © Computaid SPRL 2005-2008 - Tous droits réservés - Hébergé par eTigris - Page générée en 0,062 s - Crédits - Stats
1 connecté