/test/language/unclassified/uw/aux_uw01extra_io.e

http://github.com/tybor/Liberty · Specman e · 104 lines · 72 code · 10 blank · 22 comment · 2 complexity · 63129c633d445053e77937dc14597c3c MD5 · raw file

  1. note
  2. description:
  3. "extended I/O"
  4. status:
  5. "See notice at end of class"
  6. author:
  7. "Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>"
  8. version:
  9. "$Revision$"
  10. last_modification:
  11. "$Date$"
  12. class AUX_UW01EXTRA_IO
  13. create {ANY}
  14. make
  15. feature {ANY}
  16. make
  17. -- make new object
  18. do
  19. create {AUX_UW01PREFERRED_LANGUAGE} language
  20. end
  21. feature {ANY} -- Input
  22. read_string (prompt: STRING)
  23. -- print `prompt' and get a string
  24. require
  25. valid_prompt: prompt /= Void
  26. do
  27. io.put_string(prompt)
  28. io.read_line
  29. last_string := io.last_string
  30. last_string.right_adjust
  31. last_string.left_adjust
  32. ensure
  33. last_string /= Void
  34. end
  35. read_yes_no (prompt: STRING)
  36. -- print `prompt' and get a string to
  37. -- `last_string' and also set `last_boolean'
  38. require
  39. valid_prompt: prompt /= Void
  40. local
  41. input: CHARACTER
  42. do
  43. from
  44. until
  45. input = language.yes_character or else input = language.no_character
  46. loop
  47. read_string(prompt)
  48. if last_string.count > 0 then
  49. input := last_string.item(1)
  50. end
  51. end
  52. last_boolean := input = language.yes_character
  53. ensure
  54. last_string /= Void
  55. end -- read_string
  56. last_string: STRING
  57. last_boolean: BOOLEAN
  58. feature {ANY} -- Output
  59. print_multi (objects: ARRAY[STRING])
  60. -- print all elements in `objects' as string
  61. local
  62. i: INTEGER
  63. do
  64. from
  65. i := objects.lower
  66. until
  67. i > objects.upper
  68. loop
  69. io.put_string(objects.item(i).out)
  70. i := i + 1
  71. end
  72. end
  73. feature {}
  74. language: AUX_UW01LANGUAGE -- language to use
  75. invariant
  76. good_language: language /= Void
  77. end -- class AUX_UW01EXTRA_IO
  78. -- Copyright (C) 1998-2017: by Ulrich Windl
  79. -- Copyright (C) 1998-2017: by Klinikum der Universität Regensburg,
  80. -- D-93042 Regensburg
  81. --
  82. -- This program is free software; you can redistribute it and/or modify
  83. -- it under the terms of the GNU General Public License as published by
  84. -- the Free Software Foundation; either version 2 of the License, or
  85. -- (at your option) any later version.
  86. --
  87. -- This program is distributed in the hope that it will be useful,
  88. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  89. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  90. -- GNU General Public License for more details.
  91. --
  92. -- You should have received a copy of the GNU General Public License
  93. -- along with this program; if not, write to the Free Software
  94. -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA