Re: for?
"valery_vi" <[email protected]>
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
This is an example of For ... Next. You can check Mod result to extract odd & even cases, or use Step keyword instead of $Max = 10 ;Common case For $i = 1 to $Max if Mod($i,2) then MsgBox(0,'Odd numbers', '$i = ' & $i) else MsgBox(0,'Even numbers', '$i = ' & $i) endif Next ;case of odd numbers For $i = 1 to $Max Step 2 MsgBox(0,'Odd numbers', '$i = ' & $i) Next ;case of even numbers For $i = 0 to $Max Step 2 MsgBox(0,'Even numbers', '$i = ' & $i) Next Valery --- In [email protected], beau <n9mfk@...> wrote: > > hi All i need some help with a for loop? > were should i put for $c = 1 to 100 an the next > i went to use $c in my mod statement > thanks for any help > > Dim $ColorToggle = 0 ; Boolean toggle for Red/Blue TD colors > if Not FileExists(@ScriptDir & "/N9mfk_*.HTML") Then > MsgBox(0,"There are no Files",@ScriptDir & "/n9mfk_*.html") > Exit > EndIf > IF Not FileExists(@ScriptDir & "\input")Then > DirCreate (@ScriptDir & "\input") > EndIf > IF Not FileExists(@ScriptDir & "\output")Then > DirCreate (@ScriptDir & "\output") > EndIf > If FileExists(@ScriptDir & "/N9mfk_*.HTML") Then > FileCopy(@ScriptDir & "/n9mfk_*.html",@ScriptDir & "\input",1) > EndIf > $size = DirGetSize(@ScriptDir &"/input/",1) > $number = $size[1] > For $count = 1 To $number > $FileIn = @ScriptDir & "\input\n9mfk_"&$count&".html" > $FileOut = @ScriptDir & "\output\n9mfk_"&$count&".html" > $FileInData = FileRead($FileIn, FileGetSize($FileIn)) > $avSplitData = StringSplit($FileInData, "<TD", 1) > > ;MsgBox(0,"",$FileInData) > ;$FileInData = StringReplace ($FileinData, "background","background=") > $FileOutData = $avSplitData[1] > For $n = 2 To $avSplitData[0] > $End = StringInStr($avSplitData[$n], "</TD>", 0, -1) > $EndLen = StringLen($avSplitData[$n]) - $End + 1 > $EndText = StringRight($avSplitData[$n], $EndLen) > $avSplitData[$n] = StringTrimRight($avSplitData[$n], $EndLen) > ;MsgBox(0,"",$n) > $graphic ='"newpageback.gif"' > ;$back = "<body background="&$graphic& " bgcolor" > For $c = 1 to 100 > If Mod($c, 2) = 0 Then ; If even numbered TD, change the color > If $ColorToggle Then > $color = ' bgcolor="red"' > Else > $color = ' bgcolor="blue"' > EndIf > $ColorToggle = Not $ColorToggle > EndIf > Next > > ;$color =' bgcolor="red"' > $FileOutData = StringReplace($FileOutData, "<body background > bgcolor","<body background="&$graphic& " bgcolor") > $FileOutData &= "<TD" & $color & StringReplace($avSplitData [$n], "0", > "Ø") & $EndText > $FileOutData = StringReplace($FileOutData, "with","of " &$number &" with") > Next > $hFileOut = FileOpen($FileOut, 2) > FileWrite($hFileOut, $FileOutData) > FileClose($hFileOut) > FileClose($FileIn) > FileClose($FileOut) > Run('Notepad.exe "' & $FileOut & '"') > next >