Bug 140118

Summary: Incorrect example in Help for BASIC function WaitUntil
Product: LibreOffice Reporter: [REDACTED] <noreply+70426>
Component: DocumentationAssignee: Olivier Hallot <olivier.hallot>
Status: VERIFIED FIXED    
Severity: trivial CC: olivier.hallot
Priority: medium    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard: target:7.2.0
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 80430    

Description [REDACTED] 2021-02-03 10:56:38 UTC
Description:
LibreOffice Help page https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03130610.html?DbPAR=BASIC contains the following Example for WaitUntil Statement (BASIC)

> REM Wait until 6:00 PM then call MyMacro.
> REM If after 6:00 PM, exit.
> Sub ExampleWaitUntil
> Dim vTimeschedule As Long
>    vTimeSchedule = Date() + TimeValue("18:00:00")
>    If vTimeSchedule < Now() Then Exit Sub
>    WaitUntil vTimeSchedule
>    Call MyMacro
> End Sub

This example does not work as intended, due to declaration "Dim vTimeschedule As Long", which is turning vTimeschedule into integer. 

The documentation is incorrect here and requires "Dim vTimeschedule As Double" to demonstrate what is being intended.

Steps to Reproduce:
1. Open help page LibreOffice Help page https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03130610.html?DbPAR=BASIC
2. Implement the example given (with some adapted reasonable TimeValue) and (for testing purpose) replace the "Call Macro" by a MsgBox statement.
3. Start the makro


Actual Results:
[1] You need to wait until midnight (case TimeValue >  "12:00:00") 
[2] Macro finishes immediately (case TimeValue <  "12:00:00") 

Expected Results:
MsgBox appears at exact time give in TimeValue

Example in documentation needs to be changed to:

- Dim vTimeschedule As Long 
+ Dim vTimeschedule As Double



Reproducible: Always


User Profile Reset: No



Additional Info:
See also question: https://ask.libreoffice.org/en/question/291019/macro-show-msgbox-at-specific-time-of-the-day/
Comment 1 [REDACTED] 2021-02-18 17:14:44 UTC
Line 40 in https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03130610.xhp?r=b1aec63b

shows the correct entry. 

 <paragraph role="bascode" id="par_id3154367" localize="false">Dim vTimeschedule As Long</paragraph>
Comment 2 [REDACTED] 2021-02-18 17:15:55 UTC
(In reply to Uwe Auer from comment #1)
> Line 40 in
> https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/
> 03130610.xhp?r=b1aec63b
> 
> shows the correct entry. 
> 
>  <paragraph role="bascode" id="par_id3154367" localize="false">Dim
> vTimeschedule As Long</paragraph>

correction: shows the **in**correct entry.
Comment 3 Olivier Hallot 2021-03-03 16:03:46 UTC
Thanks for the precise report, patch is on the way.

(if you want to challenge your skills and fix such mistake yourself, have a look at these instructions: https://wiki.documentfoundation.org/Documentation/GerritEditing )
Comment 4 Commit Notification 2021-03-03 16:56:53 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/help/commit/c34bb965f993bef53fa739de6f3aaa97de2c2ef9

tdf#140118 Fix Help for BASIC function WaitUntil
Comment 5 [REDACTED] 2021-07-08 11:30:55 UTC
Fixed in target 7.2.0 -  https://help.libreoffice.org/7.2/en-US/text/sbasic/shared/03130610.html?DbPAR=BASIC