Jump to content

@year but only last digits


Recommended Posts

im trying to create a folder on my desktop that has the date as the name. but i want the year to only be the last 2 digits. ie today would be "050511" rather then "05052011".

any ideas? or can someone tell me how the marco works? meaning where it gets the date from. is it like a UDF where i can modify the code for it?

DirCreate(@DesktopDir & $Name & " " & @MON & @MDAY & "10")
<--a good way to start you day
Link to comment
Share on other sites

MsgBox(0, "Result", StringRight(@Year, 2))

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • Moderators

RogerRabbitsClone,

AutoIt folder macros do not have a trailing \ - try this:

$year = StringRight(@Year, 2)

$name = ("henry")

DirCreate(@DesktopDir & "\" & $name & " " & @MON & @MDAY & $year & " ")

Works for me. :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

 

Link to comment
Share on other sites

Now that you learned those 2 valuable lessons, it's time for another one

$sDesired = @DesktopDir & "\" & @UserName & @MON & @MDAY & StringRight(@Year, 2) & " "

$sFldr = @DesktopDir & StringFormat("\%s%02d%02d%02d ", @UserName,@MON, @MDAY, StringRight(@Year, 2))
MsgBox(0, "StringFormat Result", "Desired:     " & $sDesired & @CRLF & "Achieved:  " & $sFldr)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

@GEOSoft: StringFormat is useful, but really slow. So avoid to use it in long loops or try to do it outside the loop.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

@GEOSoft: StringFormat is useful, but really slow. So avoid to use it in long loops or try to do it outside the loop.

Hmmm

I don't remember putting it in a loop and it's only slow if there are a lot of iterations anyway.

Besides it was meant as a learning experience.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Hmmm

I don't remember putting it in a loop and it's only slow if there are a lot of iterations anyway.

Besides it was meant as a learning experience.

I know. I just wanted to give some more information. In the beginning I always used StringFormat when I had more than 2 or 3 variables to concat until I realized the performance hit.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

No problem. The more - the merrier.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Now that you learned those 2 valuable lessons, it's time for another one

$sDesired = @DesktopDir & "\" & @UserName & @MON & @MDAY & StringRight(@Year, 2) & " "

$sFldr = @DesktopDir & StringFormat("\%s%02d%02d%02d ", @UserName,@MON, @MDAY, StringRight(@Year, 2))
MsgBox(0, "StringFormat Result", "Desired:     " & $sDesired & @CRLF & "Achieved:  " & $sFldr)

forgot the dircreate

$sDesired = dircreate(@DesktopDir & "\" & @UserName & @MON & @MDAY & StringRight(@Year, 2) & " ")

but awesome! thanks guys.

this is part of my ongoing project to pull business card orders from a table in outlook and slap the info into Adobe InDesign. i wrote it when i was using CS4, and the CS5 upgrade screwed it all up, so im redoing a bunch of it.

since i have your attentions, i dont suppose anybody knows if there are Adobe functions, like _IE and _EXCEL?

<--a good way to start you day
Link to comment
Share on other sites

There isn't a UDF per say but I have seen Examples floating around the Forum.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

forgot the dircreate

$sDesired = dircreate(@DesktopDir & "\" & @UserName & @MON & @MDAY & StringRight(@Year, 2) & " ")

but awesome! thanks guys.

this is part of my ongoing project to pull business card orders from a table in outlook and slap the info into Adobe InDesign. i wrote it when i was using CS4, and the CS5 upgrade screwed it all up, so im redoing a bunch of it.

since i have your attentions, i dont suppose anybody knows if there are Adobe functions, like _IE and _EXCEL?

Oh no I didn't forget. That was just to show you how the Formatted string gave you the same results as $sDesired which in the test was a text string.

It would actually be DirCreate($sFldr)

You can forget all about $sDesired and just set the right information in the StringFormat()

As a matter of fact you could even change that line to

$sFldr = StringFormat("%s\%s%02d%02d%02d ", @DesktopDir, @UserName,@MON, @MDAY, StringRight(@Year, 2))
DirCreate($sFldr)
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Oh no I didn't forget. That was just to show you how the Formatted string gave you the same results as $sDesired which in the test was a text string.

It would actually be DirCreate($sFldr)

You can forget all about $sDesired and just set the right information in the StringFormat()

As a matter of fact you could even change that line to

$sFldr = StringFormat("%s\%s%02d%02d%02d ", @DesktopDir, @UserName,@MON, @MDAY, StringRight(@Year, 2))
DirCreate($sFldr)

:unsure: ooooOOOOOoooooo.. iiiiiiiiiii see. thanks

@guinness, i tried searching the forums to no avail. im not too worried about it, but if you happen to find one drop me a line. right now the only way i can interact with indesign is send, winwait etc commands. uber buggy.

<--a good way to start you day
Link to comment
Share on other sites

the only way i can interact with indesign is send, winwait etc commands. uber buggy.

It can be much less buggy if you use window handles, using proper WinWait() statements with timeout traps, and controlsend() instead of send().

I've had to automate AS400 emulators before, scraping text and interfacing with Excel and IE.

It's not difficult and not terribly buggy if you build proper code.

Make judicious use of the Window Spy tool built into the SciTE editor. Especially when trying to get controls.

By way of example on how I use controlsend and window handles and WinWait() traps:

Variables are labeled at the beginning of the variable's name: hwnd = window handle i = integer s = string b = binary f = float a = array

#RequireAdmin
Opt("MustDeclareVars", 1)
Opt("WinTitleMatchMode", 4)

Func Install7z()
    Local $hwnd7zInst = Default, $iLoop = Default
    If Not FileExists(@ScriptDir & "\7-zip\7za.exe") Then
        ConsoleWrite("7-zip not detected. Installing.")
        FileInstall("C:\SciteScripts\Support\7-zip\7za920.exe", @ScriptDir & "\7-zip\", 1)
        Run(@ScriptDir & "\7-zip\7za920.exe")
        If Not WinWait("7-Zip self-extracting archive", "", 30) Then
            ConsoleWrite("Timeout on window detection for istallation of 7-zip")
            SetError(-10)
            Return 0
        EndIf
        $hwnd7zInst = WinGetHandle("7-Zip self-extracting archive")
        WinActivate($hwnd7zInst)
        ControlSend($hwnd7zInst, "", "[CLASSNN:Edit1]", @ScriptDir & "\7-zip\")
        ControlClick($hwnd7zInst, "", "[CLASSNN:Button2; TEXT:]", "primary", 1)
    EndIf
    $iLoop = 0
    While 1
        Sleep(750)
        $iLoop += 1
        If FileExists(@ScriptDir & "\7-zip\7za.exe") Then
            ConsoleWrite("7-zip detected as installed.  Exiting Loop.")
            ExitLoop
        EndIf
        If $iLoop >= 30 Then
            ConsoleWrite("7-zip not detected as installed.  Timeout. Aborting.")
            SetError(-11)
            Return 0
        EndIf
    WEnd
    $iLoop = 0
        Return 1
EndFunc   ;==>Install7z
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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