![]() |
![]() |
![]() |
![]() |
![]() |
FTP | ![]() |
![]() |
CCD | ![]() |
![]() |
Buscar | ![]() |
![]() |
Trucos | ![]() |
![]() |
Trabajo | ![]() |
![]() |
Foros | ![]() |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
ayuda con puntero
A continuacion explico la situacion: yo programo en pascal y siempre he utilizado punteros para trabajar con listas dinamicas, aca pongo el codigo en pascal de lo que he tratado de hacer en delphi y me da un error.
codigo en pascal el programa funciona sin problemas Program Burbujeo; Uses Crt, Printer; Type puntlista=^nodo; nodo=Record P1:real; Rs1:real; link ![]() End; Const C1=630;C2=73110;C3=-1.562;C4=141.5;C5=131.5;S1=18.2;S2=0.83;S3=0.00091; S4=0.0125;S5=1.2048;S6=0.9759;S7=0.00012;S8=1.2; Var n:Integer; Fs,Fg,T,Fs1,Fp,Pbp,Tsp,Gg,Pbk,Go,Rsb,Rs,Rss,API,Pbs,P,Pb,dec,V:Real; L,nuevo,aux ![]() hola3:Text; confirma:Boolean; Begin Clrscr; Assign(hola3,'PVT.txt'); Rewrite(hola3); Write('Temperatura del yacimiento (øF)= '); Readln(T); Writeln; Write('Gravedad espec¡fica del gas= '); Readln(Gg); Writeln; Write('Gravedad API del crudo= '); Readln(API); Writeln; Write('Relaci¢n Gas petr¢leo en soluci¢n= '); Readln(Rsb); Writeln; Go:=C4/(C5+API); Writeln; Fs:=exp(S2*ln(Rsb/Gg))*exp(((S3*T)-(S4*API))*ln(10)); Pbs:=S1*(Fs-1.4); Pb:=Pbs; Writeln('La Pb por Standing es= ',Pbs:4:2); Writeln; Writeln('La Pb es= ',Pb:4:2); Clrscr; Writeln('Deme la presion Inicial: '); Readln(P); Writeln('deme el numero de pasos: '); Readln(n); dec:=P/n; L:=nil; aux:=L; Writeln(hola3,'Presion Rs'); Writeln(hola3); While P>=14.7 do Begin new(nuevo); confirma:=False; If P>Pb Then Begin Rs:=Rsb; V:=P-dec; If V<Pb Then confirma:=True; End Else Rs:=Gg*exp(S5*ln(((P/S1)+1.4)*exp(((S4*API)-(S3*T))*ln(10)))); nuevo^.P1:=P; nuevo^.Rs1:=Rs; nuevo^.link:=nil; If L=nil Then L:=nuevo Else While aux^.link<>nil do aux:=aux^.link; aux^.link:=nuevo; If confirma=True Then Begin new(nuevo); nuevo^.P1:=Pb; nuevo^.Rs1:=Rsb; nuevo^.link:=nil; If L=nil Then L:=nuevo Else While aux^.link<>nil do aux:=aux^.link; aux^.link:=nuevo; End; P:=P-dec; End; While L<>nil do Begin If L^.P1>=1000 Then Writeln(hola3,L^.P1:4:2,' ':5,L^.Rs1:4:2); If L^.P1<1000 Then Writeln(hola3,' ',L^.P1:4:2,' ':5,L^.Rs1:4:2); L:=L^.link; End; Close(hola3); End. ahora tenemos el codigo en delphi (el .pas) unit pruebita; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; const C1=630;C2=73110;C3=-1.562;C4=141.5;C5=131.5;S1=18.2;S2=0.83;S3=0.00091; S4=0.0125;S5=1.2048;S6=0.9759;S7=0.00012;S8=1.2; type puntlista=^nodo; nodo=Record P1:real; Rs1:real; link ![]() End; type TForm1 = class(TForm) GroupBox1: TGroupBox; Button1: TButton; Button2: TButton; Button3: TButton; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; GroupBox2: TGroupBox; Edit5: TEdit; Label5: TLabel; Edit6: TEdit; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; Edit7: TEdit; Label13: TLabel; procedure Button3Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; n:real; Fs,Fg,T,Fs1,Fp,Pbp,Tsp,Gg,Pbk,Go,Rsb,Rs,Rss,API,Pbs,P,Pb,dec,V:Real; L,nuevo,aux ![]() hola3:Textfile; confirma:Boolean; implementation {$R *.dfm} procedure TForm1.Button3Click(Sender: TObject); begin Close; end; procedure TForm1.Button1Click(Sender: TObject); begin edit1.Text := ''; edit2.Text := ''; edit3.Text := ''; edit4.Text := ''; edit5.Text := ''; edit6.Text := ''; edit7.Text := ''; edit1.SetFocus; end; procedure TForm1.Button2Click(Sender: TObject); begin Assignfile(hola3,'Pruebita1.txt'); Rewrite(hola3); T:=strToFloat(edit4.Text); Gg:=strToFloat(edit3.Text); API:=strToFloat(edit2.Text); Rsb:=strToFloat(edit1.Text); Go:=C4/(C5+API); Fs:=exp(S2*ln(Rsb/Gg))*exp(((S3*T)-(S4*API))*ln(10)); Pbs:=S1*(Fs-1.4); Pb:=Pbs; edit7.Text:=FloatTostr(Pb); P:=strToFloat(edit5.Text); n:=strToFloat(edit6.Text); dec:=P/n; L:=nil; aux:=L; Writeln(hola3,'Presion Rs'); Writeln(hola3); While P>=14.7 do Begin new(nuevo); confirma:=False; If P>Pb Then Begin Rs:=Rsb; V:=P-dec; If V<Pb Then confirma:=True; End Else Rs:=Gg*exp(S5*ln(((P/S1)+1.4)*exp(((S4*API)-(S3*T))*ln(10)))); nuevo^.P1:=P; nuevo^.Rs1:=Rs; nuevo^.link:=nil; If L=nil Then L:=nuevo Else Begin While aux^.link <> nil do {aqui da el error en delphi} aux:=aux^.link; aux^.link:=nuevo; End; If confirma=True Then Begin new(nuevo); nuevo^.P1:=Pb; nuevo^.Rs1:=Rsb; nuevo^.link:=nil; If L=nil Then L:=nuevo Else Begin While aux^.link <> nil do aux:=aux^.link; aux^.link:=nuevo; End; End; P:=P-dec; End; While L<>nil do Begin If L^.P1>=1000 Then Writeln(hola3,L^.P1:4:2,' ':5,L^.Rs1:4:2); If L^.P1<1000 Then Writeln(hola3,' ',L^.P1:4:2,' ':5,L^.Rs1:4:2); L:=L^.link; End; Closefile(hola3); end; end. Los datos de entrada para correr el programa son los siguentes: temperatura: 180 gravedad especifica del gas: 0.95 Gravedad API del crudo: 31 Relacion gas petroleo en solucion: 675 Presion inicial: 4000 numero de pasos: 20 el .txt muestra los resultados generados por el programa espero me puedan ayudar |
|
|
![]() |
||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Ayuda con puntero en delphi | lmcz | Varios | 2 | 18-10-2007 19:29:51 |
Ayuda sobre crear puntero a memoria | Lambda | Varios | 1 | 30-03-2007 18:20:30 |
puntero *pantalla en c++ | coletaun | Varios | 15 | 21-07-2006 14:46:04 |
puntero a imagen | Abaddon | Gráficos | 9 | 16-06-2005 00:17:29 |
Puntero a Stream | Enan0 | Varios | 3 | 22-03-2005 22:08:13 |
![]() |
|