Jump to content

Add timestamp or text in au3 file when compling


Recommended Posts

Hello,

 

I was wondering if there is a possibility to add timestamp or text when compiling the au3 file. for instance to have the time compile somewhere in my au3 file?

Thanks in advance

Cramaboule

Link to post
Share on other sites

Yes Indeed, I thought about it, but how ? I haven't a clear idea.

Link to post
Share on other sites
  • Developers
Posted (edited)

When you have the Full SciTE4AutoIt3 installed you have this option:

Quote

; free form resource fields ... max 15
;     you can use the following variables:
;     %AutoItVer% which will be replaced with the version of AutoIt3
;     %date% = PC date in short date format
;     %longdate% = PC date in long date format
;     %time% = PC timeformat
;  eg: #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
#AutoIt3Wrapper_Res_Field=                      ;Free format fieldname|fieldvalue

 

.. which can add an additional field to the PE header which you can see when opening the properties of the compiled script.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
  • Developers

In that case one can write a script to do so and add that to the script to runbefore/after via a directive. One just needs to use their imagination! ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
3 hours ago, cramaboule said:

I haven't a clear idea.

Just as an inspiration (there might be simpler ways to solve the problem by now 🤔) :

1. created by @BugFix in 2011 : time-stamp-and-small-version-backup-management

2. also from BugFix (2021) : timestamp-versionierung (Description only in german)

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites
  • Developers
Posted (edited)

Timestamp versioning (as in setting the version directive) can also be done with a template directive in the standard functionality. 😉

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

I came up with this:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Run_Before=test-timestamp.exe %in%
#AutoIt3Wrapper_Run_Tidy=y
#Au3Stripper_Parameters=/mo
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Region ;Timestamp =====================
#                     2022/05/24 14:29:20
#EndRegion ;Timestamp =====================
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.16.0
 Author:         Marc Arm

 Script Function:
    Time stamp in prg

#ce ----------------------------------------------------------------------------

#include <MsgBoxConstants.au3>
#include <File.au3>
#include <Date.au3>
#include <Array.au3>

Dim $aFile

If $CmdLine[0] = 1 Then
    $sFile = $CmdLine[1]
    If StringRight($sFile, 4) <> '.au3' Then
        MsgBox($MB_OK + $MB_ICONERROR, 'Error', 'Error, wrong file input' & @CRLF & 'Must be "*.au3"', 3)
    EndIf
Else
    MsgBox($MB_OK + $MB_ICONERROR, 'Error', 'Error, no file input', 3)
    Exit
EndIf



_FileReadToArray($sFile, $aFile, 1)
For $i = 1 To $aFile[0]
    If StringRegExp($aFile[$i], "^#EndRegion") Then
        $nLine = $i
        ExitLoop
    EndIf
Next

If StringRegExp($aFile[$nLine + 1], "^#Region ;Timestamp") Then
    _FileWriteToLine($sFile, $nLine + 2, "#                     " & _NowCalc(), True, True)
Else
    _ArrayInsert($aFile, $nLine + 1, "#Region ;Timestamp =====================")
    _ArrayInsert($aFile, $nLine + 2, "#                     " & _NowCalc())
    $aFile[0] = _ArrayInsert($aFile, $nLine + 3, "#EndRegion ;Timestamp =====================")
    _FileWriteFromArray($sFile, $aFile, 1)
EndIf

C.

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

    No registered users viewing this page.

×
×
  • Create New...