문제

How can you tell if an array is empty or even what it contains? I know those are two different questions. Please be kind.

I instantiate the array this way:

local array MyFiles[1,5]
nFilesFound = ADIR( MyFiles, qazMSG + '*.*')
도움이 되었습니까?

해결책

To check whether an array is empty takes two steps. First, you check whether there's only one element:

Then, you have to check whether the data in that element is empty by whatever standards make sense in content. So, in general, you might use something like:

IF ALEN(aMyArray) = 1 and EMPTY(aMyArray)
  * Array is empty
ENDIF

But in some situations, the first element being empty might be valid.

In the case you show, it's much easier. The function ADIR() returns the number of files found. So you can just check nFilesFound to see whether it's 0.

To try to answer your other question, you can see the shape of an array with the ALEN() function:

ALEN(aMyArray) or ALEN(aMyArray, 0) tells you the total number of elements in the array.

ALEN(aMyArray,1) tells you the number of rows in the array.

ALEN(aMyArray,2) tells you the number of columns.

You can multiply those last two to get the first.

Tamar

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