o2rtlb1.pas 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. program testread;
  2. {uses crt;}
  3. var
  4. cadena,cadena2 : string;
  5. number : real;
  6. begin
  7. {clrscr;}
  8. cadena2 := 'Previous string';
  9. write ('Enter the string ');
  10. readln (cadena);
  11. writeln ('You entered ',cadena);
  12. writeln ('Previous string was ',cadena2);
  13. write ('Enter a number ');
  14. readln (number);
  15. writeln ('Number entered was ',number);
  16. readln;
  17. end.
  18. {(I have retyped now because my computer is not connected to the net, but I
  19. think that there are no errors).
  20. Now you can do some tests:
  21. 1- Compile and run the program as is (that is, using crt). You will find that
  22. a) the program does not erase the screen (that is normal because we have
  23. commented clrscr), but the cursor goes to the first line, thus overwriting the
  24. screen.
  25. b) While the program is expecting the string to be entered, some of the keys
  26. do not work correctly: Backspace advances some spaces (just like tab), tab key
  27. does not work and the cursor keys write garbage. (however this is only in the
  28. screen, because if you have erased a part of the string it will be actually
  29. erased).
  30. c) Once you have press return, the message 'You entered...' appears in the
  31. same line as the text entered.
  32. 2- Uncomment the clrscr call, cokpile and execute. Point a of test 1 will be
  33. solved (the screen is erased, so nothing is overwritten), but points b and c
  34. persist.
  35. 3- Comment 'uses crt' and 'clrscr'. Now you will not be using crt. Now:
  36. a) Point a of test 1 does not appear: the program begins to write in the
  37. next line, it does not overwrite anything.
  38. b) Now all the keys (tab, backspace..) work as expected.
  39. c) Now the message 'You entered...' appears in the following line, so point
  40. c of test 1 is also solved.
  41. d) BUT it writes only 'You entered', WITHOUT writing the string cadena (!).
  42. It writes also 'Previous string was previous string', so the problem is in
  43. readln and not in writeln.
  44. 4- To see if the problem is only in the string vars, uncomment the definition
  45. of number, and also the three lines at the end that deal with number. Now ld
  46. gives the following error message:
  47. testread.pp:0 (testread.o): undefined symbol READ_TEXT_INTEGER referenced from
  48. text segment.
  49. This error happens with 'uses crt' and also without it.
  50. 5- Define number as word. Regardless of crt we get the following error from ld:
  51. testread.pp:0 (testread.o): undefined symbol READ_TEXT_WORD referenced from
  52. text segment.
  53. 6- Uncomment 'uses crt' if it was commented, and change the definition of
  54. number as real. The program will compile, and it will print the number,
  55. although in the same line as the input.
  56. 7- Finally, comment 'uses crt' again. This time it will also compile and link,
  57. but it gives a runtime error!
  58. Laufzeitfehler 106 bei 66422
  59. This error is shown before printing the number.
  60. I expect that these bug report will be useful to debug the RTL. Tonight I will
  61. try to work in the blockwrite problem.
  62. Best regards
  63. Ramon
  64. --
  65. }