Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reorder table in BROWSE on the fly

Status
Not open for further replies.

Kimed

Programmer
May 25, 2005
104
LT
Hi!

I'm trying to BROWSE a table that has several indexes. I made a "ON KEY LABEL ## DO" for it with a procedure that remembers current record position, checks for a field that the cursor is in, and if the table is indexed on this field, SET ORDER to it and then recover the position of the cursor. The problem is that while I can affect current record position in the table, the BROWSE window does not refresh until I move the cursor to the different line manually... and then it takes a previous or subsequent position according to the *old* order instead of new, throwing the table far from the area I want to browse.

A partial solution would be to issue SKIP immediately after reordering. It works, and even moves the cursor according to the new order, but when I try to combine it with a STEP -1 or SEEK/LOCATE to restore the exact position of the cursor, then refreshing of the BROWSE window works no more.

Thanks.
 
Kimed,
to force BROW reordering, you must close and restart it,
for example something as:

on key label F7 do srt_brw
on key label ESC do qt_brw
on key label CTRL+END do qt_brw
tru = .T.
do while tru
brow
enddo
***
proc srt_brw
mrecno = recno()
vr = varread()
on error ?? chr(7)
set order to tag (vr)
on error do chyba with prog(),lineno(1)
keyb '{CTRL+W}'
ii = 1
do while upper(field(ii)) # upper(vr) .and. ii <= fcount()
ii = ii + 1
keyb '{ENTER}'
enddo
go mrecno
retu
***
proc qt_brw
tru = .F.
* return indexes to standard relation model
on key label CTRL+END
on key label ESC
keyb '{CTRL+END}'
retu

Tesar



 
You don't have to close a Browse to force it to reorder. In fact, issuing SET ORDER TO does the trick, though you may have to click on the Browse or otherwise give it focus for the change to show.

Tamar
 
Hi, Tamar,

The focus doesn't actually leave Browse window; clicking on the fields in the same line or non-data areas of the window doesn't change a thing, only a move to another line makes the change show (besides, keyboard input is more common where I work). On the other hand, "otherwise give it focus" worked - I just had to temporary ACTIVATE a neighbour window, then switch it back. Thanks for help.
 
BROWSE NOFOLLOW is an idea, but again, it's a record-level event, not field level.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top