Sort Method

x5452

New Member
Hi, there i have a question....

Here's the senario:

Prompt the user to enter a series of numbers or strings from the keyboard. Once the user has finished entering data, allow the user to choose a sort method (ascending or descending) and display the results in a browse.

Thankz
X5452
 

Jenie888

Member
I would use a Freeform Query in the Browse then load it using a Dynamic Query.

PHP:
   DEFINE VARIABLE sQuery AS CHARACTER  NO-UNDO.
   DEFINE VARIABLE qString AS CHARACTER  NO-UNDO.
   DEFINE VARIABLE hQuery AS HANDLE     NO-UNDO.
 
  qString = SUBSTITUTE("FOR EACH Table &1  NO-LOCK &2 INDEXED-REPOSITION", sQuery, strSort).
 
    hQuery = QUERY br-Browser:HANDLE NO-ERROR.
    hQuery:QUERY-PREPARE(qString) NO-ERROR.
    hQuery:QUERY-OPEN() NO-ERROR.
 
Probably overkill, but try this:

def temp-table t_list
field listfield as char format "x(30)"
index idx1 listfield ascending
index idx2 listfield descending.

def var this_one as char form "x(20)".
def var this_sort as char form "x(20)" view-as combo-box.
def query q_sort for t_list scrolling.
def browse br_sort query q_sort display listfield label "Field" with 10 down.

form this_one label "Word" with
side-labels 1 down three-d centered title "Add Word" frame fr_one.
form this_sort label "Sort" skip(1) with frame fr_sort.

on value-changed of this_sort in frame fr_sort do:
assign this_sort.
apply "go" to this_sort in frame fr_sort.
end.

repeat:
this_one = "".
update this_one with frame fr_one.
if this_one = "" then leave.
find t_list where t_list.listfield = this_one no-lock no-error.
if not available t_list then do:
create t_list.
t_list.listfield = this_one.
end.
end.

hide frame fr_one.

this_sort:list-items in frame fr_sort = "<Choose Sort>,Ascending,Descending".
this_sort = "<Choose Sort>".
repeat:
update this_sort with frame fr_sort.
if this_sort <> "<Choose Sort>" then leave.
end.
if this_sort = "Ascending" then open query q_sort for each t_list use-index idx1.
if this_sort = "Descending" then open query q_sort for each t_list use-index idx2.
enable br_sort with frame fr_sort.
wait-for window-close of current-window.

 
Top