# How to make this loop work

## Recommended Posts

How do I finish this loop?  I want it to reset the month name to January after each December, and keep the counter going to 13 and beyond.  I could keep explaining, but I think you'll understand what I mean.

#include <date.au3>

\$iNum = 0
\$sYear = 2016

For \$iCC = 1 To 100

\$sMonth = _DateToMonth(\$iCC + 2, 0)

\$sString_PartOne = "(" & \$iNum & ")"
\$sString_PartTwo = \$sMonth
\$sString_PartThree = \$sYear
\$sStringFinal = \$sString_PartOne & " " & \$sString_PartTwo & " " & \$sString_PartThree
ConsoleWrite(\$sStringFinal & @CRLF)
\$iNum += 1
;~  DirCreate("d:\" & \$sStringFinal)

If \$sMonth = "December" Then
\$sYear += 1
EndIf

Next

Edited by litlmike
##### Share on other sites

Like this maybe?

#include <date.au3>

\$iNum = 1
\$sYear = 2016

For \$iCC = 1 To 13
For \$i = 1 To 12
\$sMonth = _DateToMonth(\$i, 0)
\$sString_PartOne = "(" & \$iNum & ")"
\$sString_PartTwo = \$sMonth
\$sString_PartThree = \$sYear
\$sStringFinal = \$sString_PartOne & " " & \$sString_PartTwo & " " & \$sString_PartThree
ConsoleWrite(\$sStringFinal & @CRLF)
\$iNum += 1
If Mod(\$iCC, 12) = 0 Then \$sYear += 1
Next
\$sYear += 1
Next

##### Share on other sites

The same with one loop only

#include <date.au3>

\$iNum = 1
\$sYear = 2016

For \$iCC = 1 To 100
\$m = Mod(\$iCC, 12)
\$sMonth = _DateToMonth((\$m = 0) ? 12 : \$m, 0)
\$sString_PartOne = "(" & \$iNum & ")"
\$sString_PartTwo = \$sMonth
\$sString_PartThree = \$sYear
\$sStringFinal = \$sString_PartOne & " " & \$sString_PartTwo & " " & \$sString_PartThree
ConsoleWrite(\$sStringFinal & @CRLF)
\$iNum += 1
If \$m = 0 Then \$sYear += 1
Next

##### Share on other sites

2 hours ago, Subz said:

Like this maybe?

#include <date.au3>

\$iNum = 1
\$sYear = 2016

For \$iCC = 1 To 13
For \$i = 1 To 12
\$sMonth = _DateToMonth(\$i, 0)
\$sString_PartOne = "(" & \$iNum & ")"
\$sString_PartTwo = \$sMonth
\$sString_PartThree = \$sYear
\$sStringFinal = \$sString_PartOne & " " & \$sString_PartTwo & " " & \$sString_PartThree
ConsoleWrite(\$sStringFinal & @CRLF)
\$iNum += 1
If Mod(\$iCC, 12) = 0 Then \$sYear += 1
Next
\$sYear += 1
Next﻿

Thanks!

##### Share on other sites

2 hours ago, Subz said:

Like this maybe?

#include <date.au3>

\$iNum = 1
\$sYear = 2016

For \$iCC = 1 To 13
For \$i = 1 To 12
\$sMonth = _DateToMonth(\$i, 0)
\$sString_PartOne = "(" & \$iNum & ")"
\$sString_PartTwo = \$sMonth
\$sString_PartThree = \$sYear
\$sStringFinal = \$sString_PartOne & " " & \$sString_PartTwo & " " & \$sString_PartThree
ConsoleWrite(\$sStringFinal & @CRLF)
\$iNum += 1
If Mod(\$iCC, 12) = 0 Then \$sYear += 1
Next
\$sYear += 1
Next﻿

Thanks!

##### Share on other sites

49 minutes ago, mikell said:

The same with one loop only

#include <date.au3>

\$iNum = 1
\$sYear = 2016

For \$iCC = 1 To 100
\$m = Mod(\$iCC, 12)
\$sMonth = _DateToMonth((\$m = 0) ? 12 : \$m, 0)
\$sString_PartOne = "(" & \$iNum & ")"
\$sString_PartTwo = \$sMonth
\$sString_PartThree = \$sYear
\$sStringFinal = \$sString_PartOne & " " & \$sString_PartTwo & " " & \$sString_PartThree
ConsoleWrite(\$sStringFinal & @CRLF)
\$iNum += 1
If \$m = 0 Then \$sYear += 1
Next

Thanks!

##### Share on other sites

You do not need to quote the whole post from Mikell, he knows what he has suggested to you.  But thanking him THREE times, I think it is truly excessive !

“They did not know it was impossible, so they did it” ― Mark Twain

Spoiler

##### Share on other sites

Ha, thanks!  Sorry for the double post, it was an accident and I couldn't figure out how to delete it.

##### Share on other sites

On 1/3/2020 at 12:06 AM, Nine said:

But thanking him THREE times, I think it is truly excessive !

But so pleasant...

and a nice compensation for all the times where I got nothing while spending hours to provide an incredibly clever answer

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...