•
•
•
•
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 456,610 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,507 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: 5526 | Replies: 46 | Solved
![]() |
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
There's no need for the angry attitude or to get all defensive. I have far more experience than you and, whether you believe it or not, a greater understanding of your problem than you do.
At no point have I given you incorrect code --all the code I supplied works fine. The problem lies in your understanding.
May I ask how it is that you have written so much code that it would take an enormous amount of time to switch to a TListBox (which, you will note, I have not required you to do), without understanding the basic concepts central to programming? At no point have I written anything in any post of mine which does not directly apply to your efforts. Don't just skip over stuff you don't understand because you think it has no bearing.
You are perfectly capable of working with what I have given you. It is neither over your head nor is it smarter than you. You must, if you intend to continue working with Delphi, learn how to lookup information about the VCL with the Delphi help system, and you must understand how to create and use procedures and functions, and you must understand how the type of a thing affects the code used to manipulate it. Failing these things you will remain stuck.
It is time now to put a little effort into learning something about these things instead of demanding that I or anyone else simply give you code to cut and paste (which, BTW, I have already done). Programming is not easy. It takes a lot of work, and years to become sufficiently proficient that tasks like this become 'evident'.
I have already said, and remain, willing to help. But I am unwilling to do your work for you.
At no point have I given you incorrect code --all the code I supplied works fine. The problem lies in your understanding.
May I ask how it is that you have written so much code that it would take an enormous amount of time to switch to a TListBox (which, you will note, I have not required you to do), without understanding the basic concepts central to programming? At no point have I written anything in any post of mine which does not directly apply to your efforts. Don't just skip over stuff you don't understand because you think it has no bearing.
You are perfectly capable of working with what I have given you. It is neither over your head nor is it smarter than you. You must, if you intend to continue working with Delphi, learn how to lookup information about the VCL with the Delphi help system, and you must understand how to create and use procedures and functions, and you must understand how the type of a thing affects the code used to manipulate it. Failing these things you will remain stuck.
It is time now to put a little effort into learning something about these things instead of demanding that I or anyone else simply give you code to cut and paste (which, BTW, I have already done). Programming is not easy. It takes a lot of work, and years to become sufficiently proficient that tasks like this become 'evident'.
I have already said, and remain, willing to help. But I am unwilling to do your work for you.
•
•
Join Date: Nov 2007
Posts: 87
Reputation:
Rep Power: 2
Solved Threads: 1
Wasnt getting defensive nor angry... You are not willing to help me get this one thing complete or understand what I am not doing correctly. I have spent hours on looking up information to get this done before posting this question here.
I am VERY new to programming... I am doing this alone on my own time at home. I never said you were not more experienced than me. So please. Just stop posting and turning this post into a completely unnecessary flame war.
Thanks (again) for your help. But it wasnt enough to help me understand why i cant get it to work. You are right, I am wrong. Now please let someone else with better communication skills try to help me out with this should they choose to. If I understood why I cant get it to work, then I wouldnt be typing still.
Have a nice day kind sir.
I am VERY new to programming... I am doing this alone on my own time at home. I never said you were not more experienced than me. So please. Just stop posting and turning this post into a completely unnecessary flame war.
Thanks (again) for your help. But it wasnt enough to help me understand why i cant get it to work. You are right, I am wrong. Now please let someone else with better communication skills try to help me out with this should they choose to. If I understood why I cant get it to work, then I wouldnt be typing still.
Have a nice day kind sir.
Last edited by squidd : Nov 8th, 2007 at 7:23 pm. Reason: spelling
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
Look, I haven't meant to make you feel stupid.
1. Look at posts #4 and #10, where I gave you an event handler and which you correctly modified to use the TListView.
2. Now look at post #16 where I gave you a function that prints x lines from a TListView's item list.
3. Put them both in your code. Change the word "save250" from post #10 to "saveNLines".
I know you are new to programming. That is why I have asked you to read about procedures and about types. All your errors are due as a direct consequence of your failure to do that.
You are being defensive and angry. And you presume too much to say I am unwilling or that I misunderstand. I understand better than you think, and I have stated repeatedly I am willing to help, if you are willing to follow the advice given you. I have no interest in wasting my time to lead you in circles.
Please consider that I know what it is to learn how to program and how much information overload it is to find simple answers. The truth is that there are no simple answers when it comes to programming, and you are going to have to wrap your mind around a few things --none of which come easily-- to get it right. Until you do, even a gift horse looks like a mule.
1. Look at posts #4 and #10, where I gave you an event handler and which you correctly modified to use the TListView.
2. Now look at post #16 where I gave you a function that prints x lines from a TListView's item list.
3. Put them both in your code. Change the word "save250" from post #10 to "saveNLines".
I know you are new to programming. That is why I have asked you to read about procedures and about types. All your errors are due as a direct consequence of your failure to do that.
You are being defensive and angry. And you presume too much to say I am unwilling or that I misunderstand. I understand better than you think, and I have stated repeatedly I am willing to help, if you are willing to follow the advice given you. I have no interest in wasting my time to lead you in circles.
Please consider that I know what it is to learn how to program and how much information overload it is to find simple answers. The truth is that there are no simple answers when it comes to programming, and you are going to have to wrap your mind around a few things --none of which come easily-- to get it right. Until you do, even a gift horse looks like a mule.
•
•
Join Date: Nov 2007
Posts: 87
Reputation:
Rep Power: 2
Solved Threads: 1
•
•
•
•
1. Look at posts #4 and #10, where I gave you an event handler and which you correctly modified to use the TListView.
2. Now look at post #16 where I gave you a function that prints x lines from a TListView's item list.
3. Put them both in your code. Change the word "save250" from post #10 to "saveNLines".
And again, after all this is done.. it wont compile.. still.
[DCC Error] : E2065 Unsatisfied forward or external declaration: 'TForm1.saveNLines'
[DCC Error] : E2197 Constant object cannot be passed as var parameter
Even after I did EXACTLY what you recommend, it doesnt compile.. has never compiled.
I simply don't know how to correct these errors. I cant make plainer than that.
EDIT:
Also, I have to say. If this is what I have to go through to learn one single thing for each thing I try to do, then I dont know how much longer I am going to bother with learning how to program. I have spent an ENORMOUS amount of time trying to figure this single procedure out, and the effort is simply not worth the payoff in this case i am starting to think. You cannot even begin to comprehend my frustration with this. I am getting REALLY pissed. Not at you so much, but at the idea that a simple thing such as this is so much trouble. Almost a week on this ONE thing.
Last edited by squidd : Nov 9th, 2007 at 5:31 pm.
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
Yeah, I know. I've gone through the same things... Over and over and over again. It's just part of programming...
Post your entire unit and I'll take a look-see. It has to be something painfully silly.
I once spent an entire week on about 60-70 lines of C code and was just at the point of burning my PC when I figured out that I had misplaced a } somewhere. Most. Obnoxious. Error. Ever.
Things get better after a while. Honest they do. Just don't give up. (Right now I'm banging my own head against the windows console... the stupid thing doesn't have a WndProc, permit event hooks, anything... it is for all intents and purposes an actual GUI-less process. All I want to know is if the user grabs the window and sizes it... but apparently that "can't happen". Alas...)
I think you put the saveNLines inside your TForm1 class definition, but defined it below as
instead of
I'm not sure what the second error is, so post everything so I can find it.
Post your entire unit and I'll take a look-see. It has to be something painfully silly.
I once spent an entire week on about 60-70 lines of C code and was just at the point of burning my PC when I figured out that I had misplaced a } somewhere. Most. Obnoxious. Error. Ever.
Things get better after a while. Honest they do. Just don't give up. (Right now I'm banging my own head against the windows console... the stupid thing doesn't have a WndProc, permit event hooks, anything... it is for all intents and purposes an actual GUI-less process. All I want to know is if the user grabs the window and sizes it... but apparently that "can't happen". Alas...)
I think you put the saveNLines inside your TForm1 class definition, but defined it below as
procedure saveNLines( ... );instead of
procedure TForm1.saveNLines( ... );I'm not sure what the second error is, so post everything so I can find it.
•
•
Join Date: Nov 2007
Posts: 87
Reputation:
Rep Power: 2
Solved Threads: 1
I don't think I need to post the entire program.. its almost 300 lines. Which I know is nothing, but it works fine without the code in question. See if you can find out what is wrong here first. If not Ill post the whole thing.
I hope you can find the problem.... I am bummed out. Thanks again
procedure Button12Click(Sender: TObject); procedure saveNLines(filename: string; var items: tListItems; startAt: integer; numLines: integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Caption := 'List Modify';
ListView1.Columns.Add.Caption := '0';
Listview1.Columns[0].Width := 300;
end; delphi Syntax (Toggle Plain Text)
procedure TForm1.Button12Click( Sender: TObject ); var lines_per_block: integer; line_index: integer; file_number: integer; file_extension: string; base_filename: string; begin lines_per_block := strToInt( edit6.text ); // number of lines to save per file if saveDialog1.execute then begin // get the file extension and everything except the extension in // separate strings so we can inject the 1, 2, 3, ... file number. file_extension := extractFileExt( saveDialog1.filename ); base_filename := copy( saveDialog1.filename,1,length( saveDialog1.filename ) -length( file_extension )); // save each block of lines line_index := 0; file_number := 1; while line_index < ListView1.items.count do begin SaveNLines(base_filename + intToStr( file_number ) + file_extension, ListView1.items, line_index, lines_per_block); inc( file_number ); inc( line_index, lines_per_block ); end; end; end; procedure TForm1.saveNLines(filename: string; var items: tListItems; startAt: integer; numLines: integer); var sl : tStringList; b, e : integer; begin // Our temporary string list sl := tStringList.create; // indices of lines to copy, inclusive b := startAt; e := startAt + numLines -1; if e >= items.count then e := items.count -1; // copy the indexed lines into our temporary string list for b := b to e do sl.append( items.item[ b ].caption ); // save the lines to file sl.saveToFile( filename ); // cleanup sl.free end;
I hope you can find the problem.... I am bummed out. Thanks again
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
OK, that was enough. You need two changes.
In your class definition:
You must declare your procedures and functions before you can use them. Also, the compiler was complaining about passing the TListView.items as a var argument, so you will notice that I removed the var from the parameter list. The actual procedure definition must match, so change it below the same way:
That compiled and worked correctly for me.
In your class definition:
Delphi Syntax (Toggle Plain Text)
private { Private declarations } procedure saveNLines(filename: string; items: tListItems; startAt: integer; numLines: integer); public { Public declarations } end;
Delphi Syntax (Toggle Plain Text)
procedure TForm1.saveNLines(filename: string; items: tListItems; startAt: integer; numLines: integer);
That compiled and worked correctly for me.
•
•
Join Date: Nov 2007
Posts: 87
Reputation:
Rep Power: 2
Solved Threads: 1
yes SIR! It did compile! Thank you very much 
But nothing happens when I add a number to the edit6.text box and click button12 to perform the now correct (thank you very much for that btw) code.
What is missing I wonder to where the button (button12) isnt doing the procedures being called upon?
I am happy at this point to just have it compile. But the splitting of a large list still doesnt happen .
I loaded up a list of over 15,000 lines. and clicked the button. Nothing happened. I say ok fine.. no problem. so I load up a list again and type in '20' in edit6.text. Then I went to the save button, and it didn't split it up there either.
maybe I should post the whole thing for you to peruse. This is insane. lol

But nothing happens when I add a number to the edit6.text box and click button12 to perform the now correct (thank you very much for that btw) code.
What is missing I wonder to where the button (button12) isnt doing the procedures being called upon?
I am happy at this point to just have it compile. But the splitting of a large list still doesnt happen .
I loaded up a list of over 15,000 lines. and clicked the button. Nothing happened. I say ok fine.. no problem. so I load up a list again and type in '20' in edit6.text. Then I went to the save button, and it didn't split it up there either.
maybe I should post the whole thing for you to peruse. This is insane. lol
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation:
Rep Power: 13
Solved Threads: 193
It works, it just doesn't tell you it did. Check your directory for files.
Remember also that the TListView must be populated with at least one item for it to work. (You loaded your list so that's not a problem.) When I did it, I just added three items using the designer, set the number of items per file to 2, and clicked the button --producing two files (the first containing two lines and the last containing one). I'm sure you must have a ton of files in the directory you saved to.
Most programs indicate that a save worked successfully by putting a message on the statusbar or changing the main form's caption or some other like thing.
Another thing you should be aware of is that there is currently no error checking to make sure that Edit6 contains a number, so if the user puts in "fooey" the program will crash. Go ahead and try it. There are several ways to fix this, but the easiest is something like:
Glad to be of help.
Remember also that the TListView must be populated with at least one item for it to work. (You loaded your list so that's not a problem.) When I did it, I just added three items using the designer, set the number of items per file to 2, and clicked the button --producing two files (the first containing two lines and the last containing one). I'm sure you must have a ton of files in the directory you saved to.
Most programs indicate that a save worked successfully by putting a message on the statusbar or changing the main form's caption or some other like thing.
Another thing you should be aware of is that there is currently no error checking to make sure that Edit6 contains a number, so if the user puts in "fooey" the program will crash. Go ahead and try it. There are several ways to fix this, but the easiest is something like:
Delphi Syntax (Toggle Plain Text)
try lines_per_block := strToInt( edit6.text ) except showMessage( 'You must specify how many lines to save per file.' ); edit6.setFocus; exit end; if saveDialog1.execute then ...
Glad to be of help.
•
•
Join Date: Nov 2007
Posts: 87
Reputation:
Rep Power: 2
Solved Threads: 1
it doesn't split the file nor does it save to the folder where the original file was loaded from. Actually, after added a value i.e. 50 to edit6.text, I then clicked button12 (after compiling all this first of course) and nothing happens.. Nothing is being split. If it is, then why isnt it saving?
Is that another thing altogether? Thanks again.
and yes, error checking is definately something I will need to do and possibly will help with, but no need for that until i get this to work. lol
Is that another thing altogether? Thanks again.
and yes, error checking is definately something I will need to do and possibly will help with, but no need for that until i get this to work. lol
Last edited by squidd : Nov 9th, 2007 at 11:36 pm. Reason: spelling
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- printing of sort list (C++)
- Recrusive Split on a linked list (C)
- Something is very very strange about my IE. Perhaps it's a spyware...Please help me!! (Viruses, Spyware and other Nasties)
- Taskmgn.exe adware? (Viruses, Spyware and other Nasties)
- PC crashes (Viruses, Spyware and other Nasties)
- Spyware is Redirecting Homepage (Viruses, Spyware and other Nasties)
- IE6 has been constantly hijacked by .... (Viruses, Spyware and other Nasties)
- Microsoft IE Offline Pop-ups (Web Browsers)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Disassembly pane, CPU Window
- Next Thread: Package GXOUTLOOK



Linear Mode