Insert current date to a file name

Share your macros, knowledge, solutions, services, ...
Post Reply
Posts: 106
Joined: Tue Oct 18, 2016 1:12 pm

Insert current date to a file name

Post by Petr » Wed Nov 23, 2016 5:53 pm

This macro sample shows how to insert current date to a selected file.

Code: Select all

<#> Start of the macro

<#> Start definition of procedure GetDateString  with parameter parDateString  
<proc_def_begin>(GetDateString, "&parDateString&")

<#> Assign value to variable parDateString

<#> End of procedure

<#> Start definition of procedure InsertDateToFileName with parameter parFileName 
<proc_def_begin>(InsertDateToFileName, "&parFileName&")

<#> Call procedure GetDateString with param. lpvDateString

<#> Count to vbLnt length of string parFileName
<var_oper>(vbLnt,"%parFileName%",STR_LENGTH,"","", "0")

<#> Begin loop for var. vbLnt
   <var_oper>(vbInx,"%vbLnt%-%_vLoopCounter%",CALC_EXPRESSION,"0","", "0")
   <var_oper>(vbChar,"%parFileName%",STR_GET_CHAR,"vbInx","", "0")

   <#> If found char "."

      <#> Insert var. lpvDateString before "."
      <var_oper>(parFileName,"%parFileName%",STR_INSERT,"vbInx","%lpvDateString%", "0")

      <#> Go to label lbl_b_End 

<#> Append var. lpvDateString at the end of variable parFileName ( char "." not found ...)
<var_oper>(parFileName,"%parFileName%",STR_APPEND,"%lpvDateString%","", "0")

<#> Label lbl_b_End

<#> End of procedure

<#> Macro execution starts here
<var_oper>(vFile,"",SELECT_FILE," ","", "0")

<#> If last key ESC or button Cancel
<if_str>("_vCanceled == 1")

<#> Else call procedure InsertDateToFileName with parameter vFile

<#> Show message with new file name...

<#> End of the macro

Post Reply