Arsip: help: freepascal code to delphi

 
user image
more 16 years ago

rahadian

Ada yang bisa membantu ,dibawah ini adalah kode yang saya coba untuk konversi dari hexa ke desimal. aku coba kompile dengan lazarus (freepascal) dapat berjalan dengan baik tetapi tidak untuk delphi 2006
unit
  convert;
interface
  function HexToDec (Hexadecimal: string): cardinal;
implementation
uses
  SysUtils;
function HexToDec (Hexadecimal: string): cardinal;
var
  I: cardinal;
  Koef: Integer;
  Hex: string [8];
const
  HexaChars = '123456789ABCDEF';
begin
  Hex:=UpperCase (Hexadecimal);
  Koef:=1;
  HexToDec:=0;
  for I:=1 to Length (Hex) do
  begin
    Inc (HexToDec,Koef  Pos(Hex[Length(Hex)-I+1],HexaChars));
    Koef:=Koef 16;
  end;
end;
end.
dibaris Inc (HexToDec,Koef * Pos(Hex[Length(Hex)-I+1],HexaChars)); keluar error message not enough actual parameter apa ada yang bisa membantu??
user image
more 16 years ago

mas_kofa

kalo delphi 6 delphi7 tuh ada fungsi bawaan IntToHex.... untuk HexToInt bisa pake fungsi StrToInt , contoh :

procedure TForm1.FormCreate(Sender: TObject);
begin
  caption := inttostr(strtoint('$AA'));
end;
hasil = 170; gmn mas???
user image
more 16 years ago

rahadian

thx 4 the quick reply :D akan tetapi yang saya tanyakan disini adalah apakah ada ketidakcocokan penulisan kode tersebut pada delphi dengan lazarus yang menggunakan freepascal
user image
more 16 years ago

mas_kofa

gak tau aku gak pernah pake lazarus ato freepascal
user image
more 16 years ago

MrLee

mas rahadian
dibaris Inc (HexToDec,Koef * Pos(Hex[Length(Hex)-I+1],HexaChars)); keluar error message not enough actual parameter
HexToDec jgn di pakai seperti itu; klu di pascal memang u/ memngembalikan nilai function; tapi tidak bisa u/ Inc() nya coba di ubah jadi variable terus; baru hasilnya di letakkan di result := semoga terbantu
user image
more 16 years ago

MrLee

mungkin di ubah seperti ini jika mau;

function HexToDec (Hexadecimal: string): cardinal;
  var
    I, hit: cardinal;
    Koef: Integer;
    Hex: string [8];
  const
    HexaChars = '123456789ABCDEF';
  begin
    Hex:=UpperCase (Hexadecimal);
    Koef:=1;
    Hit:=0;
    for I:=1 to Length (Hex) do
    begin
      Inc(Hit,Koef  Pos(Hex[Length(Hex)-I+1],HexaChars));
      Koef:=Koef 16;
    end;
    result := hit;
  end;
user image
more 16 years ago

muktaf

tinggal penyesuaian aja sih dari delphi ke freepascal...
user image
more 16 years ago

rahadian

aku lakukan seperti yang MrLee anjurkan,dan kini dapat dicompile thnx :)
user image
more 16 years ago

MrLee

Sama - Sama; sering post dong di sini; tentang freePsacal nya; biar kita bisa tahu juga :D
more ...
  • Pages:
  • 1
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com