Jump to content
Sign in to follow this  
Harmonful

How can i + the numbers of a .txt documnet?

Recommended Posts

Harmonful
:):):P

Share this post


Link to post
Share on other sites
Mat

$sFile = FileOpenDialog ("Open file...", @WorkingDir, "Autoit script (*.au3)|All files (*.*)")
If @Error Then Exit

$sData = FileRead ($sFile)

$ans = _Addup ($sData)

MsgBox (0, "Result", $ans)

Func _AddUp ($sData)
   ; split up the lines
   $aData = StringRegExp ($sData, "([0-9]+)", 3)

   ; Start loop
   $ret = 0
   For $i = 0 to UBound ($aData) - 1
      $ret += $aData[$i]
   Next
   Return $ret
EndFunc ; ==> _AddUp

is what I think you want to do...

Share this post


Link to post
Share on other sites
Harmonful

$sFile = FileOpenDialog ("Open file...", @WorkingDir, "Autoit script (*.au3)|All files (*.*)")
If @Error Then Exit

$sData = FileRead ($sFile)

$ans = _Addup ($sData)

MsgBox (0, "Result", $ans)

Func _AddUp ($sData)
   ; split up the lines
   $aData = StringRegExp ($sData, "([0-9]+)", 3)

   ; Start loop
   $ret = 0
   For $i = 0 to UBound ($aData) - 1
      $ret += $aData[$i]
   Next
   Return $ret
EndFunc ; ==> _AddUp

is what I think you want to do...

Thx :) It works :)

Share this post


Link to post
Share on other sites
Mat

KK... but do you understand it? I am probably a bit too helpful at times :) (and very good at guessing!)

And just because it works doesn't mean its the right way to do it either.

Mat

Share this post


Link to post
Share on other sites
CodyBarrett

yes there are a hundred different ways to implement code.. haha mat yes you are too helpful at times :) but who's complaining? :)

Share this post


Link to post
Share on other sites
Diablo2

Posted in the wrong topic lol

Edited by Diablo2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×