User:Blue.painting/Useful tricks for LibreOffice macro programming

This page includes various useful tricks for LibreOffice macro programming.

Inspect type
To inspect type, do  for example.

Access macro
To specify full macro path in script, such as one embedded in document, do the following:

Variable declarations
The shorthand for the types is: % -integer; & -long; @ -currency; # -double; ! -single; $ -string. For example: and note that if you do then only  will be an Integer, while the others will be Variant. More info in this VBA link.

Select Case
This is the switch case in Basic. Example below.

Comparing
Use  when comparing numbers or strings such as   or "hello", and use   when comparing objects.

Typecasts
The RefCard - LibOBasic-5-ExecLib-Flat-A4-EN-v101.pdf has nice info.

To typcast to stuff, for example

Options
More information in OOME p. 33.

MsgBox
For multi-line in a, see this example from OOME3 p. 208:

See OOME 3.0 on p. 208. It mentions that for  we have There is a table in OOME to should that for the dialog types we have

NOTE: there is an alternative to the numbers. An alternative is  for example. I need to find table which says what each number corresponds to in terms of an "enum".

ASCII codes
In OOME v3 p 44 we have nice table for useful ASCII codes.

You can find more ASCII codes at www.asciitable.com or for instance WP:ASCII#Printable characters.

Dialog
Create  dialog in your ODF file, which will handle the localization (l10n). You create the dialog by. Then you can edit it. First select the dialog at the border, resize if you want, and add a  (such as "L10N module"). Then add a Group Box which is indicated by the icon with a box & XY, and will have the name FrameControl1 and you can change lable to "Localized MsgBox". Inside of the FrameControl, you can add a Label1 which is indicated by an "AB" icon shown as "Label field". In this label you will add strings for each locale.

Code
In addition to  which will contain your macro code, create an   module as well.

The latter module will fetch the content of the dlgMsgBox, and the result will be in the language of the user locale. The code should look something like this:

For example to test it, you can do