I'm trying to replace a string in this fashion:
1. Name of Project should be in the naming scheme of "Testing-01A-Q1-2013"
The bolded part above is the important part. Essentially this will be one of the following:
01($i)-Q1
02($i)-Q2
03($i)-Q3
04($i)-Q4
This is our naming scheme for projects depending on which quarter of the year we are in. For now I am just trying to get it to work with Q1 projects.
The issue is that if you set the project name to be "Testing-01A-Q1-2013" for example and the number of projects is 3 for example it will increment the next project name to be "Testing-01B-Q1-2013" as expected. BUT if you click next project again it should increment to "Testing-01C-Q1-2013" but that is not happening and i'm not sure why. What is happening is the project name is not incrementing.
Code is below. Any help would be appreciated.
1. Name of Project should be in the naming scheme of "Testing-01A-Q1-2013"
The bolded part above is the important part. Essentially this will be one of the following:
01($i)-Q1
02($i)-Q2
03($i)-Q3
04($i)-Q4
This is our naming scheme for projects depending on which quarter of the year we are in. For now I am just trying to get it to work with Q1 projects.
The issue is that if you set the project name to be "Testing-01A-Q1-2013" for example and the number of projects is 3 for example it will increment the next project name to be "Testing-01B-Q1-2013" as expected. BUT if you click next project again it should increment to "Testing-01C-Q1-2013" but that is not happening and i'm not sure why. What is happening is the project name is not incrementing.
Code is below. Any help would be appreciated.
[ autoit ]
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Test", 615, 438, 215, 170) $RDCNextProjectButton = GUICtrlCreateButton("Next Project", 183, 241, 99, 33) GUICtrlSetState(-1, $GUI_DISABLE) $ProjectNameInputBox = GUICtrlCreateInput("", 35, 104, 193, 21) $ProjectNameLabel = GUICtrlCreateLabel("Please Input Your Project Name", 27, 80, 200, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $NumberOfProjectsLabel = GUICtrlCreateLabel("Please Input The Number Of Projects You Have Of This Kind", 19, 160, 364, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $RDCNumberOfProjectsInput = GUICtrlCreateInput("", 49, 198, 193, 21) $Submit = GUICtrlCreateButton("Submit", 72, 240, 99, 33) GUICtrlSetState(-1, $GUI_ENABLE) $RDCNumberOfProjectsRead = GUICtrlRead ($RDCNumberOfProjectsInput) $I = $RDCNumberOfProjectsRead;<-------------------------------------------------------This will read the number that you entered into the "number of projects" inputbox. GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Dim $alphabit[26] $alphabit[0]="A" $alphabit[1]="B" $alphabit[2]="C" $alphabit[3]="D" $alphabit[4]="E" $alphabit[5]="F" $alphabit[6]="G" $alphabit[7]="H" $alphabit[8]="I" $alphabit[9]="J" $alphabit[10]="K" $alphabit[11]="L" $alphabit[12]="M" $alphabit[13]="N" $alphabit[14]="O" $alphabit[15]="P" $alphabit[16]="Q" $alphabit[17]="R" $alphabit[18]="S" $alphabit[19]="T" $alphabit[20]="U" $alphabit[21]="V" $alphabit[22]="W" $alphabit[23]="X" $alphabit[24]="Y" $alphabit[25]="Z" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $RDCNumberOfProjectsInput $RDCNumberOfProjectsRead = GUICtrlRead ($RDCNumberOfProjectsInput) If ($RDCNumberOfProjectsRead) > 1 Then;<------------------------------------------------------If the number of projects entered is more than 1 then it will enable the next ;project button and disable the submit button. GUICtrlSetState ($RDCNextProjectButton, $GUI_ENABLE) GUICtrlSetState($Submit, $GUI_DISABLE) ElseIf ($RDCNumberOfProjectsRead) <= 1 Then;<----------------------------------------------If the number of projects entered is 1 then it will keep the next project button ;disabled GUICtrlSetState ($RDCNextProjectButton, $GUI_DISABLE) GUICtrlSetState($Submit, $GUI_ENABLE) EndIf $CapacityInput = ($RDCNumberOfProjectsRead * 10) Case $RDCNextProjectButton Local $ProjectNameRead = GUICtrlRead ($ProjectNameInputBox) $RDCNumberOfProjectsRead = GUICtrlRead ($RDCNumberOfProjectsInput) $sFirst= $alphabit[1] For $I = $RDCNumberOfProjectsRead To 1 Step - 1 $iASCII = Asc($sFirst) $iASCII += 1 $sNext = Chr($iASCII) Local $sinput = $ProjectNameRead If $sinput = $ProjectNameRead Then local $soutput =StringRegExpReplace($sinput, "\-01A-" & $alphabit & "Q", "-01"& $sNext &"-Q");<------Read the project name and if exist then rename "01A-" to "01B" which would be the next letter, and it should continue in this fashion based on the number of projects entered.. guictrlsetdata ($ProjectNameInputBox,$soutput) MsgBox(0,"", "Testing Countdown Loop " & $i) MsgBox(0,"","The total of capacity is " & $CapacityInput & "GB") MsgBox(0,"","The next project name should be " & $soutput) EndIf Next GUICtrlSetState ($RDCNextProjectButton, $GUI_DISABLE) GUICtrlSetState($Submit, $GUI_ENABLE) Case $Submit MsgBox(0,"","End of Script","") Exit EndSwitch WEnd