How to create numerology function?
-
- Posts: 10
- Joined: Mon Jun 22, 2009 7:37 am
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
Re: How to create numerology function?
In Python:
Code: Select all
LetterMap={'v':13,'o':259.23,'d':987.1234}
n = 0
For 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 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 10
- Joined: Mon Jun 22, 2009 7:37 am
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
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!
Your set of functions for a Fibonacci sequence, cat years and numerology is quite an eclectic set!
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
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:
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"
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
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'
The Basic function I wrote is:
Code: Select all
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
Code: Select all
LetterMap={'v':1,'o':2,'d':3}
def Main(word):
n = 0
for c in word:
n += LetterMap[c]
return n
Code: Select all
=Numer("voodoo")
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 10
- Joined: Mon Jun 22, 2009 7:37 am
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
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.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 10
- Joined: Mon Jun 22, 2009 7:37 am
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