## How to create numerology function?

Keyboard macros or custom scripts

### How to create numerology function?

Hello, I'm trying to make a numerology funtion to be utilized in Calc. I understand how to make a function and have already made a Fibonacci sequence function, a human-to-cat-years conversion function, and the previous function's inverse. But inorder to make the numerology function I need to know how to convert the letters to their respective numbers and add the digits of the resulting number together. I understand how to create the function when I have a preset phrase, but I'm unsure when the phrase is variable. Help me, please and thank you.
OOo 3.2.1 on MS Windows Vista Home Premium
Valen Banpaia

Posts: 10
Joined: Mon Jun 22, 2009 7:37 am

### Re: How to create numerology function?

In Python:
Code: Select all   Expand viewCollapse view
`LetterMap={'v':13,'o':259.23,'d':987.1234}n = 0For c in 'voodoo':  n += LetterMap[c]`
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x

Villeroy
Volunteer

Posts: 25365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

### Re: How to create numerology function?

Thanks for the suggestion, but Python macros don't work on mine (whether they don't work on my computer or version of OOo, I do not know).
OOo 3.2.1 on MS Windows Vista Home Premium
Valen Banpaia

Posts: 10
Joined: Mon Jun 22, 2009 7:37 am

### Re: How to create numerology function?

I agree with Villeroy that writing this in Python would be far easier. The Python macros work fine on my OOo 3.1 with XP and the Python is now version 2.6. It might be worth starting another thread to ask why your python macros don't work. In any case, if you post your code for finding the value of a set string, it might be easier to suggest how to change it to accept any input.

Your set of functions for a Fibonacci sequence, cat years and numerology is quite an eclectic set!
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
FJCC
Moderator

Posts: 6501
Joined: Sat Nov 08, 2008 8:08 pm

### Re: How to create numerology function?

Thanks to Villeroy for doing all the heavy lifting on this. His solution is here. I thought I would post my version in this thread just to have the solution with the original question. Obviously, I used his code from 2007 as a template.
The Basic function I wrote is:

Code: Select all   Expand viewCollapse view
`Function Numer(word)MSPF = createUnoService("com.sun.star.script.provider.MasterScriptProviderFactory")scriptPro = MSPF.createScriptProvider("")xScript = scriptPro.getScript("vnd.sun.star.script:Numerology.py\$Main?language=Python&location=user")Numer = xScript.Invoke(Array(word), Array(), Array())End function`

I modified his python code slightly, since mine insists on the "for" being all lower case and I didn't want to think too hard about the value of "voodoo"
Code: Select all   Expand viewCollapse view
`LetterMap={'v':1,'o':2,'d':3}def Main(word):  n = 0  for c in word:    n += LetterMap[c]   return n`

I saved that in a text file named Numerology.py in the folder C:\Documents and Settings\username\Application Data\OpenOffice\3\user\Scripts\python. Using the formula

Code: Select all   Expand viewCollapse view
`=Numer("voodoo")`

returns the value 12, as expected. Obviously you will have to expand the dictionary in the python code to include characters other than 'v', 'o', and 'd'
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
FJCC
Moderator

Posts: 6501
Joined: Sat Nov 08, 2008 8:08 pm

### Re: How to create numerology function?

Okay, I tried that and said that it was an invalid location. I did, I made sure to, correctly replace the users.
OOo 3.2.1 on MS Windows Vista Home Premium
Valen Banpaia

Posts: 10
Joined: Mon Jun 22, 2009 7:37 am

### Re: How to create numerology function?

You only have to replace the username in the file path with whatever is correct for your system. The "user" farther down the folder name (OpenOffice\3\user\Scripts\python) is the folder name of your profile and needs to remain "user". Sorry I wasn't clear about that.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
FJCC
Moderator

Posts: 6501
Joined: Sat Nov 08, 2008 8:08 pm

### Re: How to create numerology function?

Okay, I did I fixed that and it's still telling me the same thing.
OOo 3.2.1 on MS Windows Vista Home Premium
Valen Banpaia

Posts: 10
Joined: Mon Jun 22, 2009 7:37 am