Page 1 of 1

High Unicode Numbers

Posted: Tue May 12, 2020 5:21 am
by alf50
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!

Re: High Unicode Numbers

Posted: Tue May 12, 2020 6:25 am
by Zizi64
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:
Syntax:
ChrW(Expression As Integer)

Return value:
String

Parameters:
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