As a newcomer to this forum and comparatively new to LOCalc I am posting a question about its ability to utilize the built-in functions and to extend their use with custom or “user defined” functions. I am attaching a file that may illustrate some of the topics I reference.
I began by adding a date value, “6/21” and observed calc convert this to “06/21/2024”. I assumed this was a date serial number calculated by the system as “time since” some reference point. A few cells over I added an integer value to a reference to the aforementioned date and calculated the result as “08/05/2024”. I was calculating mid-summer; the date also happened to be a family-member’s birthday. I wondered what day of the week that might be.
Calc has functions for converting date-serial numbers into month-ordinal and week-ordinal numbers but not (so far as I could find) one for naming the day of the week. I created a simple formula using the SWITCH function to find the name of the weekday, referencing my previous calculation. It worked, once I used the proper syntax (double quotes, not single quotes around strings), so I tried to modify this formula using a “%1” parameter instead of the cell reference. This is a technique used in other SS but was not successful here. After more research I found I would have to write a function to use this approach anywhere in the sheet.
That function should be visible in the BASIC editor of the attached sheet: accepts an integer, processes it in a case statement, converting the number to a string and returning the string as the result. Before using the case select structure I tried my former SWITCH statement structure in my BASIC function. This approach was both successful, in that it produced a result when invoked from a sheet cell, and unsuccessful, as calc immediately thereafter issued an error message and erased the result.
This experience leaves me with some questions, which are the point of my posting here:
What is the relation (overlap?) between spreadsheet functions and BASIC functions? Are they identical? Can sheet functions be referenced in BASIC code at all?
Is the “undefined parameter” ("%1, %2 etc.) or “placeholder” ever used in LOcalc?
If not, is there a design or operational philosophy that restricts it use?
Could this be suggested as a feature for future release? What say you?
Thank you for your replies.
-CH-
LO_FunctionTest.ods (23.9 KB)