Moves all non-empty strings (text) in an array to the beginning
of the array. The resulting StringArray has the same number of
elements as the input array, but empty entries and entries that
contain only blanks appear at the end of the array.
|
[Count =:] COMPRESSARRAY(StringArray)
|
Parameters
- StringArray
-
Type: Array of strings
The string array that you want to compress.
Property Value/Return Value
Type: Integer
The number of non-empty strings that were compressed.
Remarks
Example
This example shows how to use the COMPRESSARRAY
function. The input StringArray has the following values:
Joe Raybon
|
|
|
One Meca Way
|
Atlanta
|
The output StringArray has the following values:
Joe Raybon
|
One Meca Way
|
Atlanta
|
|
|
All non-empty entries have been moved to the beginning
of the array.
This example requires that you create the following
text constants in the C/AL Globals window.
Text constant |
ENU value |
Text000
|
'Joe Raybon'
|
Text001
|
'One Meca Way'
|
Text002
|
'Atlanta'
|
Text003
|
'Before compression, the address is…\%1\%2\%3\%4\%5\%6'
|
Text004
|
'After compression, the address is…\%1\%2\%3\%4\%5\%6'
|
|
Copy Code |
Name[1] := ''; // Empty String
Name[2] := Text000;
Name[3] := Text001;
Name[4] := ' '; // A string containing blanks
Name[5] := Text002;
Name[6] := '';
MESSAGE(Text003, Name[1], Name[2], Name[3], Name[4], Name[5], Name[6]);
COMPRESSARRAY(Name); // The empty lines (strings) are removed
MESSAGE(Text004, Name[1], Name[2], Name[3],Name[4], Name[5], Name[6]);
|
The first message window displays the following:
Before compression, the address is...
Joe Raybon
One Meca Way
Atlanta
The second message window displays the following:
Joe Raybon
One Meca Way
Atlanta
All empty and blank strings, which cause blank lines,
are moved to the end of the array. The other elements are moved to
the beginning of the array.
Note |
Empty lines are not printed if they occur on the first or last
line in a message window.
|
See Also