Bug 121920 - Mid function doesn't replace to nothing
Summary: Mid function doesn't replace to nothing
Status: RESOLVED DUPLICATE of bug 121325
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.1.3.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2018-12-05 12:49 UTC by sunweb
Modified: 2019-11-21 19:03 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
mid replace string (30.70 KB, image/jpeg)
2018-12-08 14:37 UTC, Oliver Brinzing
Details
Macros with example (25 bytes, text/plain)
2018-12-20 11:04 UTC, sunweb
Details
Macros inside this ODS file (8.45 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-12-21 09:22 UTC, sunweb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sunweb 2018-12-05 12:49:04 UTC
mystring=" 40"
i = InStr(mystring, " ")
Mid(mystring, i, Len(" "), "")

In this example Mid should replace first space with nothing, effectively deleting it. But it does nothing. The last time function worked properly was in 6.0.7.
Comment 1 sunweb 2018-12-05 12:56:35 UTC
Also note that if you use symbol directly(CHR$(8205)) it does the job but it should work with simple double quotes as well.
Comment 2 raal 2018-12-06 06:53:46 UTC
Hello,

Thank you for filing the bug. Please send us a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO', so please do change it back to 'UNCONFIRMED' once you have attached a document.
(Please note that the attachment will be public, remove any sensitive information before attaching it.)
How can I eliminate confidential data from a sample document?
https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F
Thank you


tested with 4.1 and 6.3 version and result is empty string.
Comment 3 Oliver Brinzing 2018-12-08 14:36:28 UTC
there was an issue with mid function, fixed in lo 6.1.4

[Bug 121325] 4-argument form of Mid() BASIC function broken in 6.x 
(worked in 5.x and OO)
https://bugs.documentfoundation.org/show_bug.cgi?id=121325

i cannot confirm this with lo 6.1.4.1, see attached picture
Comment 4 Oliver Brinzing 2018-12-08 14:37:32 UTC
Created attachment 147383 [details]
mid replace string
Comment 5 Stephan Bergmann 2018-12-10 08:27:51 UTC
(In reply to sunweb from comment #1)
> Also note that if you use symbol directly(CHR$(8205)) it does the job but it
> should work with simple double quotes as well.

This confuses me.  CHR$(8205) is U+200D ZERO WIDTH JOINER.  I find no occurrence of that (usually invisible) character in your example code in comment 0 (but which may be due to it getting lost when you copied the example code into this issue?).

Where exactly would you use CHR$(8205) in the example code, and how exactly would it change the behavior when executing the code.
Comment 6 sunweb 2018-12-20 11:04:48 UTC
Created attachment 147690 [details]
Macros with example
Comment 7 Stephan Bergmann 2018-12-20 15:56:25 UTC
(In reply to sunweb from comment #6)
> Created attachment 147690 [details]
> Macros with example

The content of that short text/plain attachment is just "Macros attached in a file"?
Comment 8 sunweb 2018-12-21 09:20:19 UTC
Sorry, i thought i've uploaded ODS document with macros examples.
Comment 9 sunweb 2018-12-21 09:22:57 UTC
Created attachment 147734 [details]
Macros inside this ODS file
Comment 10 Stephan Bergmann 2018-12-21 14:19:32 UTC
(In reply to sunweb from comment #9)
> Created attachment 147734 [details]
> Macros inside this ODS file

Ah, so the result of

	mystring=" 40"
	i = InStr(mystring, " ")
	Mid(mystring, i, Len(" "), CHR$(8205))

is a mystring of length 3, with a first invisible character U+200D ZERO WIDTH JOINER.

The original issue from comment 0 is a duplicate of issue 121325, and should be fixed in LO 6.1.4, as confirmed in comment 3.

*** This bug has been marked as a duplicate of bug 121325 ***