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 455,973 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 3,819 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: Programming Forums
Views: 2759 | Replies: 30
Reply
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to get Dev-Pascal to use other files?

  #21  
Feb 6th, 2008
Got it working, kinda, changed "writeln" in the loop to "write" then aadded the readln so it wouldn't be a space between each lines, but the first line repeats itself still... the other lines won't read.. How do I do that?
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to get Dev-Pascal to use other files?

  #22  
Feb 6th, 2008
Got it working, kinda, changed "writeln" in the loop to "write" then aadded the readln so it wouldn't be a space between each lines, but the first line repeats itself still... the other lines won't read.. How do I do that?
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 13
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: How to get Dev-Pascal to use other files?

  #23  
Feb 6th, 2008
What?

Post your code.
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to get Dev-Pascal to use other files?

  #24  
Feb 6th, 2008
program Untitled;
uses windows;
var
t: text;
s: string[255];
i: integer;
begin
assign( t, 'untitled');
reset( t );
if IOResult <> 0 then
begin
MessageBox ( 0, 'File not found!', 'Error', Mb_ok );
halt( 1 )
end;

i := 1;
while not eof( t ) do
begin
readln( t, s );
write( 'line ', i, ': ', s );
readln;
Reset( t );
inc( i )
end;
halt ( i );
close( t )
end.
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to get Dev-Pascal to use other files?

  #25  
Feb 6th, 2008
program Untitled;
uses windows;
var
t: text;
s: string[255];
i: integer;
begin
assign( t, 'untitled');
reset( t );
if IOResult <> 0 then
begin
MessageBox ( 0, 'File not found!', 'Error', Mb_ok );
halt( 1 )
end;

i := 1;
while not eof( t ) do
begin
readln( t, s );
write( 'line ', i, ': ', s );
readln;
Reset( t );
inc( i )
end;
halt ( i );
close( t )
end.
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 13
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: How to get Dev-Pascal to use other files?

  #26  
Feb 6th, 2008
Please use [code] tags.

I've commented out the lines you don't need:
  1. program Untitled;
  2. uses windows;
  3.  
  4. var
  5. t: text;
  6. s: string[255];
  7. i: integer;
  8.  
  9. begin
  10. assign( t, 'untitled');
  11. reset( t );
  12. if IOResult <> 0 then
  13. begin
  14. MessageBox ( 0, 'File not found!', 'Error', Mb_ok );
  15. halt( 1 )
  16. end;
  17.  
  18. i := 1;
  19. while not eof( t ) do
  20. begin
  21. readln( t, s );
  22. writeln( 'line ', i, ': ', s ); // use writeln, not write
  23. // readln;
  24. // Reset( t );
  25. inc( i )
  26. end;
  27.  
  28. // halt ( i );
  29. close( t )
  30. end.

The reason you never get to EOF is because each time through the loop you were resetting the file back to the first line. Don't do that.

Also, don't halt your program to terminate normally...

Hope this helps.
Last edited by Duoas : Feb 6th, 2008 at 4:44 pm.
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to get Dev-Pascal to use other files?

  #27  
Feb 6th, 2008
Thank you, also, I don't really know what halt do, can you tell me what it does? Read a guide about it somewhere but i never understood it..

Anyway.. Next thing on my list of things I want to do (sorry for being such a "next thing" dude) is adding a bitmap in a pascal windows application, so if we say like, the popup I made for this program comes up, it will show a pic of a note with a red line over, and beside that text it says "file not found". How do I do this?
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to get Dev-Pascal to use other files?

  #28  
Feb 6th, 2008
Thank you, also, I don't really know what halt do, can you tell me what it does? Read a guide about it somewhere but i never understood it..

Anyway.. Next thing on my list of things I want to do (sorry for being such a "next thing" dude) is adding a bitmap in a pascal windows application, so if we say like, the popup I made for this program comes up, it will show a pic of a note with a red line over, and beside that text it says "file not found". How do I do this?
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 13
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: How to get Dev-Pascal to use other files?

  #29  
Feb 6th, 2008
Halt is abnormal program termination. In Unix and DOS, programs normally terminate with exit code zero. You can say halt( 1 ); to terminate abnormally with exit code 1. The exit code tells the program that executed your application (like Windows or the command shell) whether or not your program terminated normally. (Exit code 0 is success; anything else is error.) Except in shell scripts or other cases where anyone cares, the OS will typically ignore the return code.

For the bitmap, start a new project of the type "Windows Application" (or whatever the IDE calls it) and drop a TImage, a TButton, and a TOpenDialog on the main form. Double click the TButton and you'll be placed inside a procedure named something like "TForm1.Button1Click". Add the following:
  1. procedure TForm1.Button1Click( Sender: TObject );
  2. begin
  3. if OpenDialog1.Execute then // if user selects a filename
  4. try
  5. // Try to load and display it
  6. Image1.Picture.LoadFromFile( OpenDialog1.FileName )
  7. except
  8. // On error, complain.
  9. MessageDlg( "fooey!", mtWarning, [mbOK], 0 )
  10. end
  11. end;

Hope this gets you started. Make sure to find some good documentation. It makes all the difference.
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to get Dev-Pascal to use other files?

  #30  
Feb 7th, 2008
That got kinda complicated. Find an easier way to make a simple "error".

MessageBox (0, 'Windows has occured an error.' , 'Error', 0 + MB_ICONHAND);

the thing that's different against the popup without a bitmap picture is that this doesn't have the "mb_ok" after error',

But Still I want to try the way you sent. But I don't really know how.. :C

Can you "talk" me through the lines that NEEDS to be there for it to work? you don't need "program" and "end." cause I already know that, I just don't know the last part before the procedur code you said.. It would be really nice if you could..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Pascal and Delphi Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 9:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC