[Libreoffice-bugs] [Bug 123025] New: ReDim Preserve fails if array is filled by Split
bugzilla-daemon at bugs.documentfoundation.org
bugzilla-daemon at bugs.documentfoundation.org
Mon Jan 28 22:49:04 UTC 2019
https://bugs.documentfoundation.org/show_bug.cgi?id=123025
Bug ID: 123025
Summary: ReDim Preserve fails if array is filled by Split
Product: LibreOffice
Version: 5.1.6.2 release
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: BASIC
Assignee: libreoffice-bugs at lists.freedesktop.org
Reporter: gerhard.weydt at t-online.de
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.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20190128/9d8e1d9e/attachment.html>
More information about the Libreoffice-bugs
mailing list