この種のタスクにはバッチ ファイルを使用することを既に提案しましたが、サンプル スクリプトを作成しました。これは、特定のディレクトリ内のすべての *.tzs スクリプト ファイルを処理し、ファイルごとにファイルが含まれているかどうかを確認しようとします。作成されました (または、存在する場合はより具体的に)。これはもちろん、ヘルプ ファイルに示されているような *.tzs スクリプトの非常に基本的な使用方法を前提としています。ここにあります:
#define FindHandle
#define FindResult
#define ScriptFile
#define ScriptLine
#define ScriptHandle
#define ArchiveFile
; unique identifier for the target archive file name property member
#define ArchiveToken ".Archive="
; path to directory, where all the *.tzs script files will be processed
#define ScriptPath "d:\Development\__StackOverflow\14579484\"
; tool, which will be used for the *.tzs file processing mentioned above
#define ScriptTool "c:\Program Files (x86)\TUGZip\TzScript.exe"
; This procedure tries to extract the name of the archive, to be created from
; the line currently read from the just processed *.tzs script file. It first
; tries to search the ArchiveToken constant value in trimmed, space-less line
; of script. If it's found, and the script line contains also two quotes, the
; file name is stored to the ArchiveFile variable, by which is later checked
; the file existence after the script execution is done
#sub ParseScriptLine
#define SrcPos = Pos("""", ScriptLine)
#define EndPos = RPos("""", ScriptLine)
#define ParsedStr = Trim(StringChange(ScriptLine, " ", ""))
#if (Pos(ArchiveToken, ParsedStr) != 0) && (SrcPos != 0) && (EndPos != 0) && (SrcPos != EndPos)
#expr ArchiveFile = Copy(ScriptLine, SrcPos + 1, EndPos - SrcPos - 1)
#expr ArchiveFile = StringChange(ArchiveFile, "\\", "\")
#if ArchiveFile != ""
#pragma message "ExecuteScriptFile: ArchiveFile=" + ArchiveFile
#expr ExecuteScriptFile
#endif
#endif
#endsub
; This procedure opens the currently processed *.tzs script file and starts to
; read it line by line to get the file name of the archive to be created
#sub ReadScriptFile
#pragma message "ReadScriptFile: ScriptFile=" + ScriptPath + ScriptFile
#for {ScriptHandle = FileOpen(ScriptPath + ScriptFile); \
ScriptHandle && !FileEof(ScriptHandle); ScriptLine = FileRead(ScriptHandle)} \
ParseScriptLine
#if ScriptHandle
#expr FileClose(ScriptHandle)
#endif
#endsub
; This procedure is used for the script execution itself, here the TzScript.exe
; tool is called passing the name of the currently processed script file. After
; this tool is done, it's checked if the expected archive file has been created
#sub ExecuteScriptFile
#if Exec(ScriptTool, ScriptPath + ScriptFile) == 0
#if FileExists(ArchiveFile) == 0
#error The expected archive was not found. Compilation will abort now!
#endif
#else
#error An error occured at script tool starting. Compilation will abort now!
#endif
#endsub
; This is the file iteration "callback"
#sub ProcessFoundFile
#expr ScriptFile = FindGetFileName(FindHandle)
#expr ReadScriptFile
#endsub
; This procedure is used to find all the *.tzs script files in folder, specified
; by the ScriptPath constant path. All the *.tzs files found there are executed
; by the command line tool specified by the ScriptTool constant
#for {FindHandle = FindResult = FindFirst(ScriptPath + "*.tzs", 0); \
FindResult; FindResult = FindNext(FindHandle)} \
ProcessFoundFile
#if FindHandle
#expr FindClose(FindHandle)
#endif
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output