Share this page 

Sort an arrayTag(s): Datawindow Powerscript


We create a small datastore and use it to sort our array.
datastore lds_temp
string ls_err
integer i

// change the datastore definition according to the array data type
long ll_array[] = { 2 , 3, 6, 5 }
string ls_dsdef = &
   'release 6; datawindow() table(column=(type=long name=a dbname="a") )'

lds_temp = CREATE datastore
lds_temp.Create(ls_dsdef, ls_err)
// put the array in the datastore
lds_temp.object.a.current = ll_array
lds_temp.SetSort("a ASC")
lds_temp.Sort()
// get back the array
ll_array = lds_temp.object.a.current

FOR i = 1 to Upperbound(ll_array)
  MessageBox("", string(ll_array[i]))
NEXT

DESTROY lds_temp