[Solved] Get exact type for a variant

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Locked
User avatar
Mr.Dandy
Posts: 461
Joined: Tue Dec 11, 2012 4:22 pm

[Solved] Get exact type for a variant

Post by Mr.Dandy »

Hi folks

in a function, I receive a variant
Is it possible to analyze the type?
I've found the instruction IsObject but nothing to test whether it's a boolean, an integer or a string
Last edited by Mr.Dandy on Fri Dec 13, 2024 9:24 am, edited 1 time in total.
OpenOffice 4.1.12 - Windows 10
JeJe
Volunteer
Posts: 3064
Joined: Wed Mar 09, 2016 2:40 pm

Re: Get exact type for a variant

Post by JeJe »

vartype(variable)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Lupp
Volunteer
Posts: 3693
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Get exact type for a variant

Post by Lupp »

Mr.Dandy wrote: Thu Dec 12, 2024 10:16 am ... whether it's a boolean, an integer or a string.
The answer by @JeJe shows how to get the most detailed information, but you need to interpret it based on code numbers.
You can also use the function Typename(variable). In case variable is an array, a pair of parentheses is appended to the returned name.
On Windows 10: LibreOffice 25.2.2 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Locked