<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - ReDim Preserve fails if array is filled by Split"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=123025">123025</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ReDim Preserve fails if array is filled by Split
</td>
</tr>
<tr>
<th>Product</th>
<td>LibreOffice
</td>
</tr>
<tr>
<th>Version</th>
<td>5.1.6.2 release
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>UNCONFIRMED
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>BASIC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>libreoffice-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gerhard.weydt@t-online.de
</td>
</tr></table>
<p>
<div>
<pre>If an array is filled by the Split function, subsequent use of ReDim always
emties the array, regardless whether it worked befor.
Try this test code (Xray has been used because it easily displays the array; if
you don't want to install it, use msgbox arr(0) instead, seeing arr(0) empty
will be convincing enough). The Xray calls are numbered to fit the output
below.
sub test
dim s as string, arr(1) as string
arr(0) = "aa"
arr(1) = "bb"
Xray arr '[1]
ReDim Preserve arr(1)
Xray arr '[2]
s = "a/b"
arr = Split(s, "/")
Xray arr '[3]
ReDim Preserve arr(1)
Xray arr '[4]
arr(0) = "aa"
arr(1) = "bb"
Xray arr '[5]
ReDim Preserve arr(1)
Xray arr '[6]
end sub
Executing this macro you will get:
[1] after entering data: correct
Tabelle : T( 0 To 1 ) As string
(0) | string : "aa"
(1) | string : "bb"
[2] after ReDim Preserve: correct
Tabelle : T( 0 To 1 ) As string
(0) | string : "aa"
(1) | string : "bb"
[3] after assigning the values by Split: correct
Tabelle : T( 0 To 1 ) As variant
(0) | string : "a"
(1) | string : "b"
[4] after ReDim Preserve: w r o n g
Tabelle : T( 0 To 1 ) As empty
(0) | <empty>
(1) | <empty>
[5] after entering new data: still wrong, even though this should be as in [1]
Tabelle : T( 0 To 1 ) As empty
(0) | <empty>
(1) | <empty>
[6] after ReDim Preserve: wrong, consequently
Tabelle : T( 0 To 1 ) As empty
(0) | <empty>
(1) | <empty>
So it seems that assigning values to the array by Split does something wrong to
the array, such that ReDim Preserve cannot find the correct information.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>