// in increments of BlockSize
ll_Offset = (Rand(li_Blocks) - 1) * li_BlockSize
//Main Calculation
ll_Return = ll_Offset + Rand(li_Range)
LOOP
Return ll_Return
字符串转为数组
/**************************************************************
Powerbuilder 6.5 / 7.0
long StringToArray( readonly string sString,
readonly string sSeparator,
reference string sOutputArray[] )
This function parses string to array depending on the
string separator. The count of items parsed is returned.
by Mike Bartos (yawor@yawor.com)
****************************************************************/
LONG lPosEnd, lPosStart = 1, lSeparatorLen, lCounter = 1
IF UpperBound(sOutputArray) > 0 THEN sOutputArray = {""}
lSeparatorLen = len(sSeparator)
lPosEnd = Pos (sString, sSeparator, 1)
DO WHILE lPosEnd > 0
sOutputArray[lCounter] = Mid (sString, lPosStart, lPosEnd - lPosStart)
lPosStart = lPosEnd + lSeparatorLen
lPosEnd = Pos (sString, sSeparator, lPosStart)
lCounter++
LOOP
sOutputArray[lCounter] = Right (sString, Len(sString) - lPosStart + 1)
RETURN lCounter
动态创建数据仓库来对数组排序
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.o b j e c t.a.current = ll_array
lds_temp.SetSort("a ASC")
lds_temp.Sort()
// get back the array
ll_array = lds_temp.o b j e c t.a.current
FOR i = 1 to Upperbound(ll_array)
MessageBox("", string(ll_array[i]))
NEXT
DESTROY lds_temp
执行外部程序并等待
OleObject wsh
integer li_rc
CONSTANT integer MAXIMIZED = 3
CONSTANT integer MINIMIZED = 2
CONSTANT integer NORMAL = 1
CONSTANT boolean WAIT = TRUE
CONSTANT boolean NOWAIT = FALSE
wsh = CREATE OleObject
li_rc = wsh.ConnectToNewObject( "WScript.Shell" )
li_rc = wsh.Run("Notepad" , NORMAL, WAIT)
messagebox("hello", "world")
If WAITING, then Run returns any error code returned by the application.
In the example only three CONSTANTs are defined. But more options are available : 0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or
maximized, the system restores it to its original size and position. An
application should specify this flag when displaying the window for the
first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Di