|
@@ -150,45 +150,45 @@ procedure pointer is
|
150
|
150
|
|
151
|
151
|
|
152
|
152
|
|
153
|
|
- function saisir2 return list is
|
154
|
|
- liste : list;
|
155
|
|
- ended : boolean := false;
|
156
|
|
- space : boolean := false;
|
157
|
|
- charac : character := ' ';
|
158
|
|
- Num: integer:=0;
|
159
|
|
- val : integer := 0;
|
160
|
|
- s : string(1..1);
|
161
|
|
- I : integer := 0;
|
162
|
|
- aux : list;
|
163
|
|
- first : boolean:= True;
|
164
|
|
-
|
165
|
|
- begin
|
166
|
|
- aux := liste; -- we set the
|
167
|
|
- while (not end_of_line) loop
|
168
|
|
- while (not space and not end_of_line) loop
|
169
|
|
- -- put_line("test");
|
170
|
|
- get(charac);
|
171
|
|
- if(charac = ' ') then ended := True; space := True;
|
172
|
|
- else
|
173
|
|
- s(1):=charac;
|
174
|
|
- val := integer'Value(s);
|
175
|
|
- -- put_Line("vous avez saisi " & charac);
|
176
|
|
- Num := Num*10+val;
|
177
|
|
- end if;
|
178
|
|
- end loop;
|
179
|
|
- space := False;
|
180
|
|
- if first then
|
181
|
|
- liste := new cell'(Num,Null);
|
182
|
|
- first:= False;
|
183
|
|
- aux := liste;
|
184
|
|
- else
|
185
|
|
- aux.all.next := new cell'(Num, Null);
|
186
|
|
- aux:= aux.all.next;
|
187
|
|
- end if;
|
188
|
|
- Num := 0;
|
189
|
|
- end loop;
|
190
|
|
- return liste;
|
191
|
|
- end saisir2;
|
|
153
|
+ function saisir2 return list is
|
|
154
|
+ Llist : list; --returned
|
|
155
|
+ ended : boolean := false; --end of first while
|
|
156
|
+ space : boolean := false; --end of second
|
|
157
|
+ charac : character := ' '; -- to get the char
|
|
158
|
+ Num: integer:=0; -- value at the end of the 2nd while
|
|
159
|
+ val : integer := 0; -- value from the char used to buid num
|
|
160
|
+ s : string(1..1); -- because ada < C and we need to use the Integer'Value on a string as there can be no cast from char to int
|
|
161
|
+ I : integer := 0;
|
|
162
|
+ aux : list; -- helper
|
|
163
|
+ first : boolean:= True; -- to mimick initialization
|
|
164
|
+
|
|
165
|
+ begin
|
|
166
|
+ aux := Llist; -- we set the helper to list
|
|
167
|
+ while (not end_of_line) loop -- check the buffer for upcoming \n
|
|
168
|
+ while (not space and not end_of_line) loop -- space is true when char = ' '
|
|
169
|
+ -- put_line("test");
|
|
170
|
+ get(charac);
|
|
171
|
+ if(charac = ' ') then ended := True; space := True;
|
|
172
|
+ else
|
|
173
|
+ s(1):=charac; -- change the char to a string for cast to int
|
|
174
|
+ val := integer'Value(s);
|
|
175
|
+ put_Line("vous avez saisi " & charac); -- visual confirmation
|
|
176
|
+ Num := Num*10+val; -- convert to base 10 value
|
|
177
|
+ end if;
|
|
178
|
+ end loop;
|
|
179
|
+ space := False; -- reset
|
|
180
|
+ if first then -- init
|
|
181
|
+ Llist := new cell'(Num,Null);
|
|
182
|
+ first:= False;
|
|
183
|
+ aux := Llist;
|
|
184
|
+ else
|
|
185
|
+ aux.all.next := new cell'(Num, Null);
|
|
186
|
+ aux:= aux.all.next;
|
|
187
|
+ end if;
|
|
188
|
+ Num := 0; --reset
|
|
189
|
+ end loop;
|
|
190
|
+ return Llist;
|
|
191
|
+ end saisir2;
|
192
|
192
|
|
193
|
193
|
|
194
|
194
|
function saisir3 return returned3 is
|