Diana (Cda) Posted 3 hours ago Posted 3 hours ago (edited) Hello! Happy Advent! I shock myself sometimes <g>, I just started editing a file that had 2 inputboxes that I'd made up using the CodeWizard tool some years back (though I don't remember much from that far back <g>!). But I went and added another inputbox and darned if it doesn't work and work without hiccuping!!! <lol> MIracle I managed to do it <g>. Anyway, it's for creating folders. But I don't know how to apply the StringFormat to the leading number that will be inserted at the beginning of the created folder name. The user input for the folder number is in inputbox 1. Here is my code: expandcollapse popup; ; AutoIt 3x ; #Include <Date.au3> #include<_My_DATE.au3> ; my date, time conventions, etc. #NoTrayIcon ; AutoIt's icon doesn't show in systray TraySetIcon("Shell32.dll", 147) ; changes the icon displayed in the systray AutoItSetOption("WinTitleMatchMode", 2) ; this allows partial window titles to be valid! ;------------------------------------------------------------------------------------------------------------------------- #Region --- CodeWizard generated code Start --- ;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes, Width=250, Height=125 If Not IsDeclared("sInputBoxAnswer1") Then Local $sInputBoxAnswer1 ;===================================================================================================== $BoxTitle1 = "Create folder:" $LineTitle1 = "1. Number for next folder -- (i.e., ''2'', ''14'', or ''99'', etc. ...):" $BoxWidth1 = "525" $BoxHeight1 = "125" ;===================================================================================================== $sInputBoxAnswer1 = InputBox($BoxTitle1, $LineTitle1 & @CRLF & @CRLF, ""," ", $BoxWidth1, $BoxHeight1, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ClipPut($sInputBoxAnswer1) Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- If Not IsDeclared("sInputBoxAnswer2") Then Local $sInputBoxAnswer2 ;===================================================================================================== $BoxTitle2 = "Create folder:" $LineTitle2 = "2. yymmdd.ddd" & @CRLF & "(Today's date by default; but change, as needed in yymmdd.ddd format.):" $BoxWidth2 = "525" $BoxHeight2 = "145" ;===================================================================================================== $sInputBoxAnswer2 = InputBox($BoxTitle2, $LineTitle2 & @CRLF & @CRLF, $YrDate_Short," ", $BoxWidth2, $BoxHeight2, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ClipPut($sInputBoxAnswer2) Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- If Not IsDeclared("sInputBoxAnswer3") Then Local $sInputBoxAnswer3 ;===================================================================================================== $BoxTitle3 = "Create folder:" $LineTitle3 = "3. Name for folder -- (i.e., Pliers, etc.):" $BoxWidth3 = "525" $BoxHeight3 = "125" ;===================================================================================================== #Region --- CodeWizard generated code Start --- ;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes, Width=250, Height=125 If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer3 $sInputBoxAnswer3 = InputBox($BoxTitle3, $LineTitle3 & @CRLF & @CRLF, ""," ", $BoxWidth3, $BoxHeight3, Default, Default) ; width, heigh, left ("Default" centers box), top ("Default" centers box). Select Case @Error = 0 ;OK - The string returned is valid ;============================================================================== $PathAndFldrName = @ScriptDir & "\" & $sInputBoxAnswer1 & "." & $sInputBoxAnswer2 & "- " & $sInputBoxAnswer3 & " [rd" ;============================================================================== $Title1 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- PRODUCT DETAILS.txt" $LineText1 = "Seller:" & @TAB & @TAB & @TAB & "." & @CRLF & _ "* FULFILLED By:" & @TAB & "." & @CRLF & _ "Product:" & @TAB & @TAB & @TAB & "." & @CRLF & _ "Price:" & @TAB & @TAB & @TAB & "$ #.#" & @CRLF & @CRLF & @CRLF & _ "Price:" & @TAB & @TAB & @TAB & "$ #.#" & @CRLF & @CRLF & @CRLF & _ "--------------------------------" & @CRLF & _ "Source URL:" & @TAB & "." & @CRLF & _ "--------------------------------" & @CRLF & @CRLF & @CRLF & _ "Details:" & @TAB & @CRLF & "*******" & @CRLF & @CRLF & "." ;------------------------------------------------------------------------------ $Title2 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- [SOURCE URL FOR PRODUCT(S) (drag pg here4 2create)].url" $LineText2 = "" ;------------------------------------------------------------------------------ $Title3 = ClipGet() & ", _ _._ _- " & $sInputBoxAnswer3 & "- screencapture of order page.jpg" $LineText3 = "" ;============================================================================== DirCreate($PathAndFldrName) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title1, $LineText1) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title2, $LineText2) Sleep(50) FileWrite($PathAndFldrName & "\" & $Title3, $LineText3) Case @Error = 1 ;The Cancel button was pushed Exit ; finished Case @Error = 3 ;The InputBox failed to open Exit ; finished EndSelect #EndRegion --- CodeWizard generated code End --- [Now before anyone says, I'm sure it's ugly to you guys and it could probably be done waaayyyy better than this. But this is at my level and I can understand it <g>.] In other scripts that I have, I can ensure they keep the same naming convention in terms of number length by using StringFormat. An example I have of a line of working code can be seen here below. But I'm lost as how to apply it to the script above in the section dealing with $sInputBoxAnswer1 re the folder name. I think for 3 places with leading 0 -- to ensure the output is like this - 009, 054, 099, 125, etc. -- the code below with "StringFormat("%02i"," might need %03i, instead of %02i, no? ClipPut($YrDate_Short & "." & StringFormat("%02i", $number) & "- ") Thank you for any help in advance! Edited 3 hours ago by Diana (Cda)
argumentum Posted 2 hours ago Posted 2 hours ago 21 minutes ago, Diana (Cda) said: might need %03i Yes Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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