Download it now!
Bug 86501 - declaring variables: only last one initialized
Summary: declaring variables: only last one initialized
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.3.3.2 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-20 21:51 UTC by Rene Engelhard
Modified: 2015-04-09 12:47 UTC (History)
2 users (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 Rene Engelhard 2014-11-20 21:51:26 UTC
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770378  

--- snip ---
I use libreoffice base, i was testing some macros, and i see an important problem.
It's a declaration variable problem.

Sub Test01

	dim ID as integer   'or as long
	msgbox(ID)

End Sub

====> The Box open "0"

Sub Test02

	dim ID1, ID2 as integer   'or as long
	msgbox(ID1)
	msgbox(ID2)

End Sub

====> The first Box open ""
====> The second box open "0"
[...]
I've forgotten to specify that with many variables, just the last is 
initialized to zero.

For exemple:
dim ID1, ID2, ID3, ID4 as long

Iknow that it's recommended**to initialize them but it's possible that 
it's just a bug.
--- snip ---

The help (at https://help.libreoffice.org/Basic/Using_Variables#Initial_Variable_Values) indeed says:
"Initial Variable Values

As soon as the variable has been declared, it is automatically set to the "Null" value. Note the following conventions:

Numeric variables are automatically assigned the value "0" as soon as they are declared."
Comment 1 raal 2014-11-21 18:47:43 UTC
I can confirm with Version: 4.4.0.0.alpha2+
Build ID: 2f342c61616418c6ad7303d7f5efa27a28378681
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:master, Time: 2014-11-16_00:33:40
Comment 2 Matthew Francis 2015-04-09 12:47:19 UTC
This line does not do what you think it does:

"dim ID1, ID2, ID3, ID4 as long"

You have declared three "variant" type variables and only one "long"
To make them all four "long", you must add the qualifiers to each variable name