tcase15.pp 1004 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. { comparsion of one-symbol strings as ranges and single cases }
  2. {$H+}
  3. var
  4. my_str: string;
  5. my_str_wide: widestring;
  6. my_str_ansi: ansistring;
  7. my_str_uni: unicodestring;
  8. i: integer;
  9. begin
  10. my_str := 'c';
  11. my_str_wide := 'c';
  12. my_str_ansi := 'c';
  13. my_str_uni := 'c';
  14. i := -1;
  15. case my_str of
  16. 'a'..'b': i := 1;
  17. 'c': i := 2;
  18. 'd'..'eee': i := 3;
  19. else i := 0;
  20. end;
  21. if (i <> 2) then begin
  22. writeln('Error');
  23. Halt(1);
  24. end;
  25. case my_str_wide of
  26. 'a'..'b': i := 1;
  27. 'c': i := 2;
  28. 'd'..'eee': i := 3;
  29. else i := 0;
  30. end;
  31. if (i <> 2) then begin
  32. writeln('Error');
  33. Halt(1);
  34. end;
  35. case my_str_ansi of
  36. 'a'..'b': i := 1;
  37. 'c': i := 2;
  38. 'd'..'eee': i := 3;
  39. else i := 0;
  40. end;
  41. if (i <> 2) then begin
  42. writeln('Error');
  43. Halt(1);
  44. end;
  45. case my_str_uni of
  46. 'a'..'b': i := 1;
  47. 'c': i := 2;
  48. 'd'..'eee': i := 3;
  49. else i := 0;
  50. end;
  51. if (i <> 2) then begin
  52. writeln('Error');
  53. Halt(1);
  54. end;
  55. end.