將數組內容排序

PB沒有提供數組的排序功能,實際上我們可以通過利用DataStore來實現.

datastore lds_temp
string ls_err
integer i

long ll_array[] = { 2 , 3, 6, 5 }
string ls_dsdef = &
'release 8; datawindow() table(column=(type=long name=a
dbname="a") )'
//上面的產生DW的語法可能因不同版本有些差異,
//大家可以先在pb中建立一個DW Object,然后利用Edit Source功能查看語法.

lds_temp = CREATE datastore
lds_temp.Create(ls_dsdef, ls_err)
// 將數組內容導入datastore
lds_temp.object.a.current = ll_array
lds_temp.SetSort("a ASC")
lds_temp.Sort()
//取得排序后的結果.
ll_array = lds_temp.object.a.current

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

DESTROY lds_temp

 

你可能感兴趣的:(object,String,table)