@marcos1598 escreveu:
Estou desenvolvendo um simples software em pascal, mas ao copilar o meu programa, ele deu o seguinte erro:
"unit1.pas(28,46) Fatal: Syntax error, ":" expected but ";" found".
Segue o meu código fonte
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type { TVenda } TVenda = class(TForm) Button1: TButton; Button2: TButton; Label2: TLabel; txtVenda: TEdit; txtCusto: TEdit; txtLucro: TEdit; Label1: TLabel; Label3: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { private declarations } function CalculaVenda(cCUSTO,cLUCRO : string) : String; function AchaLucro(cVENDA,cCUSTO :String); public { public declarations } end; var Venda: TVenda; implementation {$R *.lfm} {Acha preço de venda (Custo * (Lucro/100) + Custo} function TVenda.CalculaVenda(cCUSTO,cLUCRO : string) : String; var nCUSTO, nLUCRO, nVENDA : real; begin try nCUSTO:=strtofloat(cCUSTO); except nCUSTO:= 0 end; try nLUCRO:=strtofloat(cCUSTO); except nLUCRO:= 0 end; nVENDA := ((nCUSTO * (nLUCRO/100)) +nCUSTO); result := floattostr (nVENDA); end; { TVenda } procedure TVenda.Button1Click(Sender: TObject); begin txtVenda.Text := CalculaVenda(txtCusto.Text,txtLucro.Text); end; function TVenda.AchaLucro(cVENDA,cCUSTO):String; {Acha %((Venda - Custo)/ Custo) * 100} var nCUSTO, nLUCRO, nVENDA : real; begin try nCUSTO:=strtofloat(cCUSTO); except nCUSTO:= 0 end; try nVENDA:=strtofloat(cVENDA); except nVENDA:= 0 end; nLUCRO := ((nVENDA - nCUSTO) / nCUSTO) * 100; Result := Floattostr (nVENDA); end; procedure TVenda.Button2Click(Sender: TObject); end; end.
Mensagens: 1
Participantes: 1