Bug 125763 - HELP: Wrong help text for variable type declaration
Summary: HELP: Wrong help text for variable type declaration
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
6.2.2.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:6.4.0
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-06 20:54 UTC by Gerhard Weydt
Modified: 2019-06-11 12:25 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Weydt 2019-06-06 20:54:27 UTC
The following text section in the help for "Using variables" for Basic (the URL on my computer is 
file:///C:/Program%20Files/LibreOffice/help/en-GB/text/sbasic/shared/01020100.html?DbPAR=BASIC#bm_id3149346
) seems to be wrong:

It is very important when declaring variables that you use the type-declaration character each time, even if it was used in the declaration instead of a keyword. Thus the following statements are invalid:

Dim a$           Declares "a" as a String

a="TestString"   Type-declaration missing: "a$="

I tested it, it works without a$ in the second statement. The text is probably outdated for a long time.
The sentence, by the way, seems to me badly constructed, "even" is misplaced, and the meaning is not very clear. I understand that the meaning is: "if you use the type-declaration character in the declaration, then you must use it in all statements using this variable". I add this for the case that my test was incomplete, and a suitable help text is still necessary.
Comment 1 Olivier Hallot 2019-06-06 22:48:55 UTC
I also tested and confirmed. It looks that if you declare A$ then you should use A$ in the code for the sake of readability and maintainability.

However I am not sure if this is a documentation issue or a bug in the implementation of LO Basic.
Comment 2 Gerhard Weydt 2019-06-06 23:23:24 UTC
(In reply to Olivier Hallot from comment #1)
> I also tested and confirmed. It looks that if you declare A$ then you should
> use A$ in the code for the sake of readability and maintainability.
> 
> However I am not sure if this is a documentation issue or a bug in the
> implementation of LO Basic.

I don't consider this as a bug in the implementation, it works as well with a$ as with simply a, as is optimal for compatibility sake.
But I understood that we have to report documentation issues in bugzilla. And the main implication of the text in consideration is that you have to use the $ extension (in the example) every time you use the variable, which is obviously wrong; therefore the text section should be corrected.
As "for the sake of readability and maintainability": if one would understand a$ as a name for a variable to be always used, that would astonish me.
Comment 3 Olivier Hallot 2019-06-07 00:50:35 UTC
How about


-----8<-----
It is recommended to declare variable either by the type-declaration character or by the variable type keyword. Thus the following statements are good programming practice:

Dim A$
Dim A as String

-----8<-----
Comment 4 Olivier Hallot 2019-06-07 15:03:10 UTC
(In reply to Olivier Hallot from comment #3)
> How about
> 
> 
> -----8<-----
> It is recommended to declare variable either by the type-declaration
> character or by the variable type keyword. Thus the following statements are
> good programming practice:
> 
> Dim A$
> Dim A as String
> 
> -----8<-----

Never mind. Actually I am removing the whole paragraph and example. The example just above says all on variable declaration, no need for confusion.
Comment 5 Gerhard Weydt 2019-06-08 21:19:23 UTC
(In reply to Olivier Hallot from comment #4)
> (In reply to Olivier Hallot from comment #3)
> > How about
> > 
> > 
> > -----8<-----
> > It is recommended to declare variable either by the type-declaration
> > character or by the variable type keyword. Thus the following statements are
> > good programming practice:
> > 
> > Dim A$
> > Dim A as String
> > 
> > -----8<-----
> 
> Never mind. Actually I am removing the whole paragraph and example. The
> example just above says all on variable declaration, no need for confusion.

Yes, that's OK. I could have suggested that myself!
I set the status to RESOLVED.
Comment 6 Commit Notification 2019-06-11 12:25:00 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/+/d884a65408c8d477292c8dab2d17258f25f1322b%5E%21

tdf#125763 Remove confusing remark on Variable declarations