2011/6/9 JOE Conner <[email protected]>:
> On 6/9/2011 9:17 AM, Johnny Rosenberg wrote:
>>
>> 2011/6/8 JOE Conner<[email protected]>:
>>>
>>> On 6/6/2011 2:14 PM, Johnny Rosenberg wrote:
>>>>
>>>> 2011/6/6 JOE Conner<[email protected]>:
>
>>>> <<SNIP>>
>>>
>>> Thanks Johnny for that, but you give me far too much programming skill.
>>>
>>> For all, is not boolean arithmetic/algebra a part of the ODF
>>> specifications?
>>>
>>> Joe Conner, Poulsbo, WA USA
>>> --
>>
>> I am not an ODF- or OpenOffice.org/LibreOffice expert, but I guess you're
>> right.
>>
>> Do you think the following is too complicated?
>> =OR(AND(NOT(A1);B1);AND(A1;NOT(B1)))
>>
>> If there is no typo, it's equivalent with =XOR(A1;B1) (if XOR
>> existed…), but I guess you already know that.
>>
>> Anyway, it's easy to make a function like this with OpenOffice.org
>> BASIC, but you need to accept that the new function's name can not be
>> XOR, because XOR is a keyword in OpenOffice.org BASIC, and can
>> therefore not be the name of a function or a variable.
>>
>> So let's accept the name XR instead, or you can choose whatever you
>> want as long as it's not a keyword.
>>
>> Now click Tools → Macros → Organize Macros → OpenOffice.org Basic…
>> This brings up a dialogue box with three fields. One of them is ”Macro
>> from”. Under ”My Macros” you'll find ”Standard”. Highlight it and
>> click ”New”.
>> Another dialogue pops up and you are expected to enter a name of a new
>> module. Default name is ”Module1" which is not too exciting… I typed
>> ”CellFunctions”.
>>
>> Hit OK and off you go…! The OpenOffice.org BASIC IDE thing opened and
>> you can enter your Basic code, which will work in any spreadsheet from
>> now on!
>>
>> Here's what I typed, you can copy it from here and just paste it in,
>> if you like:
>>
>> REM  *****  BASIC  *****
>>
>> Option Explicit
>>
>> Function XR(x As Boolean, y As Boolean) As Boolean
>>        XR=x XOR y
>> End Function
>>
>> I don't know how much programming skill you have, but in case of zero
>> I will explain every row now:
>>
>> REM  *****  BASIC  *****
>> This is just a comment and does nothing more than tell people that
>> this is a BASIC macro. This is there by default so I didn't write it.
>> You can delete it if you like.
>>
>> Option Explicit
>> Means that you need to declare every variable you use, otherwise you
>> will get nothing but error messages. This helps you to spell your
>> variable names the same every time. Misspelled names of variables are
>> often very hard to find, at least if your code is somewhat more
>> complicated than this.
>>
>> Function XR(x As Boolean, y As Boolean) As Boolean
>> This tells us that XR is a function which return value is Boolean. XR
>> takes two parameters, x and y, and both of them are booleans.
>>
>> XR=x XOR y
>> Returning a value in a BASIC function is done by assigning a value to
>> the function's name. In this case, XR returns x XOR y.
>>
>> End Function
>> This is, surprisingly enough, where this function ends…
>>
>> Okay, we wrote our own cell function, let's try to use it!
>>
>> Go back to the spreadsheet, enter FALSE in A1 and TRUE in B1. In C1,
>> enter:
>> =XR(A1;B1)
>> Hit Enter. C1 should now display TRUE!
>>
>>
>> So there you go! So now it's up to you to create your own XNOR, NAND
>> and NOR functions!
>>
>>
>> Regards
>>
>> Johnny Rosenberg
>> ジョニー・ローゼンバーグ
>
> Thank you Johnny - both for your time and for your willingness to work up a
> detailed example and explanation.
> I do appreciate it
>
> Blessings, Joe Conner, Poulsbo, WA USA

You're welcome. By the way, did it work…?


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ
-- 
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help

Reply via email to