tarray6.pp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {$ifndef macos}{$APPTYPE CONSOLE}{$endif}
  2. {$ifdef fpc}{$mode delphi}{$endif}
  3. procedure wideansi;
  4. var
  5. S: AnsiString = 'abcd';
  6. pc: PChar = 'abcd';
  7. ca: array [0..4] of Char = ('a', 'b', 'c', 'd', #0);
  8. W: WideString = 'abcd';
  9. pw: PWideChar = 'abcd';
  10. wa: array [0..4] of WideChar = ('a', 'b', 'c', 'd', #0);
  11. begin
  12. {$IFDEF FPC}
  13. ca := S;
  14. ca := W;
  15. ca := pc;
  16. wa := pw;
  17. wa := S;
  18. wa := W;
  19. {$ENDIF}
  20. W := S;
  21. W := pc;
  22. W := ca;
  23. W := pw;
  24. W := wa;
  25. S := W;
  26. S := pc;
  27. S := ca;
  28. S := pw;
  29. S := wa;
  30. if S = pc then WriteLn('(2.1) strings are equal');
  31. if S = ca then WriteLn('(2.2) strings are equal');
  32. WriteLn;
  33. if W = pw then WriteLn('(3.1) wide pass');
  34. if W = wa then WriteLn('(3.2) wide pass');
  35. WriteLn;
  36. if S = W then WriteLn('(4.1) wide vs ansi');
  37. if pc = W then WriteLn('(4.2) wide vs ansi');
  38. if ca = W then WriteLn('(4.3) wide vs ansi');
  39. if pw = S then WriteLn('(4.4) wide vs ansi');
  40. if wa = S then WriteLn('(4.5) wide vs ansi');
  41. WriteLn;
  42. end;
  43. procedure wideshort;
  44. var
  45. S: ShortString = 'abcd';
  46. pc: PChar = 'abcd';
  47. ca: array [0..4] of Char = ('a', 'b', 'c', 'd', #0);
  48. W: WideString = 'abcd';
  49. pw: PWideChar = 'abcd';
  50. wa: array [0..4] of WideChar = ('a', 'b', 'c', 'd', #0);
  51. begin
  52. {$IFDEF FPC}
  53. ca := S;
  54. ca := W;
  55. ca := pc;
  56. wa := pw;
  57. wa := S;
  58. wa := W;
  59. {$ENDIF}
  60. W := S;
  61. W := pc;
  62. W := ca;
  63. W := pw;
  64. W := wa;
  65. S := W;
  66. S := pc;
  67. S := ca;
  68. S := pw;
  69. S := wa;
  70. if S = pc then WriteLn('(2.1) strings are equal');
  71. if S = ca then WriteLn('(2.2) strings are equal');
  72. WriteLn;
  73. if W = pw then WriteLn('(3.1) wide pass');
  74. if W = wa then WriteLn('(3.2) wide pass');
  75. WriteLn;
  76. if S = W then WriteLn('(4.1) wide vs ansi');
  77. if pc = W then WriteLn('(4.2) wide vs ansi');
  78. if ca = W then WriteLn('(4.3) wide vs ansi');
  79. if pw = S then WriteLn('(4.4) wide vs ansi');
  80. if wa = S then WriteLn('(4.5) wide vs ansi');
  81. WriteLn;
  82. end;
  83. begin
  84. wideshort;
  85. wideansi;
  86. end.