Description: The statement 'On expression GoSub' does not work properly. When expression is 0, the statement GoSub should not be executed. Actually it is executed on the following line. When statements GoSub are imbricated the next Return statement does not jump to the proper line. Steps to Reproduce: Sub Main Dim i As Integer GoSub Sub1 Print i Exit Sub Sub1: On 1 GoSub SubA, SubB i=i+1 Return SubA: Return SubB: Return End Sub Actual Results: 2 Because the line i=i+1 is executed twice! Expected Results: 1 Reproducible: Always User Profile Reset: No Additional Info: [Information automatically included from LibreOffice] Locale: en-US Module: BasicIDE [Information guessed from browser] OS: Mac OS X (All) OS is 64bit: no
I copied the code, pasted it on the Basic IDE and ran it... I got 1 as result. Can you test this again? System info Version: 24.2.1.2 (X86_64) / LibreOffice Community Build ID: 420(Build:2) CPU threads: 12; OS: Linux 6.5; UI render: default; VCL: kf5 (cairo+wayland) Locale: pt-BR (pt_BR.UTF-8); UI: en-US Ubuntu package version: 4:24.2.1~rc2-0ubuntu0.23.10.1~lo1 Calc: threaded
Created attachment 193251 [details] Result from the macro
Thanks Rafael for your quick response. I made a mistake when I copied the code. Change 'On 1 GoSub SubA, SubB' By 'On 0 GoSub SubA, SubB' You'll get 2 as result Cheers
Hello Could you tell me if you get the same result when you run the following code? Cheers Sub Main Dim i As Integer GoSub Sub1 Print i Exit Sub Sub1: On 0 GoSub SubA, SubB i=i+1 Return SubA: Return SubB: Return End Sub
I can confirm with Version 4.1.0.0.alpha0+ (Build ID: efca6f15609322f62a35619619a6d5fe5c9bd5a) and Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 2887ffbf240aa70330cb50bf810170cf9c896405 CPU threads: 4; OS: Linux 6.5; UI render: default; VCL: gtk3 Locale: cs-CZ (cs_CZ.UTF-8); UI: en-US Calc: threaded Jumbo Help: https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03090303.html?DbPAR=BASIC#bm_id3153897 "If expression is 0, the statement is not executed."
@Andreas, this one might interest you.
Thank you Rafael for the ping. It is on my list. Lot of work currently so less libreoffice :(