User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 391,601 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,606 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:

txt files in pascal

Join Date: Jun 2006
Location: Blumenau, Brazil
Posts: 67
Reputation: Micheus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 4
Micheus's Avatar
Micheus Micheus is offline Offline
Junior Poster in Training

Re: txt files in pascal

  #3  
May 14th, 2008
Originally Posted by Olsi009 View Post
BUT when i run the program i wrote it just gets stuck!
Olsi009, start with this changes:
  1. Procedure Kontrollo_listen(Var l:fjale;fj2:str);
  2. Var tmp,tmp2,koka:fjale; c:boolean;
  3. Begin
  4. c:=False;
  5. tmp:=l; koka:=l;
  6. If tmp=nil then
  7. Begin
  8. new(tmp2);
  9. tmp2^.fjala:=fj2;
  10. tmp2^.den:=1;
  11. tmp2^.tjetri:=tmp;
  12. // tmp:=tmp2;
  13. l:=tmp;
  14. // dispose(tmp2);
  15. End
  16. else
  17. Begin
  18. while (tmp<>nil) and (not c) do
  19. // while tmp<>nil do
  20. Begin
  21. If tmp^.fjala=fj2 then
  22. Begin
  23. tmp^.den:=tmp^.den+1;
  24. c:=true;
  25. End;
  26. tmp:=tmp^.tjetri;
  27. End;
  28. End;
  29. If c=false then
  30. Begin
  31. new(tmp2);
  32. tmp2^.fjala:=fj2;
  33. tmp2^.den:=1;
  34. tmp2^.tjetri:=koka;
  35. l:=tmp2; // use this
  36. // koka:=tmp2;
  37. // l:=koka;
  38. // dispose(tmp2);
  39. End;
  40. End;
You cannot call dispose after have allocated memory that you still will use - You will use than until your program has finished. So, you will need to write a procedure in order to free allocated memory at end of your program - don't forget it.

Bye
"It always has, at least, two ways to make one same thing. Exactly that they are certain and wrong"(Micheus)

Brazil - Blumenau
Reply With Quote  
All times are GMT -4. The time now is 11:50 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC