{I+-} и IOResult

Модераторы: Duncon, Naeel Maqsudov, Игорь Акопян, Хыиуду

Ответить
warobushek
Сообщения: 7
Зарегистрирован: 14 апр 2008, 05:52

Написал следующую функцию для ввода переменной

Код: Выделить всё

{функция защищенного ввода переменной типа word 0..65535}
function OneScan(str:string):WORD;
var
  n:WORD ;
BEGIN
  writeln(str);
 {директива компилятора, отключающая проверку ввода/вывода}
  while(1=1) do
  BEGIN
	{ fflush(stdin);очистить стандартный поток ввода         }
     {I-}
	 read(n);
     {I+}
	 if(IOresult<>0) then {IOResult проверяет, был ли последний}

     begin             {вызов функции ввода/вывода удачным}
         writeln;
		 writeln('     !!Ошибка ввода, попробуйте снова!!');
     end
	 else break;
  END;{while }

  OneScan:=n;
END;{OneScan}
Почему-то не работает(:
Скажите в чем дело?
MOTOCoder
Сообщения: 548
Зарегистрирован: 14 янв 2008, 20:27
Откуда: Россия, Псков

Во-первых, {I+} это не директива, а комментарий. Директива будет {$I+}.
Ни что так не ограничивает фантазию программиста, как компилятор...
Аватара пользователя
somewhere
Сообщения: 1858
Зарегистрирован: 31 авг 2006, 17:14
Откуда: 71 RUS
Контактная информация:

Боюсь таким образом реализовать защиту не получится, т.к. ввод целого числа уже изначально построен на реализации ввода для длинных целых (Longint) и лишь потом это число преобразуется в тип данных более низкой разрядности. Поэтому при вводе значения 100000 например в переменную Word - IOResult будет 0, т.к. это число умещается в Longint.
It's a long way to the top if you wanna rock'n'roll
lovefcs09
Сообщения: 6
Зарегистрирован: 12 июн 2008, 11:21

3.5 Problems occurred in the arrangement of the compositionLook at the following composition selected from students’ writing:Should Students Take a Part Time Job or Not silkroad online goldIn recent years, taking part-time job is very popular on the campus, more and more students spend more time taking part-time job, and this phenomenon causes a lot of hot argument, is it right or not? In my opinion, we can’t say it is right or wrong directly, because the reason is complex. On the other hand, many students take part-time job in order to reduce the burden of their families because their families have not enough money to support them. So their action is reasonable. We can not say it is not right, as to those students whose families are not very poor, some of them taking part-time job just want to practice in the society and gain some experience. Earning money is not their main purpose; we cannot say it is right, either.It is not conformed to the Standard English writing. Firstly, in the above text, there is no definite idea. We cannot get the author’s attitude after reading the text. In this sense, this composition is a failure. To English-speaking people they tend to choose one aspect to illustrate. Secondly, the whole text just has one paragraph. Generally speaking, an English composition consists of three parts: the introductory paragraph, the body and the conclusion. So the text should be rewritten as the following:maple story goldIn recent years, taking part-time job is very popular on the campus. More and more students spend more time taking part-time jobs. This phenomenon causes a lot of hot argument. Is it right or not? In my opinion, it is right based on the following reasons.FFXI GilFirstly, they can reduce the burden of their families, because their families just cannot afford the tuition. In addition, where their life expenditure comes from? Considering this, many students may choose to take part-time jobs to reduce their financial pressure.dofus kamasSecondly, by taking part-time jobs, students could gain more social experience. Knowledge is a treasure, but practice is the key to it. There is always some gap between what we know from textbooks and what we can do in the real world, and social practice helps us build the bridge over it. If you are a qualified student, working as a private teacher will enable you to test out the theories acquired in classroom and to guide you to make your own discoveries. From the above mentioned, we can see that taking part-time jobs has many advantages. It is beneficial to the college students. So do not hesitate, join in the line!The rewritten text is clearer than the original one, after reading the above text. We can easily understand the author’s opinion with sufficient supporting arguments. In addition, the text is fully conformed to the three-part model of English writing.world of warcraft gold
Ответить