How to calculate numeric strings

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Scones
Junior Coder
Posts: 32
Joined: Fri Jul 05, 2019 11:21 am

How to calculate numeric strings

Post by Scones » Fri Mar 06, 2020 10:40 am

I have some numeric strings i want to add and get the final sum, but it can't calculate numeric strings.

Is there a way around it?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: How to calculate numeric strings

Post by Marcus Tettmar » Fri Mar 06, 2020 12:42 pm

Not sure I follow. Macro Scheduler will normally convert from string to numeric automatically. Can you provide an example of the strings and what you want to do?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Scones
Junior Coder
Posts: 32
Joined: Fri Jul 05, 2019 11:21 am

Re: How to calculate numeric strings

Post by Scones » Fri Mar 06, 2020 1:14 pm

Wow you're right. Just did this

Code: Select all

LET>A=1
LET>B=2
LET>SUM=%A%+%B%
MDL SUM
to confirm what you said, and it works.

I wonder why mine doesn't work then?

I'm trying to count the number of lines in some txt files and add them together.

Here it is

Code: Select all

ReadFile>\\DSS-DK-FIL-001\Data\Common\Autoclick projekt\Statistik\Grouped Output\Dkpbrsc.txt,DKPBRSC
ReadFile>\\DSS-DK-FIL-001\Data\Common\Autoclick projekt\Statistik\Grouped Output\DKPERNI.txt,DKPERNI
ReadFile>\\DSS-DK-FIL-001\Data\Common\Autoclick projekt\Statistik\Grouped Output\dkjurroh.txt,DKJURROH
ReadFile>\\DSS-DK-FIL-001\Data\Common\Autoclick projekt\Statistik\Grouped Output\dkptana.txt,DKPTANA
ReadFile>\\DSS-DK-FIL-001\Data\Common\Autoclick projekt\Statistik\Grouped Output\DKPTHSK.txt,DKPTHSK


Separate>DKPBRSC,CRLF,DKPBRSC_Arr
Separate>DKPERNI,CRLF,DKPERNI_Arr
Separate>DKJURROH,CRLF,DKJURROH_Arr
Separate>DKPTANA,CRLF,DKPTANA_Arr
Separate>DKPTHSK,CRLF,DKPTHSK_Arr

ArrayCount>DKPBRSC_Arr,DKPBRSC_Count
ArrayCount>DKPERNI_Arr,DKPERNI_Count
ArrayCount>DKJURROH_Arr,DKJURROH_Count
ArrayCount>DKPTANA_Arr,DKPTANA_Count
ArrayCount>DKPTHSK_Arr,DKPTHSK_Count

Let>Collective=%DKPBRSC_Count%+%DKPERNI_Count%+%DKJURROH_Count%+%DKPTANA_Count%+%DKPTHSK_Count%

MDL Collective
The MDL says 519+655+511+877+247 instead of the result.

The strings are clearly nothing but numbers, so i don't see the difference between my strings and the %A%+%B% i used in my example

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to calculate numeric strings

Post by Dorian (MJT support) » Fri Mar 06, 2020 1:39 pm

Code: Select all

Let>Collective=%DKPBRSC_Count%+%DKPERNI_Count%
..Works just fine

Code: Select all

Let>Collective=%DKPBRSC_Count%+%DKPERNI_Count%+%DKJURROH_Count%+%DKPTANA_Count%+%DKPTHSK_Count%
...Doesn't


Even if we use ..

Code: Select all

Let>Collective=%DKPBRSC_Count%+%DKPBRSC_Count%+%DKPBRSC_Count%+%DKPBRSC_Count%+%DKPBRSC_Count%
..It doesn't


The first method below can only take two arguments, so try this when adding more than two of them together:

Code: Select all

let>a=1
let>b=2
let>c=3

let>total1=%a%+%b%+%c%
mdl>total1

let>total2={%a%+%b%+%c%}
mdl>total2
Thus :

Code: Select all

Let>Collective={%DKPBRSC_Count%+%DKPERNI_Count%+%DKJURROH_Count%+%DKPTANA_Count%+%DKPTHSK_Count%}
MDL>Collective
Yes, we have a Custom Scripting Service. Message me or go here

Scones
Junior Coder
Posts: 32
Joined: Fri Jul 05, 2019 11:21 am

Re: How to calculate numeric strings

Post by Scones » Fri Mar 06, 2020 1:42 pm

It works!

As always, thank you!

Ranger762
Newbie
Posts: 7
Joined: Thu Mar 26, 2020 9:55 am

Re: How to calculate numeric strings

Post by Ranger762 » Sat Mar 28, 2020 11:07 am

Works for me as well, thanks, I'm really not familiar with numeric strings at all, thanks for helping us newbies.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts