•
•
•
•
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
![]() |
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
•
•
Join Date: Nov 2007
Posts: 44
Reputation:
Rep Power: 2
Solved Threads: 0
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.
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.
•
•
Join Date: Nov 2007
Posts: 44
Reputation:
Rep Power: 2
Solved Threads: 0
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.
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.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
Please use [code] tags.
I've commented out the lines you don't need:
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.
I've commented out the lines you don't need:
Pascal Syntax (Toggle Plain Text)
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 ); writeln( 'line ', i, ': ', s ); // use writeln, not write // readln; // Reset( t ); inc( i ) end; // halt ( i ); close( t ) 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.
•
•
Join Date: Nov 2007
Posts: 44
Reputation:
Rep Power: 2
Solved Threads: 0
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?
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?
•
•
Join Date: Nov 2007
Posts: 44
Reputation:
Rep Power: 2
Solved Threads: 0
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?
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?
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
Halt is abnormal program termination. In Unix and DOS, programs normally terminate with exit code zero. You can say
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:
Hope this gets you started. Make sure to find some good documentation. It makes all the difference.
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:
Delphi Syntax (Toggle Plain Text)
procedure TForm1.Button1Click( Sender: TObject ); begin if OpenDialog1.Execute then // if user selects a filename try // Try to load and display it Image1.Picture.LoadFromFile( OpenDialog1.FileName ) except // On error, complain. MessageDlg( "fooey!", mtWarning, [mbOK], 0 ) end end;
Hope this gets you started. Make sure to find some good documentation. It makes all the difference.
•
•
Join Date: Nov 2007
Posts: 44
Reputation:
Rep Power: 2
Solved Threads: 0
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..
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..
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- New to Pascal and need to open project. (Pascal and Delphi)
- Could somebody tell me more dev-pascal code? (Pascal and Delphi)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: help me..
- Next Thread: Dialer in VB6 or Delphi that works on XP?



Linear Mode