Re: Constant values for Function arguments

Thomas Krumbein <[email protected]> Thu, 18 Aug 2011 13:25:09 +0200
Newsgroups gmane.comp.openoffice.devel.api
Message-ID <[email protected]>
Hey Johnny,

honestly, a lot of your questions/things are "basics"...

VALUE, STRING, FORMULA and DATETIME are reserved words in Basic and
cannot be used as constant or variable names. Ever thought about this?

Try to put a character in Front (i.E. nValue, or myString)  and
everything works as expected....

Best regards
Thomas


Am 18.08.2011 12:52, schrieb Johnny Rosenberg:
> Here's another delicate problem that's easy to work around, but still
> very strange:
>=20
> Module 2:
> =E2=80=94=E2=80=94=E2=80=94Code starts below=E2=80=94=E2=80=94=E2=80=94
> REM  *****  BASIC  *****
>=20
> Option Explicit
>=20
> Public Const VALUE=3D1
> Public Const STRING=3D4
> Public Const FORMULA=3D16
> Public Const DATETIME=3D2
>=20
> Sub HelloWorld
> 	Print "Hello world!"
> End Sub
> =E2=80=94=E2=80=94=E2=80=94End of code=E2=80=94=E2=80=94=E2=80=94
>=20
>=20
> Module1:
> =E2=80=94=E2=80=94=E2=80=94Code starts below=E2=80=94=E2=80=94=E2=80=94
> REM  *****  BASIC  *****
>=20
> Option Explicit
>=20
> Sub Main
> 	Dim A
> 	A=3DVALUE+STRING+FORMULA
> End Sub
> =E2=80=94=E2=80=94=E2=80=94End of code=E2=80=94=E2=80=94=E2=80=94
> Run Main and you will get an error message at =E2=80=9DA=3DVALUE+STRING=
+FORMULA=E2=80=9D.
> If you run step by step (Ctrl+F8 in the BASIC IDE) and stop at that
> line and then hover your mouse pointer over VALUE or STRING or
> FORMULA, you can clearly see its values, but obviously this doesn't
> help. Dimensioning A as Variant, as I did, doesn't help either. If you
> look at VALUE, STRING or FORMULA in the variable monitor (or whatever
> it's called in English), the window at the bottom left, you can see
> that they are Variant/Integer and you can see their correct values.
>=20
> So now, let's move the constant definition to Module1:
> Module 2:
> =E2=80=94=E2=80=94=E2=80=94Code starts below=E2=80=94=E2=80=94=E2=80=94
> REM  *****  BASIC  *****
>=20
> Option Explicit
>=20
> Sub HelloWorld
> 	Print "Hello world!"
> End Sub
> =E2=80=94=E2=80=94=E2=80=94End of code=E2=80=94=E2=80=94=E2=80=94
>=20
>=20
> Module1:
> =E2=80=94=E2=80=94=E2=80=94Code starts below=E2=80=94=E2=80=94=E2=80=94
> REM  *****  BASIC  *****
>=20
> Option Explicit
>=20
> Public Const VALUE=3D1
> Public Const STRING=3D4
> Public Const FORMULA=3D16
> Public Const DATETIME=3D2
>=20
> Sub Main
> 	Dim A
> 	A=3DVALUE+STRING+FORMULA
> End Sub
> =E2=80=94=E2=80=94=E2=80=94End of code=E2=80=94=E2=80=94=E2=80=94
>=20
> Now Main in Module1 works as expected, but take a look in the monitor
> again. Those constants appears in exactly the same way this time as
> before, the only exception is that this works.
> I would be very grateful for an explanation about this. Is there
> REALLY a logical reason for it to be this way or should I report this
> as a bug as soon as possible?
>=20
> Of course I can define those constants in every module, but isn't one
> of the points by declaring as Public that I can reach them in all my
> modules? Well, in this case I can; I just can't use them, at least not
> when adding them to each other.
> =E2=80=9DA=3DVALUE=E2=80=9D works in both my examples, but obviously no=
t
> =E2=80=9DA=3DVALUE+STRING+FORMULA=E2=80=9D for some reason I am sure ab=
solutely nobody
> can explain, so please prove me wrong here=E2=80=A6!
>=20
> :D
>=20
>=20
> Kind regards
>=20
> Johnny Rosenberg
> =E3=82=B8=E3=83=A7=E3=83=8B=E3=83=BC=E3=83=BB=E3=83=AD=E3=83=BC=E3=82=BC=
=E3=83=B3=E3=83=90=E3=83=BC=E3=82=B0

--=20
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help