Are SetKey/GotoKey safe ?

Are SetKey/GotoKey safe ?

Post by Jury Kisele » Sun, 31 Dec 1899 09:00:00

I would like to use SetKey/GotoKey construction in my applications (Delphi
2), but now some my colleagues say that the construction halts computer
sometimes and not work at all under higher versions of BDE. They advise me
to use Locate method instead. Is it true ? Did anybody experience the
problem ? Is possible to use it safely ? What about Locate ? I will welcome
any advise or help. Thanks in advance.
Jury Kiselev


1. Emulating SetKey/GotoKey on TQuery

Here's a little brain teaser for you:

I am a programmer for a multi-bazzilion dollar international company
that supplies 78% of the world widget market. This company made the
exceptionally wise decision to hire me to write a widget management app
for them called Widgets '95. In this dialog (diatribe?), I will also
play the role of the overworked user, who is on the brink of suicide.

I have a table containing data about widgets. Each widget has various
attributes like color, size, shape etc. Since there are thousands of
widgets, I need a means to narrow the list before I select the widget I
want to view. So, I have a little query dialog box that allows me to
filter out, say, all the yellow widgets. Then, I search through my list,
and find the one I want, and select it. This makes a detail screen pop
up, and I may happily view the data pertaining to this widget.

As you may have guessed, I used the TQuery to narrow the list to only
yellow widgets. I then used the same instance of the TQuery as my
DataSet on the detail form.

Now the plot thickens...

I realize that the widget I am viewing is listed as yellow, but should
actually be red. I make these changes, and post them (still in the
detail screen.) However, since this record no longer fits the query
requirements of being yellow, it dissapears, and I, the confused user am
left looking at the next record in the yellow set. Being the frustrated
user that I am, this is the precise moment when my psyche snaps, and I
thow myself off the roof of my office building in despair...

Luckily, the building was only one storey high, and there was a soft
lawn at the bottom, so I survived my ordeal, but now I must fix this
dastardly problem. How do I do it? I try this:

           KeyNum: Integer;
           KeyNum := Query1.FieldByName('KeyField').AsInteger;
           {This is a routine that closes the Query1, clears all the
            parameters, and opens with the entire dataset}
           Query1.FieldByName('KeyField') := KeyNum;

This would open the dataset again, and allow me to go back to that
record that was changed. Only one problem. TQuery doesn't have SetKey
and GotoKey methods, only TTable has that.

Whatever shall I do!

2. DTSRun

3. Quirk: Paradox vs dBase SetKey...GotoKey

4. Install 8i on Linux

5. Q : Interbase and Setkey and Gotokey

6. Recovery from Log

7. SetKey and GotoKey ?

8. help

9. Setkey...Gotokey help

10. DOS 3.5 Capslock, and SetKey questions.

11. SetKey, EditKey, etc

12. PDOX 4.0 Dos Setkey Question

13. Clipper SETKEY and SETCANCEL