hisoft.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 2002 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. History:
  14. Made this unit to help porting from HS Pascal
  15. to fpc. Feel free to add more stuff.
  16. 09 Nov 2002.
  17. Added the define use_amiga_smartlink.
  18. 13 Jan 2003.
  19. [email protected] Nils Sjoholm
  20. }
  21. {$I useamigasmartlink.inc}
  22. {$ifdef use_amiga_smartlink}
  23. {$smartlink on}
  24. {$endif use_amiga_smartlink}
  25. unit hisoft;
  26. interface
  27. uses exec, gadtools,pastoc,amigados,intuition;
  28. type
  29. ppbyte = pointer;
  30. const
  31. NULL = 0;
  32. TRUE_ = 1;
  33. FALSE_ = 0;
  34. procedure MakeMenu(var mnm: tNewMenu;
  35. nmType: byte;
  36. nmLabel: string;
  37. nmCommKey: string;
  38. nmFlags: word;
  39. nmMutualExclude: longint;
  40. nmUserData: longint);
  41. function ptrtopas(s : pchar): string;
  42. function FExpandLock( l : BPTR): String;
  43. Function CSCPAR(rk : pRemember; s : String) : STRPTR;
  44. implementation
  45. (*
  46. * A little routine to fill in the members of a NewMenu struct
  47. *
  48. *)
  49. procedure MakeMenu(var mnm: tNewMenu;
  50. nmType: byte;
  51. nmLabel: string;
  52. nmCommKey: string;
  53. nmFlags: word;
  54. nmMutualExclude: longint;
  55. nmUserData: longint);
  56. begin
  57. mnm.nm_Type := nmType;
  58. if nmLabel <> '' then
  59. mnm.nm_Label := pas2c(nmLabel)
  60. else mnm.nm_Label := nil;
  61. if nmCommKey <> '' then
  62. mnm.nm_CommKey := pas2c(nmCommKey)
  63. else mnm.nm_CommKey := nil;
  64. mnm.nm_Flags := nmFlags;
  65. mnm.nm_MutualExclude := nmMutualExclude;
  66. mnm.nm_UserData := pointer(nmUserData);
  67. end;
  68. function ptrtopas(s : pchar): string;
  69. begin
  70. ptrtopas := strpas(s);
  71. end;
  72. function FExpandLock( l : BPTR): String;
  73. var
  74. buffer : array[0..255] of char;
  75. begin
  76. if l <> 0 then begin
  77. if NameFromLock(l,buffer,255) then FExpandLock := strpas(buffer)
  78. else FExpandLock := '';
  79. end else FExpandLock := '';
  80. end;
  81. Function CSCPAR(rk : pRemember; s : String) : STRPTR;
  82. VAR
  83. p : STRPTR;
  84. begin
  85. s := s + #0;
  86. p := AllocRemember(rk, length(s), MEMF_CLEAR);
  87. if p <> nil then
  88. move(s[1], p^, length(s));
  89. CSCPAR := p;
  90. end;
  91. end.