1. riešenie:
'*******************************************************************************
******
' Update "Last update" date in current document and save it
'
' Example:
' // Last update: Jul 15, 2026
' becomes:
' // Last update: Aug 5, 2026
'
' Description : Updates the "Last update:" line to current date
' and saves the active document.
' Version : 1.0
'*******************************************************************************
******
Option Explicit
Const module_name = "UpdateLastDate"
Const module_ver = "1.0"
Sub UpdateLastDate
Dim editor
Dim txt
Dim re
Dim today
Dim newDate
Dim monthNames
Set editor = NewEditor()
editor.assignActiveEditor()
' Current date
today = Date
monthNames = Array( _
"Jan", "Feb", "Mar", "Apr", "May", "Jun", _
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" _
)
newDate = monthNames(Month(today) - 1) _
& " " & Day(today) _
& ", " & Year(today)
' Get complete document
txt = editor.Text
' Find:
' // Last update: Jul 15, 2026
'
' Everything after "Last update:" on that line is replaced.
Set re = New RegExp
re.Pattern = "(//[ ]*Last update:[ ]*)[A-Za-z]{3}[
]+[0-9]{1,2},[
]+[0-9]{4}"
re.Global = False
re.IgnoreCase = True
If re.Test(txt) Then
txt = re.Replace(txt, "$1" & newDate)
' Replace document contents
editor.command("ecSelectAll")
editor.selText(txt)
' Save active document
runPSPadAction("aSave")
Else
MsgBox _
"Line '// Last update: ...' was not found.", _
vbExclamation, _
"Update Last Date"
End If
Set re = Nothing
Set editor = Nothing
End Sub
' Name "Init" is required.
' It is called automatically by PSPad during script initialization.
Sub Init
addMenuItem _
"Update Last Date && Save", _
"Date / Version", _
"UpdateLastDate", _
"Shift+Ctrl+S"
End Sub
--
<https://forum.pspad.com/read.php?1,79795,79797>
PSPad freeware editor https://www.pspad.com