Prestwood eMagazine
Subscribe to our popular FREE monthly eMagazine.

Enter your email:

Subscription Center
Prestwood Tip Jar
Finding something useful?

Add to the
Tip Jar!

New KB Comments

The new kb comments ordered newest to oldest. 

To view comments to your KB Articles, go to your My Knowledge Base page. To view user contributions to your blogs, go to your My Blog page.
Wes Peterson
Prestwood Software
Send Wes a Private Message Visit Wes's Home Page
PS Staff
Moderator
Rank: Rear-Admiral

Joined: Jan 2004
Visits: 972
MB Posts: 78

KB Articles: 102

Location: Citrus Heights, CA USA
Monday, January 05, 2009 (Updated 1/5/2009 4:45:27 PM)
Read | +Add Comment

Hi Franco,

I'll answer as best I can.

>1. I must de-activate all database tables before calling the restore method - this is not explained in the DBISAM help files - otherwise I get a file access error

[wp] The PDF manual states that, before running a backup, the database engine attempts to obtain read locks on the entire database. This makes it pretty clear that we have to do one thing at a time.

>2. If I do any transactions in the database at all, I cannot do a backup, even though I check if any transactions are pending (which they are not).

[wp] I tend to code pretty defensively, which might by why I'm not experiencing the same problems. My applications virtually always have one, and only one, TDBISAMDatabase component.  Before attempting any of the database maintenance operations, I first check for pending transactions, then set the TDBISAMDatabase.Connected property to false. Then I set it to true before attempting backup, restore, etc.

>3. If I do a restore, and immediately afterwards try to do a backup, it fails with an access error. However, on starting the program, I can do a restore, OR a backup no problem.

[wp] See my reply to 2, above.  Disconnect, then reconnect.

>It seems as if the system only allows one of these operations at a time. What experience have you had of this behaviour, or am I doing something wrong?

[wp] One at a time is correct.

We've had incredibly good results with DBISAM.  You might be interested in what we have to say about it in this article about Employee Handbook Writer.

Best regards.

Wes



Regarding...
DBISAM Database Maintenance Techniques
DBISAM is a fantastic database for Delphi (or C++ Builder) projects. Don't let the name fool you: This database has great SQL support. Among its many features are the flexibility offered by its database maintenance routines.

franco_p
Send franco_p a Private Message Visit franco_p's Home Page
Rank: Cadet 1st Year

Joined: Dec 2008
MB Articles: 0

KB Articles: 0

Wednesday, December 31, 2008 Read | +Add Comment

Hello Wes,

I have tried (with varying degrees of success) to use the 'backup' and 'restore' methods in DBISAM as per your article. The problem I am having is as follows:

1. I must de-activate all database tables before calling the restore method - this is not explained in the DBISAM help files - otherwise I get a file access error

2. If I do any transactions in the database at all, I cannot do a backup, even though I check if any transactions are pending (which they are not).

3. If I do a restore, and immediately afterwards try to do a backup, it fails with an access error. However, on starting the program, I can do a restore, OR a backup no problem.

It seems as if the system only allows one of these operations at a time. What experience have you had of this behaviour, or am I doing something wrong?

regards,

Franco.



Regarding...
DBISAM Database Maintenance Techniques
DBISAM is a fantastic database for Delphi (or C++ Builder) projects. Don't let the name fool you: This database has great SQL support. Among its many features are the flexibility offered by its database maintenance routines.

Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Tuesday, December 16, 2008 Read | +Add Comment



Regarding...
Message Boards May Be Disrupted
We are moving our server in a few days so boards may be interrupted.

honey_saroch
Send honey_saroch a Private Message Visit honey_saroch's Home Page
Rank: Cadet 2nd Year

Joined: Dec 2008
MB Articles: 0

KB Articles: 0

Location: mubarikpur, UNK IN
Tuesday, December 16, 2008 (Updated 12/16/2008 11:45:36 AM)
Read | +Add Comment

hello sir,  

    i developed a program in vb6 and access dataabse as a backend for party accounts balances. i have unbound msflexgrid and command button caption save. when i slelect party from listbox, party account transaction displayed in msflexgrid, now i want to add new rows and some rows modified and click to save button. save changes in dataabse and msflexgrid. iam using "acticex data objects.2.0 library to connect dataabse. tell me code. i will waiting for your reply.

thanks u sir.



Regarding...
Message Boards May Be Disrupted
We are moving our server in a few days so boards may be interrupted.

marianchovan
Send marianchovan a Private Message Visit marianchovan's Home Page
Rank: Cadet 3rd Year

Joined: Jun 2008
MB Articles: 0

KB Articles: 0

Location: SK
Monday, December 15, 2008 Read | +Add Comment

good idea,

{#think}

i don't work with Paradox11 perhaps one year

and forgot many things.

thanks

Smile



Regarding...
ObjectPAL Variable Declaration (var x SmallInt endVar)

Languages Focus: Variable Declaration

A variable holds a value that you can use and change throughout your code so long as the variable is within scope. With variable declaration, you not only want to know the syntax of how you declare a variable but you also want to know where. Are you allowed to declare a variable inline? What are the available scopes: local vs. global. Can you assign a value at the same time you declare a variable?

ObjectPAL Variable Declaration

Declaring variables is optional unless you click Program | Compiler Warnings while in the ObjectPAL editor for every form, script, and library you create. Using Compiler Warnings is strongly recommended to avoid incorrectly typing an existing variable and to avoid any confusion about variable scope. Also recommended is turning on Compile with Debug for every form, script, and library too for tighter, cleaner code.

Undeclared variables are AnyType variables. Common data types include Currency, Date, Datetime, Logical, LongInt, Number, SmallInt, String, and Time.

Declare local variables within a method. If you want a local static variable (retains it's value because it is not destroyed), declare the variables above the method. Variables declared in an object's Var window are visible to all methods attached to that object, and objects that it contains.


marianchovan
Send marianchovan a Private Message Visit marianchovan's Home Page
Rank: Cadet 3rd Year

Joined: Jun 2008
MB Articles: 0

KB Articles: 0

Location: SK
Sunday, December 14, 2008 Read | +Add Comment

Mike,

many thanks

MarianSmile



Regarding...
Paradox 11 Settings do not Save
I just installed Paradox 11 on a new computer and my working directory and other settings do not stick when I restart Paradox. Why?

ckerscher
Metro Computer Services
Send ckerscher a Private Message Visit ckerscher's Home Page
Rank: Cadet 3rd Year

Joined: Feb 2002
MB Articles: 0

KB Articles: 0

Location: Williamson, GA USA
Saturday, December 13, 2008 Read | +Add Comment

The following didn't work for me in Delphi 5 Enterprise version

To mark or unmark a series of lines of code with a comment

1) Highlight the lines of code you wish to comment out - hold down the shift key and move cursor up or down.

2) Hit Ctrl + / and the lines will be commented out. If they already were commented out, they will no longer be commented

Any ideas.

Thanks,

Charlie



Regarding...
Delphi Comments (// or { ... } or (* ... *))

Languages Focus: Comments

Commenting code generally has three purposes: to document your code, for psuedo coding prior to coding, and to embed compiler directives. Most languages support both a single line comment and a multiple line comment. Some languages also use comments to give instructions to the compiler or interpreter.

Delphi Comments

Commenting Code
Delphi uses // for a single line comment and both {} and (**) for multiple line comments. Although you can nest different types of multiple line comments, it is recommended that you don't.

Compiler Directives - $
A special comment. Delphi compiler directives are in the form of {$DIRECTIVE}. Of interest for comments is using the $IFDEF compiler directive to remark out code.


Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Friday, December 12, 2008 Read | +Add Comment

Hi Daniel: I fixed the problem and the attachment is now showing up.



Regarding...
Modified Preorder Tree Traversal Algorithm
I needed a way to show a hierarchical structure. What most were saying, was the, Modified Preorder Tree Traversal Algorithm, was a preferred way of doing hierarchical sets. I thought I would share the code with you.

rdkram
Send rdkram a Private Message Visit rdkram's Home Page
Rank: Cadet 3rd Year

Joined: Oct 2008
Visits: 21
MB Posts: 4

KB Articles: 4

Friday, December 12, 2008 Read | +Add Comment

You can also use Arrays in records. For example:

   TName = record

      FName    : String;

      MInitial : String[1];

      LName    : String;

   end;

 

TPeople = record

  F_Gender: string;
  F_Address: string;
  F_Name: array of TName;

End;

Notice, the F_Name is not defined in size, so use the SetLength() call

see this article:

http://www.prestwood.com/ASPSuite/KB/Document_View.asp?QID=100158



Regarding...
Using Record Types In Delphi
How to use records in Delphi.

rdkram
Send rdkram a Private Message Visit rdkram's Home Page
Rank: Cadet 3rd Year

Joined: Oct 2008
Visits: 21
MB Posts: 4

KB Articles: 4

Friday, December 12, 2008 Read | +Add Comment

I could not upload the associated zip file. I am working with Mike to get the file attached to the posting.

If you need it before then, just respond to this post or email me direclty.



Regarding...
Modified Preorder Tree Traversal Algorithm
I needed a way to show a hierarchical structure. What most were saying, was the, Modified Preorder Tree Traversal Algorithm, was a preferred way of doing hierarchical sets. I thought I would share the code with you.

Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Friday, November 14, 2008 Read | +Add Comment

Thanks Daniel. I added your info on (* *) to the multiple-line comment section and I combined the single line comment info with this post and deleted the single line comment. Originally I wanted to document single line comments from multiple line comments. In hindsight, that was a dumb idea.

Since compiler directives are also embedded in comments, I added a bit of introductory info about that too.



Regarding...
Delphi Comments (// or { ... } or (* ... *))

Languages Focus: Comments

Commenting code generally has three purposes: to document your code, for psuedo coding prior to coding, and to embed compiler directives. Most languages support both a single line comment and a multiple line comment. Some languages also use comments to give instructions to the compiler or interpreter.

Delphi Comments

Commenting Code
Delphi uses // for a single line comment and both {} and (**) for multiple line comments. Although you can nest different types of multiple line comments, it is recommended that you don't.

Compiler Directives - $
A special comment. Delphi compiler directives are in the form of {$DIRECTIVE}. Of interest for comments is using the $IFDEF compiler directive to remark out code.


Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Thursday, November 13, 2008 Read | +Add Comment

You're welcome and thanks for the kind words. By the way, a few months ago you suggested we improve the look and make it a bit simpler and cleaner. Based on your input (and others) I made quite a few changes. Is the website better looking now? Or, do I have more work to do. I do have some ideas I haven't had time to implement but if you have any suggestions, they are welcome.



Regarding...
Mike Prestwood will present UML 1.4 at the Nov VB user group
Mike Prestwood will speak on the Universal Modeling Language (UML) at the November 19th meeting of the Sacarmento Visual Basic user group. Tek Systems will be providing dinner.

Dr. Arti Mehta
Datamatics
Send aartimehta a Private Message Visit aartimehta's Home Page
Rank: Cadet 3rd Year

Joined: Jul 2007
MB Articles: 0

KB Articles: 0

Location: Mumbai IN
Thursday, November 13, 2008 Read | +Add Comment

Mike,

You are an encyclopedia of knowledge. So if no the session, even if the extracts of the session on UML 1.4 in th eform of knowldege base article would help us learn a lot.

Request you to evaluate the possibility.

And, thank you very much for so much knowledge sharing!

Regards

Arti



Regarding...
Mike Prestwood will present UML 1.4 at the Nov VB user group
Mike Prestwood will speak on the Universal Modeling Language (UML) at the November 19th meeting of the Sacarmento Visual Basic user group. Tek Systems will be providing dinner.

Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Wednesday, November 12, 2008 (Updated 12/15/2008 1:18:40 AM)
Read | +Add Comment

Although I still like Paradox, I guess I should add that if you want to explore switching to MS Access, check out my ObjectPAL and Access VBA Cross Reference Guide.



Regarding...
WPO X4 Ships! Paradox Still Does Not Support Vista!
According to current information on the official Corel X4 home page, WPO X4 ships with Paradox 11 SP2 and still does not support Vista. Yet.

Steve Green
Diamond Software Group, Inc.
Send greens a Private Message Visit greens's Home Page
Rank: Ensign

Joined: May 2008
Visits: 60
MB Posts: 41

KB Articles: 0

Location: Myrtle Beach, SC USA
Tuesday, November 11, 2008 Read | +Add Comment

> It's over six months since it was revealed that Corel still did not support Paradox under Vista in WPX4...have they fixed this yet?

to be honest, it's doubtful that Corel will ever touch Paradox again.. all the people that were associated with it have been gone since 2002..



Regarding...
WPO X4 Ships! Paradox Still Does Not Support Vista!
According to current information on the official Corel X4 home page, WPO X4 ships with Paradox 11 SP2 and still does not support Vista. Yet.

Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Tuesday, November 11, 2008 Read | +Add Comment

No new info. I agree that they should fix this especially if they want to make good software and be known as a quality software company. I'm hopeful they will find the money to fix these errors. Until they find the money, it's just not going to happen. Paradox 9 works fine on Vista though so you might want to revert to that version. In my opinion, Paradox is the best desktop database available. It's only real competitor is Microsoft Access and even though Microsoft has continued development of Access and it does have some neat features, it's still not as easy to use as Paradox.



Regarding...
WPO X4 Ships! Paradox Still Does Not Support Vista!
According to current information on the official Corel X4 home page, WPO X4 ships with Paradox 11 SP2 and still does not support Vista. Yet.

vinylsol
Vinyl Solution
Send vinylsol a Private Message Visit vinylsol's Home Page
Rank: Cadet 4th Year

Joined: Sep 2007
Visits: 12
MB Posts: 12

KB Articles: 0

Location: Cheltenham AU
Tuesday, November 11, 2008 Read | +Add Comment

It's over six months since it was revealed that Corel still did not support Paradox under Vista in WPX4...have they fixed this yet? I'm particularly concerned about the BDE initialization problem and the 'Paradox has stopped' error on exiting. It seems to me that Corel shouldn't be selling the product as a Vista compatible package with these kinds of errors but I can't find any reviews of X4 that indicate that the problem has been fixed (the reviews only seem concerned with WP itself) and I don't want to pay for an upgraded version if the problem is still there. Any new info out on this?



Regarding...
WPO X4 Ships! Paradox Still Does Not Support Vista!
According to current information on the official Corel X4 home page, WPO X4 ships with Paradox 11 SP2 and still does not support Vista. Yet.

Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Monday, November 10, 2008 Read | +Add Comment

Hi Arti,

No, we didn't capture that event. I'm hoping to capture some in the future and post them to the website. Until then, I'm mainly focusing on knowldge base articles and responding to message board Q&A.



Regarding...
Mike Prestwood will present UML 1.4 at the Nov VB user group
Mike Prestwood will speak on the Universal Modeling Language (UML) at the November 19th meeting of the Sacarmento Visual Basic user group. Tek Systems will be providing dinner.

Dr. Arti Mehta
Datamatics
Send aartimehta a Private Message Visit aartimehta's Home Page
Rank: Cadet 3rd Year

Joined: Jul 2007
MB Articles: 0

KB Articles: 0

Location: Mumbai IN
Monday, November 10, 2008 Read | +Add Comment

Mike, will you be sharing the session content on this site?

Regards

Dr. Arti Mehta



Regarding...
Mike Prestwood will present UML 1.4 at the Nov VB user group
Mike Prestwood will speak on the Universal Modeling Language (UML) at the November 19th meeting of the Sacarmento Visual Basic user group. Tek Systems will be providing dinner.

Dr. Arti Mehta
Datamatics
Send aartimehta a Private Message Visit aartimehta's Home Page
Rank: Cadet 3rd Year

Joined: Jul 2007
MB Articles: 0

KB Articles: 0

Location: Mumbai IN
Monday, November 10, 2008 Read | +Add Comment

I always admire the simplistic text you use to explain any concept.

Regarding introduction to DFD, a small diagram, if possible, would have helped to relate description with the visualization.

Regards

Dr. Arti Mehta



Regarding...
A 10 Minute Data Flow Diagrams (DFD) Quick Start
DFDs document a process by documenting the flow of data throughout the process. They depict how data interacts with a system. They can be used to engineer a new process, document an existing process, or re-engineer an existing process.

rdkram
Send rdkram a Private Message Visit rdkram's Home Page
Rank: Cadet 3rd Year

Joined: Oct 2008
Visits: 21
MB Posts: 4

KB Articles: 4

Tuesday, November 04, 2008 (Updated 11/4/2008 11:47:24 AM)
Read | +Add Comment

Another form of a multiple line comment

(*

  some comments go here

*)

Speaking of comments:

// I am a Single line comment

Multiple levels of comments. You can nest comments like the example below

(*

  I am a comment

  {

    I am a comment within a comment

  }

*)

The hierarchy of comments:

(* comment *) = highest precedence

{ comment }

// comment

To mark or unmark a series of lines of code with a comment

1) Highlight the lines of code you wish to comment out - hold down the shift key and move cursor up or down.

2) Hit Ctrl + / and the lines will be commented out. If they already were commented out, they will no longer be commented

Before:

if (something) then

begin

  ShowMessage('I did it.');

end;

After:

//if (something) then
//begin
//  ShowMessage('I did it.');
//end;



Regarding...
Delphi Comments (// or { ... } or (* ... *))

Languages Focus: Comments

Commenting code generally has three purposes: to document your code, for psuedo coding prior to coding, and to embed compiler directives. Most languages support both a single line comment and a multiple line comment. Some languages also use comments to give instructions to the compiler or interpreter.

Delphi Comments

Commenting Code
Delphi uses // for a single line comment and both {} and (**) for multiple line comments. Although you can nest different types of multiple line comments, it is recommended that you don't.

Compiler Directives - $
A special comment. Delphi compiler directives are in the form of {$DIRECTIVE}. Of interest for comments is using the $IFDEF compiler directive to remark out code.


Wes Peterson
Prestwood Software
Send Wes a Private Message Visit Wes's Home Page
PS Staff
Moderator
Rank: Rear-Admiral

Joined: Jan 2004
Visits: 972
MB Posts: 78

KB Articles: 102

Location: Citrus Heights, CA USA
Friday, October 31, 2008 (Updated 10/31/2008 10:33:22 AM)
Read | +Add Comment

Whether to use Free, or FreeAndNil, is an interesting topic.  It depends on the circumstances.

My rule of thumb is that if an object is local (that is, it's reference variable will soon go out of scope) just use Free.  But if the object is more "global," use FreeAndNil.

A classic example is a form that will create and show another form.  This is often done within the scope of a button click handler, or an ActionItem's Execute method:

procudure MyForm.Button1Click(Sender : TObject);
var 
  StudentForm : TStudentForm;
begin
  StudentForm := TStudentForm.Create(Self);
  StudentForm.ShowModal;
  StudentForm.Free;
end;

In the above snippet, the local variable, StudentForm, isn't accessible outside of the click handler, and it will go out of scope fairly soon.  In this case, I think Free is sufficient.

However, if I'd made my reference variable more "global," say as a private member, FStudentForm, of TMyForm, any and every method of that class has access to it. In that case, I'll use FreeAndNil:

procedure MyForm.Button1Click(Sender : TObject);
begin
  if (FStudentForm = nil) then
    FStudentForm := TStudentForm.Create(Self);
  FStudentForm.ShowModal;
  FreeAndNil(FStudentForm);
end;

Just to play it safe, you'll probably want to set FStudentForm to nil in TMyForm's OnCreate event.

Of course, it does no harm to use FreeAndNil wherever it's legal (As Mike says, the argument to FreeAndNil must be a TObject, or descendant thereof).



Regarding...
Object Pascal Destructor (Free or FreeAndNil)

Object Pascal uses a standard virtual destructor named Destroy which is called by the standard Free method. All objects are dynamic, so you need to call MyObject.Free method or the FreeAndNil(MyObject) routine for each object you create.


Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Thursday, October 30, 2008 (Updated 10/30/2008 7:07:30 PM)
Read | +Add Comment

Hmmm...sure, that's a good rule of thumb and thanks for adding the info here (I added it to the flashcard above too). Bottom line.

However, to further the discussion I guess it depends on the situation. It is a routine and not a class method so using Free "feels" more OOP to me so I tend to use it with simple OOP examples when giving demos. ((I know, that's a pretty weak excuse but I think it helps with new coders.)) You do have to be careful to only pass TObjects to this routine too. My own rule of thumb with larger applications is that I use Free when doing simple controlled tasks and FreeAndNil with more complicated things.

Also, when do we stop writing extra checks? You could be even more complete and do something like the following:

If Assigned(MyObject) then
FreeAndNil(MyObject)
Else
MyObject := nil;

If by some chance MyObject was not assigned to begin with, then FreeAndNil() will never get called and therefore MyObject will never get set to nil.

Should Be NilAndFree

Finally a minor point but because we're getting into it a bit, I thought it might be important because FreeAndNil actually does the opposite. You can run into problems accessing the object variable while it's being destroyed.

For reference, here are the three VCL code routines in discussion:

In System Unit:

//TObject.Free
procedure TObject.Free;
begin
  if Self <> nil then
    Destroy;
end; 
 
//TObject.Destroy
destructor TObject.Destroy;
begin
end;

In SysUtils unit:

//FreeAndNil
procedure FreeAndNil(var Obj);
var 
  Temp: TObject;
begin 
  Temp := TObject(Obj); 
  Pointer(Obj) := nil; 
  Temp.Free;
end;

 



Regarding...
Object Pascal Destructor (Free or FreeAndNil)

Object Pascal uses a standard virtual destructor named Destroy which is called by the standard Free method. All objects are dynamic, so you need to call MyObject.Free method or the FreeAndNil(MyObject) routine for each object you create.


Mike Prestwood
Prestwood Software
Send mprestwood a Private Message Visit mprestwood's Home Page
PS Staff
Moderator
Rank: Fleet Admiral

Joined: Oct 2000
Visits: 21792
MB Posts: 1032

KB Articles: 1267

Location: Citrus Heights, CA USA
Thursday, October 30, 2008 Read | +Add Comment

Hi Daniel:

I just wanted to welcome you and say your post is just fine right here. We welcome your input.



Regarding...
Associative Arrays in Delphi/Object Pascal (Use TStringList)

TStringList Example
Object Pascal doesn't have a native associative array, but you can use a TStringList the same way. (Alternatively, search the Internet for TStringHash and THashedStringList classes for implementations of a true associative array).


Mike Prestwood
Prestwood Software