| View previous topic :: View next topic |
| Author |
Message |
rocket_scientist General User


Joined: 02 Jun 2006 Posts: 16 Location: Houston, TX
|
Posted: Tue Jun 06, 2006 11:08 am Post subject: special symbols and chr$() |
|
|
This is kindof interesting... does anyone know of a listing of all the characters accessable with chr$()? I made a loop that would start at 1 and spit out every chr$() character... but it was SLOW... i stopped it somewhere in the four thousand range. It was probably just the process of actually inserting the text into the doc that was too slow.
Basically I need a new sub to insert a check-mark (in the past i believe we used a square root as a check) and also a right-pointing arrow. I was able to record a macro during which I did an Insert special character command... and while the code I got out works, it doesn't look very efficient or friendly:
| Code: | sub Check
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Symbols"
args1(0).Value = ""
args1(1).Name = "FontName"
args1(1).Value = "Symbol"
dispatcher.executeDispatch(document, ".uno:InsertSymbol", "", 0, args1())
end sub |
In that code, the value of args1(0) is not a character that will even display correctly in my basic editor.
Isn't there an easy way I can find a chr$() value to insert a check or arrow or any other symbol i might need? |
|
| Back to top |
|
 |
rocket_scientist General User


Joined: 02 Jun 2006 Posts: 16 Location: Houston, TX
|
Posted: Tue Jun 06, 2006 11:16 am Post subject: |
|
|
| I tried using =Code("?")... but that didn't work. It did not recognize the special characters. |
|
| Back to top |
|
 |
noranthon Super User

Joined: 07 Jul 2005 Posts: 3323
|
Posted: Tue Jun 06, 2006 5:23 pm Post subject: |
|
|
The lookup tables may help. =CODE() accurately gets the number for ">" as 62; it mistakes the "check" (my "tick") for a question mark. The Ascii code for the tick does not work in Basic either. Unicode may be the most likely but finding it would take forever.
A job for that other macro recorder (only works on a single cell) which got this:
| Code: | With ThisComponent.CurrentSelection
.CharFontCharSet = -1
.CharFontCharSetAsian = -1
.CharFontCharSetComplex = -1
.CharFontFamilyAsian = 5
.CharFontFamilyComplex = 5
.CharFontNameAsian = "DejaVu Sans"
.CharFontNameComplex = "DejaVu Sans"
.CharFontStyleNameAsian = "Book"
.CharFontStyleNameComplex = "Book"
.FormulaLocal = "√"
End With |
This code entered a tick:
| Code: | | ThisComponent.CurrentSelection.FormulaLocal = "√" |
_________________ search forum by month |
|
| Back to top |
|
 |
rocket_scientist General User


Joined: 02 Jun 2006 Posts: 16 Location: Houston, TX
|
Posted: Wed Jun 07, 2006 7:56 am Post subject: |
|
|
OK... for the sake of anyone else with the same problem... we have two solutions (not including recording the macro)
noranthon found that the other macro recorder captured the special unicode character in the basic code itself. I don't know any other way to do that except to insert the ASCII/ANSI character into a blank document and then copy-paste the character into the basic code. That seems to work ok in this case.
The other way I found is to find the Unicode number for the character from the unicode tables I found at: http://www.unicode.org/charts/ The unicode numbers are in base-16, but when I converted them to base-10 and used that number with the Chr() command, I got the character I was looking for.
So in this case, my check mark was Unicode 221A which converts to base-10 as 8730. then chr(8730) gave me my check. |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 7664 Location: Kentucky, USA
|
Posted: Wed Jun 07, 2006 10:08 am Post subject: |
|
|
You can use the hex number directly, e.g., Chr(&h221A). Here is another example of how to insert the character. | Code: | Sub Main
oDoc = ThisComponent
oVC = oDoc.CurrentController.getViewCursor
oVC.String = Chr(&h2713)
oVC.collapseToEnd
End Sub |
|
|
| Back to top |
|
 |
rocket_scientist General User


Joined: 02 Jun 2006 Posts: 16 Location: Houston, TX
|
Posted: Wed Jun 07, 2006 2:16 pm Post subject: |
|
|
Excellent... Thanks John, now I don't have to do the base conversion.
I realize I'm running this topic into the ground... but the Unicode charts also show some characters with 5-digit hex codes (for example musical symbols). Chr() complains they are outside of the 65k characters it knows. How can I get these? |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 7664 Location: Kentucky, USA
|
Posted: Fri Jun 09, 2006 4:19 am Post subject: |
|
|
| This question has been asked before but I have never seen an answer. Of course you would have to have a font that contained such characters for a start. |
|
| Back to top |
|
 |
|