zasxes Posted March 26, 2004 Share Posted March 26, 2004 Why isnt this working at line "If $line[$POS] >= 100" I am trying to add 1 to the array varaiable that coinsides with the line I am reading if there is an error expandcollapse popup$LIST="studies.txt" Dim $a $a=FileCountLines($LIST ) MsgBox(0, "Message", $a) Dim $line[$a] While 1;==>OpenLIST $LIST = FileOpen("studies.txt", 0) $POS=0 While 1;==>ReadLIST $POS=$POS+1 If OPENLIST() = 1 Then ExitLoop OPENSITE() Sleep(3000) $TITLEX=WinGetTitle("","") If $TITLEX = "Cannot find server - Microsoft Internet Explorer" Then $line[$POS]= $LINE[$POS]+1 EndIf WinClose($TITLEX) If $line[$POS] >= 100 Then;<---------<<Error Here MsgBox(0, "Message", "Got here") EndIf Wend;==>ReadLIST Wend;==>OpenLIST ; ---------------------------------------------------------------------------- ; Func OPENLIST() ; ---------------------------------------------------------------------------- Func OPENLIST() $RETURN=0 $LINE = FileReadLine($LIST) If @error = -1 Then FileClose($LIST) $RETURN=1 EndIf If $LINE = "" Then $RETURN=1 EndIf $SPLIT=StringSplit($LINE,".") $LOGNAME=StringTrimLeft($SPLIT[1],7) If $RETURN=1 Then Return( 1) Else Return( 0) EndIf EndFunc ;==>OPENLIST() ; ---------------------------------------------------------------------------- ; Func OPENSITE() ; ---------------------------------------------------------------------------- Func OPENSITE() Run('explorer.exe '& $LINE) WinWait("classname=IEFrame") If Not WinActive("classname=IEFrame","") Then WinActivate("classname=IEFrame","") WinWaitActive("classname=IEFrame","") WinShow("classname=IEFrame","", @SW_MAXIMIZE) EndFunc ;==>OPENSITE ; ---------------------------------------------------------------------------- ; Func FileCountLines() ; ---------------------------------------------------------------------------- Func FileCountLines( ByRef $sFilePath, ) Local $hFile Local $iLines $hFile = FileOpen($sFilePath, 0) If $hFile <> -1 Then While 1 FileReadLine( $hFile ) If @error = -1 Then ExitLoop $iLines = $iLines + 1 Wend FileClose($hFile) Return $iLines Else SetError( 1 ) Return 0 EndIf EndFunc Link to comment Share on other sites More sharing options...
CyberSlug Posted March 26, 2004 Share Posted March 26, 2004 (edited) What error message? Do you get an "index out of bounds" error? You don't appear to check that $POS >= 0 And $POS < $a What is supposed to happen after the last element of your $line[] array is read? Maybe try $POS= -1 While $POS < $a;==>ReadLIST $POS=$POS+1;first element is zero Edited March 26, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Developers Jos Posted March 26, 2004 Developers Share Posted March 26, 2004 (edited) what are you testing with this statement: If $line[$POS] >= 100 on line 5 you dim the array:Dim $line[$a] on line 34 you read a record into this var: $LINE = FileReadLine($LIST) this doens't create an array! so you probably get an error : subscript used with non-Array variable ?? Edited March 26, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
zasxes Posted March 26, 2004 Author Share Posted March 26, 2004 Error is: if $line[$POS] >= 100 then If $line^ERROR Error: Subscript used with non-array variable Link to comment Share on other sites More sharing options...
Developers Jos Posted March 26, 2004 Developers Share Posted March 26, 2004 Like i mentioned in my previous post: I think the $line contains the record and isn't an Array..... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
redndahead Posted March 26, 2004 Share Posted March 26, 2004 It looks like maybe it should be $Split[$Pos] Also since it is going to a function you might want to make $Split a Global variable I think. red Link to comment Share on other sites More sharing options...
scriptkitty Posted March 26, 2004 Share Posted March 26, 2004 (edited) While 1;==>ReadLIST $POS=$POS+1 You need to stop the loop before it goes over the amount of array elements. While $POS<$a;==>ReadLIST or something like this $POS=$POS+1 edit NM, I can't make out much of anything going on with $LINE and $line[] Functions use a non array variable $line Main script uses array $line[] I usually use different variables for arrays and normal variables, so this got too confusing for me Edited March 26, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
zasxes Posted March 26, 2004 Author Share Posted March 26, 2004 Ok the studies.txt file has a list of say 20 different webs sites. If at any point I get over 100 server not found errors for an indidvidual site I want it to pop up a msg box. 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