Jump to content

Recommended Posts

Posted

Hi,

I'm completely new to AutoIt and don't have much knowledge and experience in programming.

I apologize in advance if I ask questions that seem obvious or silly.

I have a routine which I follow every sunday. It includes many many actions.

To start with, I need to create a folder with today's date. Easy enough:

DirCreate("C:\Sunday Reports\" & @MON & "-" & @MDAY & "-" & @YEAR )

However, I need the month to be spelled out, e.g. April-3-2011

I tried this, but AutoIt just created a folder with the day and year:

Local $aMonths[13] = [12, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

DirCreate("C:\Sunday Reports\" & $aMonths & "-" & @MDAY & "-" & @YEAR )

Then I need to create subfolders, which again, I'm missing something in the syntax:

DirCreate("C:\Sunday Reports\" & @MON & "-" & @MDAY & "-" & @YEAR )

DirCreate("C:\Sunday Reports\" & @MON & "-" & @MDAY & "-" & @YEAR\ & "CCC" )

Tried searching the forum and the help topics, which helped me partially, but got stuck with the months.

Thanks,

Miriam

Posted (edited)

Welcome to the forum ! Posted Image

Try this :

Local $aMonths[13] = [12, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
For $_I = 1 To 12
    DirCreate ( "C:\Sunday Reports\" & $aMonths[$_I] & "-" & @MDAY & "-" & @YEAR & '\ccc' )
Next
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

Thanks a lot!

That worked.

Can I ask you about the logic of the syntax?

I'm trying to learn how to write scripts myself :unsure:

For ... Next: what prevents AutoIt from creating 12 folders?

How did it know to create today's month?

I hope it's OK I'm asking.

Thanks,

Miriam

Posted

Sorry - I just looked again and realized that the potential problem I described below indeed occurred!

AutoIt created 12 folders with today's date but 12 different months!

All I needed is to create ONE folder with today's month.

Instead it created this:

May-09-2011

June-09-2011

July-09-2011

etc.

Thanks again,

Miriam

Posted

This is a quick and dirty solution - put it in a function and call it before you create the directory, and use $mon instead of @mon in the name.

Select
    Case @MON = 1
        $Mon = "January"
    Case @MON = 2
        $Mon = "February"
    Case @MON = 3
        $Mon = "March"
    Case @MON = 4
        $Mon = "April"
    Case @MON = 5
        $Mon = "May"
    Case @MON = 6
        $Mon = "June"
    Case @MON = 7
        $Mon = "July"
    Case @MON = 8
        $Mon = "August"
    Case @MON = 9
        $Mon = "September"
    Case @MON = 10
        $Mon = "October"
    Case @MON = 11
        $Mon = "November"
    Case @MON = 12
        $Mon = "December"
EndSelect

William

Posted

This is a quick and dirty solution - put it in a function and call it before you create the directory, and use $mon instead of @mon in the name.

Select
    Case @MON = 1
        $Mon = "January"
    Case @MON = 2
        $Mon = "February"
    Case @MON = 3
        $Mon = "March"
    Case @MON = 4
        $Mon = "April"
    Case @MON = 5
        $Mon = "May"
    Case @MON = 6
        $Mon = "June"
    Case @MON = 7
        $Mon = "July"
    Case @MON = 8
        $Mon = "August"
    Case @MON = 9
        $Mon = "September"
    Case @MON = 10
        $Mon = "October"
    Case @MON = 11
        $Mon = "November"
    Case @MON = 12
        $Mon = "December"
EndSelect

William

Sorry, I'm a real beginner, and am a little bit embarrassed to ask this :unsure: , but what do you mean by "put it in a function and call it before.

Thanks again.

Miriam

Posted (edited)

Global $Mon ; declares global variable - another quick and dirty method, 
;             rather than passing the variable in the return value.

Monthname() ; runs the function which sets the value of $Mon

DirCreate("C:\Sunday Reports\" & $Mon & "-" & @MDAY & "-" & @YEAR )  ; your bit, with $Mon substituted for @MON

Func Monthname()

Select                  
    Case @MON = 1
        $Mon = "January"
    Case @MON = 2
        $Mon = "February"
    Case @MON = 3
        $Mon = "March"
    Case @MON = 4
        $Mon = "April"
    Case @MON = 5
        $Mon = "May"
    Case @MON = 6
        $Mon = "June"
    Case @MON = 7
        $Mon = "July"
    Case @MON = 8
        $Mon = "August"
    Case @MON = 9
        $Mon = "September"
    Case @MON = 10
        $Mon = "October"
    Case @MON = 11
        $Mon = "November"
    Case @MON = 12
        $Mon = "December"
EndSelect

endfunc ; ===> Monthname

William

Edited by saywell
  • Moderators
Posted

MiriamSapir,

Sorry, I'm a real beginner, and am a little bit embarrassed to ask this

Do not be embarrassed - we all started at that point! :>

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You might also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

MiriamSapir,

Do not be embarrassed - we all started at that point! :>

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You might also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. :unsure:

M23

Thank you all for your explanations and suggestions!

This is really very helpful and much appreciated.

While I did read the manuals and searched the UDF, they helped me get started but I still get stuck often.

Thank you everyone!

Miriam

Posted

One folder...ok

#include <Date.au3>

DirCreate ( "C:\Sunday Reports\" & _DateToMonth ( @MON, 1 ) & "-" & @MDAY & "-" & @YEAR & '\ccc' )

hope it's the good one ! Posted Image

Edit : see helpfile for _DateToMonth if you want short or complete name.

This did the job.

And after reading the helpfile, I understand the sytanx much better.

The trouble I have with the manuals, or the functions actually, is sometimes I look for a phrase and it's defined differently in the guide.

For example: I'm looking to sort files in windows explorer but could not find something tailored to my needs.

Then, after searching the forum, someone mentioned list_view, or something like that, which also does sorting.

But I would have never found it unless I looked at each function.

Thanks!

By the way,

Posted

....

However, I need the month to be spelled out, e.g. April-3-2011

I tried this, but AutoIt just created a folder with the day and year:

Local $aMonths[13] = [12, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

DirCreate("C:\Sunday Reports\" & $aMonths & "-" & @MDAY & "-" & @YEAR )

Then I need to create subfolders, which again, I'm missing something in the syntax:

DirCreate("C:\Sunday Reports\" & @MON & "-" & @MDAY & "-" & @YEAR )

DirCreate("C:\Sunday Reports\" & @MON & "-" & @MDAY & "-" & @YEAR\ & "CCC" )

....

Try this.

Local $aMonths[13] = [12, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

ConsoleWrite("C:\Sunday Reports\" & $aMonths[@MON] & "-" & @MDAY & "-" & @YEAR & @CRLF)
ConsoleWrite("C:\Sunday Reports\" & $aMonths[@MON] & "-" & @MDAY & "-" & @YEAR & "\CCC" & @CRLF)

;DirCreate("C:\Sunday Reports\" & $aMonths[@MON] & "-" & @MDAY & "-" & @YEAR)
;DirCreate("C:\Sunday Reports\" & $aMonths[@MON] & "-" & @MDAY & "-" & @YEAR & "\CCC")

@saywell

Because all the expressions of case statements in this Select...Case...EndSelect routine start with @MON = .... , I believe using "Switch @MON" in a Switch...Case...EndSwitch routine would be easier.

But in this example, selecting the appropiate element directly from an array of months would be more efficient.

...

Edit : see helpfile for _DateToMonth if you want short or complete name.

@wakillon

Just a heads up to the bug with getting the short month name from _DateToMonth.

Note in the _DateToMonth() function in the Date.au3 include file, the $aMonthNumberAbbrev array does not have the conventional three character short names of every month.

Posted

@wakillon

Just a heads up to the bug with getting the short month name from _DateToMonth.

Note in the _DateToMonth() function in the Date.au3 include file, the $aMonthNumberAbbrev array does not have the conventional three character short names of every month.

Yes, June, July and Sept have 4 characters short names format, instead of others.

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...