Jump to content

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


Recommended Posts

$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...

Link to comment
Share on other sites

$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 :)
Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...