Jump to content

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

 

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

 

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

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

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

Link to comment
Share on other sites

Link to comment
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...  :wub:

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

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