AcidCorps Posted August 14, 2008 Share Posted August 14, 2008 I'm working on getting the progress of an upload to a website, I copy and pasted the string I'm working with: '00:00:00 (1.43 KB of 10.00 MB)' and am using that to figure out the code this is what I came up with: $Base = '00:00:00 (1.43 KB of 10.00 MB)' $Transfered = StringTrimLeft($Base, StringInStr($Base, '(')) $Transfered = StringLeft($Transfered, StringInStr($Transfered, ' ')) $Total = StringTrimLeft($Base, StringInStr($Base, 'of ')+2) $Total = stringLeft($Total, StringInStr($Total, ' ')) $Progress = ($Total / $Transfered) * 100 MsgBox(0,'',$Progress) all its returning is: -1#IND I also tried to round $Transfered & $Total and it would always return 0, I'm sure it's something stupid, any ideas? Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 14, 2008 Share Posted August 14, 2008 (edited) I'm working on getting the progress of an upload to a website, I copy and pasted the string I'm working with: '00:00:00 (1.43 KB of 10.00 MB)' and am using that to figure out the code this is what I came up with: $Base = '00:00:00 (1.43 KB of 10.00 MB)' $Transfered = StringTrimLeft($Base, StringInStr($Base, '(')) $Transfered = StringLeft($Transfered, StringInStr($Transfered, ' ')) $Total = StringTrimLeft($Base, StringInStr($Base, 'of ')+2) $Total = stringLeft($Total, StringInStr($Total, ' ')) $Progress = ($Total / $Transfered) * 100 MsgBox(0,'',$Progress) all its returning is: -1#IND I also tried to round $Transfered & $Total and it would always return 0, I'm sure it's something stupid, any ideas? That's a divide by zero error. Your divisor is a string, which evaluates to 0. Try this: $Transfered = Number($Transfered) If $Transfered <> = 0 Then $Progress = ($Total / $Transfered) * 100 Else MsgBox(16, "Error", "Operation not allowed: Successfull divide by zero would destroy the space-time continuum!") EndIf P.S. Number() conversion is required on $Total also, so you could just do: $Base = '00:00:00 (1.43 KB of 10.00 MB)' $Transfered = StringTrimLeft($Base, StringInStr($Base, '(')) $Transfered = StringLeft($Transfered, StringInStr($Transfered, ' ')) $Total = StringTrimLeft($Base, StringInStr($Base, 'of ')+2) $Total = stringLeft($Total, StringInStr($Total, ' ')) $Progress = (Number($Total) / Number($Transfered)) * 100 MsgBox(0,'',$Progress) Edited August 14, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now