Thanks for all the comments. Highly appreciated !!!
Here is a little progress report for those who might be interested. I have spent about 4 hours so far. Not too much for the achievement, I think. Thanks to LC ).

- Excel-like spreadsheet made using LiveCode
Well, I wanted to say that I made some progress and through this learning in doing I get a crisper understanding what LiveCode could actually do for me and others. And I am still using an Excel-like spreadsheet as something to learn using LiveCode. Now, after some hours additionally spending on the subject, I feel pretty sure that this is not a task for many months or even years. The basics of quite a nice and workable spreadsheet can be done in days !!! And it would not take more than 4 weeks to come up with a nice solution. It is my belief now.
Exploring the world of LiveCode - the problem is that I do not know all the many functions by heart to immediately apply them and understand. And often enough I do not know what to search for. How would I know a certain function name? I would have had to read all the dictionary from A-Z and make notes and keep track. Probably I should do this.
Well, regarding small-scale Excel, I believe I got the basic solution. Each cell is a field. The rows and columns are indicated using buttons (or graphics). Each cell has its name using a combined row and column button name, as everybody intuitively would use. The numbered row fields receive the letter "r" in front of the number since an object should not just have a number as its name. Otherwise, what is button 1 if the name is 1 and its actual number would be 5? Custom properties store different values and different states of the "cell"-field. The same information is also already stored in a corresponding array. (I just believe such array gives advantages to speed up certain selections and executing formlas, even though all objects in this application are already storing all information.)
Just now, I can already select rows, columns, even discontinues cells, rows, and columns. The basic field state is locked. When the user selects a field, either through double-click or starting to type the field is opened for editing and changes the state. Another field state is stored when a formula is applied.
For indicating row and column hilites I am using graphic objects on top or behind the fields to create visual effects, especially lines and rectangles. The background color is also changing according to the state.
When the user enters a formula, I can parse the text string. If the "=" equal sign is used as the first char (not counting spaces before and after), this would be a formula which will be stored in a custom property.
In my LiveCode spreadsheet, I am using a fixed number of cells. They could, of course, be created dynamically when needed. Already all objects are created by a script. Placing them into a group and then using horizontal and vertical scroll bars will allow to also scroll up and down through the spreadsheet.
Of course, there are little small details which keep me thinking.
One detail, and therefore a question, is, how best to parse entered formulas and execute them.
For example, in the simplest form, a user enters =A1+A2 as the formula into cell B1. Expected is that the cell will look up cell "A1" and "A2", which the user clicked, then add the values and place the result into the first selected cell. The problem here is the parsing. The user might use spaces or not, enter wrong formulas, etc. If there is no space then how to know the cell reference or what is an operator. And also wrongly entered data must be accounted for. Well, of course, it can be done and I have done it for the simplest cases already.
So, what I am doing here is using the elements of the formula and execute them through a "do" statement. The string that I have build in scripting in this example would look like:
Code: Select all
do "put field " "e& A1 "e& " + " &" field " "e& A2 "e& " into field " "e& B1 "e&"
Since I know the id number of each field, either looking up the field object itself or looking up the id number in my array of cells, I can also use another way and tested this as well. I know that the "do" command should usually be avoided. And the solution should be flexible enough to allow to be extended with all those formulas using the commonly known spreadsheet syntax (or, maybe, additionally also LiveCode expressions themselves).
Code: Select all
# Primitive example code snippet
global gSpreadsheet
command executeFormula pParsed,pTarget
-- pParsed contains the operation chunks
-- Operands, formula, etc.
put word 1 of pParsed into x
put word 2 of pParsed into y
put the last word of pParsed into tFormula
put the text of field id gSpreadsheet[x] ["id"] into a
put the text of field id gSpreadsheet[y] ["id"] into b
if tFormula is "addition" then
put a+b into field id gSpreadsheet[pTarget]["id"]
--- Here lots of function cases can be added
end if
end executeFormula
After execution using The Return or Enter key, the formula becomes invisible being stored in a custom property (and/or my array) and the result is shown in the target field the user selected. Actually, so far, all behaves very similar to Excel itself and I am using Excel as the blueprint.
It should be relatively easy to also shift columns or rows around, copy and paste them elsewhere, hide columns or rows, lock fields, and actually created a better user experience partially than Excel creates.
Where I still see more problems is how to have text entered into a field stretch over to other fields, or combining fields to be one field (which I think is not good practice anyway even in Excel itself), and changing text formatting making all other rows and columns shift all the time might be a real challenge.
Or on the visual side, people like to underline cells or groups of cells. Since a field in LC does not allow to address object borders individually, graphic lines would have to be used which would sit on top of the border sides of a cell or more cells. And a user who is reformatting the spreadsheet will then require touching many such objects at once.
When I find the time, I will continue building LiveCode "Excel" and maybe the time may come when I will feel I (or others) could publish. Any suggestions, critical remarks, etc. are welcome. This is beginners section.
Such application - if really made well - would speak for the quality of this LC language. Also, I think it would be used since it could make things much easier for people who are confined within the boundaries of current Microsoft Excel. And as it usually goes, 80% of Excels functions and possibilities are not used by the ordinary user anyway. What would be the effort doing this in the LiveCode Builder (LCB) language?