Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Code Help

funkymonkeyfunkymonkey Posts: 1Member
Hi, i have done a procedure but when i execute and it ends, my program exit and doesn't execute the rest of the code, and i don't know why. If anyone find the mistake or the solution please post it
THANKSS!!

these are the types:

Telemento=char;
PTNodo=^TNodo;
TLista = PTNodo;

TNodo=RECORD
elemento:Telemento;
siguiente:TLista;
End;

TProd = ^TProduccion;
TListaP = TProd;
TProd2 = RECORD
izq:TLista;
der:TLista;
end;

TProduccion = RECORD
prod:TProd2;
sig: TProd;
end;

And this is the procedure:
[code]
procedure simbolos_innecesarios (var listaP:TlistaP);
var
aux:TlistaP;
aux3:Tlista;
izq:char;
der:string;
begin
der:='';
aux:=listaP;
aux3:=aux^.prod.der;
while (aux<>NIL) do
begin
izq:=' ';
der:='';
izq:=aux^.prod.izq.elemento;
while (aux3<>nil) do begin
der:=der+aux3^.elemento;
aux3:=aux3^.siguiente;
end;
if izq=der then begin
borrarlistaP(listaP,aux^.prod.izq^.Elemento,aux^.prod.der^.elemento);
aux:=listaP;
end;
aux:=aux^.sig;
aux3:=aux^.prod.der;
end;
end;
[/code]

Comments

  • Phat NatPhat Nat Posts: 757Member
    I can't tell from this code. Try stepping through your code (or put a break at the procedure start) and see if it actually gets to the last statement in the procedure. If it gets to the end, then doesn't return to to code that called it, you probably forgot to initialize a pointer and are assigning a value to a nil pointer.

    If you still can't find it, post at least the code surrounding the procedure call.

    Phat Nat
    [code]
    : procedure simbolos_innecesarios (var listaP:TlistaP);
    : var
    : aux:TlistaP;
    : aux3:Tlista;
    : izq:char;
    : der:string;
    : begin
    : der:='';
    : aux:=listaP;
    : aux3:=aux^.prod.der;
    : while (aux<>NIL) do
    : begin
    : izq:=' ';
    : der:='';
    : izq:=aux^.prod.izq.elemento;
    : while (aux3<>nil) do begin
    : der:=der+aux3^.elemento;
    : aux3:=aux3^.siguiente;
    : end;
    : if izq=der then begin
    : borrarlistaP(listaP,aux^.prod.izq^.Elemento,aux^.prod.der^.elemento);
    : aux:=listaP;
    : end;
    : aux:=aux^.sig;
    : aux3:=aux^.prod.der;
    : end;
    : end;
    [/code]:
Sign In or Register to comment.