문제

string array[]
long lBound, uBound

lBound = LowerBound(array[]) // = 1, empty array value
uBound = UpperBound(array[]) // = 0, empty array value

array[1] = 'Item 1'
array[2] = 'Item 2'
array[3] = 'Item 3'

lBound = LowerBound(array[]) // = 1
uBound = UpperBound(array[]) // = 3

array[3] = '' //removing item 3

lBound = LowerBound(array[]) // = 1, still
uBound = UpperBound(array[]) // = 3, still (but array[3] is nulled?

I think the line 'array[3]' is wrong, but I think I've read that this should remove the array cell.

What would be the right way to remove an array cell? Does it depend on object type? (String vs Number vs Object)

Or

Can one manipulate the UpperBound value to make it work?

i.e. after removing Item 3, I want the UpperBound, or arraylength, to be 2, since this is logically correct.

도움이 되었습니까?

해결책

[ME] 참조는 SharePoint / Office의 함수 유형입니다.공식 및 기능에 대한 공식 문서를 확인하려면 다음 링크를 사용하십시오.이것은 당신이 찾고있는 나란히 비교가 정확히 아닙니다. 그러나 그것은 상당히 잘 자세히 알 수 있습니다.

구체적으로 말하면, 정보에 들어가면 |Me Function [me]가 어떻게 작동하는지 설명하기 위해 그들이 열거 한 것을 볼 수 있습니다.그들은 "... 현재 사용자 이름을 반환합니다."뿐만 아니라.

다른 팁

Powerbuilder doesn't really have any good array manipulation functions built in (that i know of).

You can achieve what you are trying to do by copying the values you want to retain to a new unbounded array.

For example

int i
string array3[] = {'Item 1', 'Item 2', 'Item 3'}, array2[]

for i = 1 to 2
    array2[i] = array3[i]
next
UpperBound(array2[]) // = 2

In your example you are removing only the latest value - this can be done even more simply by copying the whole array to a new smaller, bounded array like so:

string array3[] = {'Item 1', 'Item 2', 'Item 3'}, array2[2]

array2 = array3
UpperBound(array2[]) // = 2

When I was writing a comment for Dan's answer I started thinking about what I do use, since I don't like PFC's lists. What I use is a DataStore, which, if you think about it the right way, is like a list on steroids.

Rather than copying the array, if you need to keep track of a changing upper bound of the array (for instance, if you are trying to use it as something like a stack), why not just keep a separate integer variable indicating the last real element's index? Seems a lot simpler and more efficient than the copying solutions suggested above!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top