High Unicode Numbers

Creating a macro - Writing a Script - Using the API

High Unicode Numbers

Postby alf50 » Tue May 12, 2020 5:21 am

I am looking for a way to read high UNICODE(127137) numbers in a macro. The number represents the UNICODE Number for an Ace of Clubs. I can use the formula in a cell "=UNICODE(W2)" to display the High UNICODE() value of 127137 for the Ace of Clubs string character in Cell W2, but I cannot get the UNICODE() or UNICHAR() commands to work within a Macro.

All I get is "Sub-procedure or function procedure not defined."

The procedure must be defined in OpenOffice for the UNICODE() function to work within a Calc Cell, but how do I call it from my macro?

I have a awkward way of doing this by Copying the playing card symbol into cell W2, then reads the double precision value from the "=UNICODE(W2)" cell, but life would be much easier if I could just call the function directly in my macro.

A response to a person wanting to due the same thing for Musical Instrument symbols, showed the use of UNICHAR() as a way of doing this, but when I try it, it only errors out (As stated above).

Any help would be greatly appreciated!
OpenOffice 4.1.5 on Mac El Capitan(10.11.6) and MS Windows10
Posts: 102
Joined: Sun Jun 13, 2010 2:55 pm

Re: High Unicode Numbers

Postby Zizi64 » Tue May 12, 2020 6:25 am

but I cannot get the UNICODE() or UNICHAR() commands to work within a Macro.

There are two command pairs in the StarBasic for handling the characters and the the character codes. These are the Chr/ChrW and the Asc/AscW functions The Chr/Asc functions have a 8 bit parameters (0-255), and the ChrW/AscW functions have 16 bit parameters (0-65535). You can call them directly from a StarBasic Macro
From the LibreOffice HELP:

ChrW(Expression As Integer)

Return value:

Expression: Numeric variables that represent a valid 16 bit Unicode value (0-65535). An empty value returns error code 5. A value out of the range [0,65535] returns error code 6.

Error codes:
5 Invalid procedure call
6 Overflow

Otherwise you can call the built-in Cell functions from a macro, but it is not a simple task. You must use the FUNCTIONACCESS and you must pass the parameters as an Array(). (In this case you can not pass a cell reference directly, as you can do it when you use the function in a Cell)

See this topic:
https://forum-test.openoffice.org/en/fo ... 45&t=75288
Tibor Kovacs, Hungary; LO6.1.6, 6.2.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.4.5;AOO4.1.7
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Posts: 9427
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests