tcnvstr2.pp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. {****************************************************************}
  4. { NODE TESTED : secondtypeconvert() -> second_cstring_to_pchar }
  5. {****************************************************************}
  6. { PRE-REQUISITES: secondload() }
  7. { secondassign() }
  8. { secondtypeconv() }
  9. {****************************************************************}
  10. { DEFINES: }
  11. { FPC = Target is FreePascal compiler }
  12. {****************************************************************}
  13. { REMARKS: }
  14. { }
  15. { }
  16. { }
  17. {****************************************************************}
  18. {$H-}
  19. const
  20. StrConst = 'HELLO WORLD';
  21. AnsiConst = 'COCORICCO!';
  22. AnsiConst2 = '';
  23. procedure testcstring2pcharone;
  24. var
  25. p1 : pchar;
  26. begin
  27. WriteLn('(left) : LOC_MEM; (right) : LOC_MEM');
  28. p1 := pchar(strconst);
  29. WriteLn('Value should be ''HELLO WORLD''...',p1);
  30. end;
  31. { source: }
  32. { LOC_REFERENCE, LOC_MEM }
  33. { destination: }
  34. var
  35. p: pchar;
  36. Begin
  37. WriteLn('------------------- STRING/PCHAR ------------------------');
  38. WriteLn('(left) : LOC_MEM; (right) : LOC_MEM');
  39. { LOC_MEM -> LOC_MEM test }
  40. { SHORTSTRING -> PCHAR }
  41. p := pchar(strconst);
  42. WriteLn('Value should be ''HELLO WORLD''...',p);
  43. testcstring2pcharone;
  44. WriteLn('------------------- ANSI/PCHAR ------------------------');
  45. WriteLn('(left) : LOC_MEM; (right) : LOC_MEM');
  46. p:=pchar(ansistring(ansiconst));
  47. WriteLn('Value should be ''COCORICCO!''...',p);
  48. p:=pchar(ansistring(ansiconst2));
  49. WriteLn('Value should be ''''...',p);
  50. End.