You are here: PSPad forum > English discussion forum > Sumator - issue

Sumator - issue

#1 Sumator - issue

Posted by: Haunebu | Date: 2021-05-18 19:16 | IP: IP Logged

Where can I find the Sumator of numbers in 10000 lines. I searched all the ideas on the internet and can't find such a simple app anywhere.
I've asked thousands of people for a math script, but people don't understand the simplest thing in the whole universe.

Example:
23445555=sum
13445555=sum
123=6
111=3
34098=24

Edited 1 time(s). Last edit at 2021-05-18 19:17 by Haunebu.

Options: Reply | Quote | Up ^


#2 Re: Sumator - issue

Posted by: pspad | Date: 2021-05-18 19:28 | IP: IP Logged

Use pspad scripting and Write script what will sum numbers from line or selection.
You askod for it before, now you start same topic again.

Options: Reply | Quote | Up ^


#3 Re: Sumator - issue

Posted by: Haunebu | Date: 2021-05-19 13:00 | IP: IP Logged

I am a young man, I am still far from writing scripts. I am not a programmer.
4 years, and I am unable to solve this problem. But I will wait 4 more years, maybe I will write my unique Almanac, the Number Prediction System and the infinite winning!

19522114=25 win!
Today this number was won 19,47 Euro

Edited 2 time(s). Last edit at 2021-05-19 13:10 by Haunebu.

Options: Reply | Quote | Up ^


#4 Re: Sumator - issue

Posted by: pspad | Date: 2021-05-19 14:29 | IP: IP Logged

Store this code into PSPad subfolder .\Script\VBScript as e.g. SumDigits.vbs file

Quote:
const module_name = "SumDigits" 'this name must be unique !!!
const module_desc = "Sum selected digits" 'script description
const module_ver = "1.00" 'version

sub mySum
set obj = NewEditor()
obj.AssignActiveEditor()

Dim n, d, sum
sum = 0
d = 0
n = obj.SelText
If IsNumeric(n) Then
For i = 1 To Len(n)
d = CInt(Mid(n,i,1))
sum = sum + d
Next
End If
obj.selText(n & "=" & sum)
end sub

sub Init
addMenuItem "Sum digits from selection","", "mySum"
end sub

Select numbers in editor
From the menu script click on Sum digits from selection

Options: Reply | Quote | Up ^


#5 Re: Sumator - issue

Posted by: Haunebu | Date: 2021-05-19 15:29 | IP: IP Logged

I have done it, but it does not produce any result.
only one = 0

Pspad version 4.6

If you want I will send you a full file with numbers in lines privately. Enter your e-mail address.

i.postimg.cc

Options: Reply | Quote | Up ^


#6 Re: Sumator - issue

Posted by: pspad | Date: 2021-05-19 15:35 | IP: IP Logged

Open new document and write:
123456
select it
call script
In the selection must be numbers only
You didn't select numbers as I wrote. It's your long time weakness - problem with reading.

It's base of the sctript. You wrote you are young man. You should be able to read few lines of code, understand it and modify it as you need.

Edited 1 time(s). Last edit at 2021-05-19 15:38 by pspad.

Options: Reply | Quote | Up ^


#7 Re: Sumator - issue

Posted by: Haunebu | Date: 2021-05-19 15:48 | IP: IP Logged

soory... I have no idea what you are talking about.

Options: Reply | Quote | Up ^


#8 Re: Sumator - issue

Posted by: pspad | Date: 2021-05-19 16:07 | IP: IP Logged

Read it again, slowly
If you don't understand, repeat line 1

Options: Reply | Quote | Up ^


#9 Re: Sumator - issue

Posted by: pspad | Date: 2021-05-19 16:27 | IP: IP Logged

here is modified script
it goes in your file line by line and sum each line
if line contains any non digit char, is ignored, it means summed lines are not touched

const module_name = "SumDigits" 'this name must be unique !!!
const module_desc = "Sum digits" 'script description
const module_ver = "1.00" 'version

sub mySum
set obj = NewEditor()
obj.AssignActiveEditor()

Dim n, d, sum
for j = 1 to obj.linesCount()
sum = 0
d = 0
obj.caretY(j)
n = obj.lineText
If IsNumeric(n) Then
For i = 1 To Len(n)
d = CInt(Mid(n,i,1))
sum = sum + d
Next
obj.lineText(n & "=" & sum)
End If
Next
end sub

sub Init
addMenuItem "Sum digits in lines","", "mySum"
end sub

Options: Reply | Quote | Up ^


#10 Re: Sumator - issue

Posted by: Haunebu | Date: 2021-05-19 17:07 | IP: IP Logged

Work! Thanks!

Edited 1 time(s). Last edit at 2021-05-19 17:12 by Haunebu.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR