Yes, you have to add it to the menu. But am I right that the same thing doesn’t exist in Libre Office?
IMHO it is one of this features wich LibreOffice doesn’t need. MS is/was selling Word as a separate software, so it needed its own way for serial letters, a calculator etc.
.
LibreOffice is simply delivering Base and Calc for free, so you can use this tools. Always remember: Star-/Open-/LibreOffice was not designesd as a clone of MS-Office. You may replace it, but you will feel the difference. (The best time for transit was, when MS enforced ribbons to users. So one had to learn new stuff anyway…)
I totally agree. With the already-existing features, it is trivial even in Writer, to press F2 then 2+5+46Enter, and have the result in a calculated field (which may be even used better, by defining document variables, and having calculations refresh on data change); or to have a table with numbers, and add a sum; or to use Calc
. But having several paragraphs with numbers in a text document, select them, press some button, and have their sum in clipboard? That’s just crazy. This is a text document! Why do you think that easter eggs like this are better than e.g. Pinball in Word 97?
that kind of macro would do the trick :
Sub sum_selected_strings()
GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
For each s in thisComponent.CurrentSelection
nums = SF_String.ReplaceRegex( s.getString, "[^\d]+", " ")
For each n in split(nums, " ")
sum = sum + cint(n)
Next
Next
msgbox "sum = "& sum
' CopyToClipBoard(sum)
End sub
Copying to clipboard is a misery, e.g. How do you copy text to clipboard from macro? - #7 by george37809
(I guess the answer will be we don’t need clipboard copy )
The answer is: we DONT need ScriptForge!
def main(*_):
doc =XSCRIPTCONTEXT.getDocument()
xsum = 0
for part in doc.CurrentSelection:
xsum += sum(map(float, part.String.replace(',','.').split()))
print(xsum)
Thanks @EarnestAI, I found it.
topic missed?!
It’s one you and Mikegagariski don’t need but that I use!
I’m not complaining, I’m just asking, for heaven’s sake.
Thanks so much, fpy, will give that a try.
Changing for another tool always requires a change of routine.
Have you considered thoroughly your workflow? You mention a list of paragraphs containing numbers. Are these paragraph a “meaningful” part of the document. By “meaningful”, I mean: are these paragraphs part of the normal reading flow? Do they bring something important to the argumentation?
- If the answer is “no”, they are simply scratch annotations out of which you compute the total, the only significant data.
- If the answer is “yes”, I doubt that the numbers are simply written down alone without any comment or explanation. In this case, you need a table and you’ll end up “naturally” either with a Calc table or the minimalistic Writer spreadsheet.
I share @Wanderer’s and @mikekaganski’s point of view. This is a personal routine which can be achieved differently. My 2-cent supplement: there are enough open bugs in LO, critical enough to impede users, that we don’t need to add “noise” features in a product demanding stability and reliability.
Featurism is a deadly plague in software. It costs a lot to integrate and maintain new features in an existing application without breaking it. When a feature is not vital, I prefer not to request it in favour of a reliable app.
Until now, you have not demonstrated which aspect of your routine is innovative and susceptible of a shared interest. To attract attention of developers, please provide an example document where your workflow proves superior to the suggested workarounds. So, share your ideas (in the form of an example and a semi-specification) so that convinced users would pressure developers. In FOSS, there is word “open”. Developers are also “open” to innovation and would be proud to be at least on par with commercial competition.
Dude. I asked whether this feature exists in the program. Why are you so aggressive?
I didn’t ask for anything to be implemented, and it’s not a noise feature to me, it’s one I’ve been using for almost 40 years. You also have no idea how or when I use it.
Exactly. So, please, provide an example case showing its usefulness. I am not aggressive, I only want to understand how it fits in a “standard” document. Clarify the relationship between paragraphs containing (only?) numbers and surrounding text. I don’t grasp the integration of numbers in a discourse. There must be at least an introduction to them, but what is their individual role when they’re isolated in their paragraph? Once I got the idea, I could suggest a way to achieve your goal, likely to be different from Word.
What you are looking may be present under a different process.
What I want to do is easy, as I wrote: just copy the text and paste it into the Calculator app, and it does the same thing - including placing the result in the clipboard. Not a big deal, it’s just more convenient having it directly in the word processor.
One example of how I use this feature is during tax time. I have a Word document with a long table of expenses, which I update for the current year. That involves arithmetic on lists of numbers (either positive or negative), and then multiplying by a percentage to figure out, say, the percentage of our household expenses I can deduct for my home office/studio.
I’m sure there will be other features/commands I need to find as I move over to Libre Office. The reason I posted to ask about this one is that… I wanted to add something up! (But I’m not working on taxes now, thank goodness.)
Then you can use the calculation functions of a table, Mike Kaganski alluded to it in his earlier comment, Calculate command as in Word - #10 by mikekaganski.
To sum see Calculating Cell Totals in Tables . Note that there are other functions available for calculating within a table, after pressing F2 click the fx icon to see the list.
.
To convert a list of numbers, such as you described, to a table just click Table > Convert > Text to table.
.
The Writer Guide is a handy reference, download from English documentation | LibreOffice Documentation - LibreOffice User Guides
Yes, I know you can do it in tables like you would in a spreadsheet, but that’s not exactly what I was looking for.
I just like having a basic calculator inside the word processor because I’m not a spreadsheet GUY.
So I’ll use the Calculator app instead. It’s just a little less convenient, but it’s fine.
Okay, I think we’re done here.
The “Calculate” command in menu Tools works on a selection inside a paragraph. This selection needs to be a valid expression including operators, e.g. 12*17+4. The command puts the calculation result into the clipboard. It does not automatically replace the selection. From the clipboard you can insert it into the document with the usually Ctrg+V, to a new place or as replacement of the selection. The command does not perform a default addition of the selection, in case there are no operators.
So LibreOffice has a “Calculate” command, but it works a little bit different than in Word.
Should there be a fancy syntax for epressions accepted by the tool?
What restrictions concerning standard functions?
Why should SIN(literal argument)
be accepted, but PI()
not?
See attachment.
disask114902_25_refutation.odt (150.8 KB)
I think you’re saying mostly the same thing, but in Word if you type this (with returns between the numbers):
1
2
(2)
…then select them all and issue the Calculate command, the resulting answer 1 will be in the clipboard and it’ll show in the bar at the bottom of the window. (Obviously numbers in parenthesis are subtracted.)
Similarly, if you select 2*3 or 12/2 (they have to be in the same paragraph), 6 will be the result.
But I’ll have to find the command you’re talking about in Libre, because it sounds like it’s almost the same thing.
One other point (you’ll have to excuse me for being new to Libre): in Word, you can hold Option while selecting and restrict the selection’s horizontal boundaries, not just the vertical ones as normal.
Thanks.
Sorry. I’m not interested in MS™ Word™, and didn’t use it for more than 20 years.
To regard numbers in parentheses negative is an idiotic misuse of parentheses which are indispensable for reasonable purposes. On the same level is it to interpret line breaks or paragraph breaks as arithmetic operators.
LibreOffice Writer simply isn’t Word™ though it has to support fancy “formats” in some cases…
Typing
5 `Enter` (3) `Enter` 428 `Enter` `3/4` Enter,
then selecting a bunch of lines,
finding a menu item and a submenu item by clicking,
losing (and later regretting to have lost) the previous content of the clipboard,
then (most likely) deleting what originally was entered
and eventually pasting a result from the clipoard somewhere,
is surely more complicated, less powerful, and less intuitive
than
typing
5 - 3 + 428 + 3/4
selecting what was typed
(copying it to the clipboard possibly for later use)
and clicking a sensitive area of a toolbar.
If a user can accept to need custom code, the solution I suggested is much better than what MS™ Word™ can do and also better than what LibO Writer currently supports with >Tools>Calculate
.
If a user can’t accept custom code, they will need to use the tools as they are, and to accept the shortcomings - or wait for an enhancement of the tool.
See also the enhanced attachment to my answer below.