Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > Apps

Lost Password?

Reply
 
Thread Tools Display Modes
  #11  
Old 09-14-2010, 06:34 AM
Shaun Hand Shaun Hand is offline
Junior Member
 
Join Date: Aug 2010
Posts: 24
Default

Thank you. I will work through it and hopefully gain a better understanding of what's going on.

Just a small question. Why would what I've tried to use ini.ValueExists actually compile and work, when it shouldn't, or am I missing the boat on this?
Reply With Quote
  #12  
Old 09-14-2010, 07:36 AM
Glenn1234 Glenn1234 is offline
Senior Member
 
Join Date: Aug 2009
Posts: 131
Default

Quote:
Originally Posted by Shaun Hand View Post
Just a small question. Why would what I've tried to use ini.ValueExists actually compile and work, when it shouldn't, or am I missing the boat on this?
I did research against some source and found that this is a non-common base class method that exists in TCustomIniFile in later Delphis than what I was looking at documentation for. This method is not typical for TInifile. This is likely why what you would have would compile. But it is basically functional to what I posted. In fact, what I posted would be more efficient than using ValueExists anyway, since you are performing the read & parsing operations against the whole INI file in using this (and allocating a TStringList to do this).

But this really is all immaterial to the logic error you had in your code. Did you figure that out and why it occurred?
Reply With Quote
  #13  
Old 09-14-2010, 07:55 AM
Shaun Hand Shaun Hand is offline
Junior Member
 
Join Date: Aug 2010
Posts: 24
Default

From what I have in my code,
if not I think this is what you're referring to, but I don't quite understand the problem.
(The debugger info is even more confusing) I had a look at it, and it makes even less sense, but I do know what my problem is. I want to run before I can walk, and I'm barely crawling at the moment.

I've reverted to similar code as what I had, but will try to use what you're saying.

What would be the best way to learn Delphi? I'm using RS2009 D&C++. Not interested in C++ at all though. There doesn't seem to be much documentation available for Delphi 2009/2010, so I'm using old books for Delphi 5-7 which do help. The help files in D2009 are very limited though.

I have a bunch of errors in my code, which I can't figure out how to get rid of them, as they are referring to things that are not part of my form.

I'm doing what I can and from what I read online, try and use code that does what I want it to do, without understanding what the code actually does.
Reply With Quote
  #14  
Old 09-14-2010, 08:11 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default

The older delphi books are still very good, especially the Marco Cantu... When learning Delphi this is something like a bible...
I learned delphi back when it was D5, but now I'm working up to 2009 (haven't tried 2010 yet) without any problems... It's basically the same... Only really big difference is the unicode, but I doubt you'll run into this when still in the learning curve...

And the debugger is something you'll have to get used to... Once you figure it out it truly is your best friend... Now I code most of my time in Clarion, there is no good debugger... I see myself posting messages in my code just to find small typo's... That's when you learn to appreciate the good old delphi debugger
Reply With Quote
  #15  
Old 09-14-2010, 09:47 AM
Shaun Hand Shaun Hand is offline
Junior Member
 
Join Date: Aug 2010
Posts: 24
Default

I am getting some indications in my log that there is Debug info available in specific modules.
Are these the errors in my code?

What I'm using now after changes.

Code:
 
procedure TForm1.ReadINIExecute(Sender: TObject);
var
  ini: TIniFile;
  b: String;
 begin
  // Create INI Object and open or create file test.ini
     ini := TIniFile.Create(GetSpecialFolderPath($001a)+'\UTCT\UTCT.ini');
     b:= ini.ReadString('Setup', 'Exist', 'False');
try if b= 'True'
  then begin
   PageControl1.TabIndex :=0;
   PageControl1.Pages[4].TabVisible :=False;
// Read boolean value from the INI file.
   if ini.ReadBool('Setup', 'Preferred', False)
   then RadioButton1.Checked:= True; Edit7.Enabled :=True;
   if ini.ReadBool('Technology', 'Type1', False)
   then cbSetupType1.Checked:= True;
...
   if ini.ReadBool('Technology', 'Type20', False)
   then cbSetupType20.Checked:= True;
  // if ini.ReadBool('Technology', 'Other', False)
  // then cbSetupOther.Checked:= True;
end else
  PageControl1.Pages[4].TabVisible :=True;
  PageControl1.TabIndex :=4;
  btnSave.Enabled :=True;
// Read String value from the INI file.
   Edit7.Text := ini.ReadString ('Setup', 'Tel1', '' );
   Edit8.Text := ini.ReadString ('Setup', 'Tel2', '0800012345' );
// Read Integer value from the INI file.
   x := ini.ReadInteger('Setup', 'Section', 0 );
 finally end;
    ini.Free;
  end;
IT WORKS!!!!


Thanks

Last edited by Shaun Hand; 09-14-2010 at 10:48 AM. Reason: It Works!!!
Reply With Quote
  #16  
Old 09-14-2010, 10:50 AM
Glenn1234 Glenn1234 is offline
Senior Member
 
Join Date: Aug 2009
Posts: 131
Default

Quote:
Originally Posted by Norrit View Post
The older delphi books are still very good, especially the Marco Cantu... When learning Delphi this is something like a bible...

Only really big difference is the unicode, but I doubt you'll run into this when still in the learning curve...

And the debugger is something you'll have to get used to... Once you figure it out it truly is your best friend...
Sometimes I think the documentation is so bad now because they want to foster a market in books such as these.

(Addressed more in general) As for the interactive debugger, that is one way to do things. But as you point out with Clarion, you really have to learn how to do things eventually without an interactive debugger. My suggestion when/if it were to come for me to teach programming is to treat it as training wheels are treated with bicycles. The training wheels need to come off eventually the same way that you need to eventually be able to debug without an interactive debugger.

There really isn't that much difference with Unicode. It's *essentially* supported in most Delphis (I've used it with 3 without a problem). You just have to be aware of the data types to use if you have to interface with it.

Quote:
Originally Posted by Shaun Hand View Post
but I do know what my problem is. I want to run before I can walk, and I'm barely crawling at the moment.
Yes that is often the problem with most new to programming. It takes smaller projects to understand what is going on with the logic and how things work before you start running with multiple controls and the like.
Expressing your code in a logically consistent and formatted style helps for readability and understanding your logic as well.

Quote:
What would be the best way to learn Delphi?
Consider looking through the Delphi Object Pascal references (or even straight Pascal references). You will find many of these have been prepared online, some with some of those small projects (25-100 lines on average) which are useful to cut your teeth on. If I were to teach, I would teach straight logic before I would enter on any use of controls.

Quote:
I'm doing what I can and from what I read online, try and use code that does what I want it to do, without understanding what the code actually does.
When you find code that works, study it. Change it around a little bit and see what happens. You always learn best by doing.
Reply With Quote
  #17  
Old 09-15-2010, 06:35 AM
Shaun Hand Shaun Hand is offline
Junior Member
 
Join Date: Aug 2010
Posts: 24
Default

Glenn, Your last line posted, I pretty much do that. I find something that sortof does what I want, and try to adapt it to my needs.
(Still without actually understanding what it really does or can do)
An example in point would be something like this...

Code:
begin
Edit1.Clear;
Edit2.Clear;
Edit5.Clear;
Edit7.Clear;
end;
//how could this be shortened?
Sometime's written as Edit7.Text := ' ';
I know there is code to clear the contents of all Edit boxes, but what if I just wanted to clear a range, say as above 1-2, 5 and 7. What I currently do is have an instruction for each item.

These are the things I don't understand.

S
Reply With Quote
Reply

Tags
pagecontrol1, tabindex, visible

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:09 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.