summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/amunits/src/utilunits/hisoft.pas
blob: e30fd35a7d23ce75789e5129223b54dd3bb94690 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
    This file is part of the Free Pascal run time library.

    A file in Amiga system run time library.
    Copyright (c) 2002 by Nils Sjoholm
    member of the Amiga RTL development team.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

 {
        History:

        Made this unit to help porting from HS Pascal
        to fpc. Feel free to add more stuff.
        09 Nov 2002.

        Added the define use_amiga_smartlink.
        13 Jan 2003.
        nils.sjoholm@mailbox.swipnet.se Nils Sjoholm
}

{$I useamigasmartlink.inc}
{$ifdef use_amiga_smartlink}
    {$smartlink on}
{$endif use_amiga_smartlink}

unit hisoft;

interface

uses exec, gadtools,pastoc,amigados,intuition;

type
    ppbyte = pointer;

const
    NULL = 0;
    TRUE_ = 1;
    FALSE_ = 0;

procedure MakeMenu(var mnm: tNewMenu;
        nmType: byte;
        nmLabel: string;
        nmCommKey: string;
        nmFlags: word;
        nmMutualExclude: longint;
        nmUserData: longint);

function ptrtopas(s : pchar): string;
function FExpandLock( l : BPTR): String;
Function CSCPAR(rk : pRemember; s : String) : STRPTR;

implementation


(*
 * A little routine to fill in the members of a NewMenu struct
 *
 *)
procedure MakeMenu(var mnm: tNewMenu;
        nmType: byte;
        nmLabel: string;
        nmCommKey: string;
        nmFlags: word;
        nmMutualExclude: longint;
        nmUserData: longint);
begin
        mnm.nm_Type := nmType;
        if nmLabel <> '' then
           mnm.nm_Label := pas2c(nmLabel)
        else mnm.nm_Label := nil;
        if nmCommKey <> '' then
           mnm.nm_CommKey := pas2c(nmCommKey)
        else mnm.nm_CommKey := nil;
        mnm.nm_Flags := nmFlags;
        mnm.nm_MutualExclude := nmMutualExclude;
        mnm.nm_UserData := pointer(nmUserData);
end;

function ptrtopas(s : pchar): string;
begin
   ptrtopas := strpas(s);
end;

function FExpandLock( l : BPTR): String;
var
   buffer : array[0..255] of char;
begin
   if l <> 0 then begin
      if NameFromLock(l,buffer,255) then FExpandLock := strpas(buffer)
      else FExpandLock := '';
   end else FExpandLock := '';
end;

Function CSCPAR(rk : pRemember; s : String) : STRPTR;
VAR
        p : STRPTR;

begin
  s := s + #0;
  p := AllocRemember(rk, length(s), MEMF_CLEAR);
  if p <> nil then
        move(s[1], p^, length(s));
  CSCPAR := p;
end;

end.