This code is not optimized and you have to change the first 3 constants!
Code: Select all
; Configure as
;
; Commandline: "%TEMPFILE"
; Trigger: "New Sourcecode created"
; [x] Wait until tool quits
; [x] Reload Source after tool has quit
; (x) into current source
; [x] Hide tool from the Main menu
;
EnableExplicit
#APP_NAME_DEFAULT$ = "Example"
#AUTHOR_DEFAULT$ = "Thomas <ts-soft> Schulz"
#VERSION_DEFAULT$ = "0.0"
Procedure.s GetPBCompilerVersion()
Protected Compiler, result.s
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
Compiler = RunProgram(GetEnvironmentVariable("PB_TOOL_Compiler"), "/STANDBY", "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Write | #PB_Program_Hide)
CompilerDefault
Compiler = RunProgram(GetEnvironmentVariable("PB_TOOL_Compiler"), "--standby", "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Write | #PB_Program_Hide)
CompilerEndSelect
If Compiler
result = StringField(ReadProgramString(Compiler), 3, #TAB$)
WriteProgramStringN(Compiler, "END")
CloseProgram(Compiler)
EndIf
ProcedureReturn result
EndProcedure
Procedure.s ReadPBPrefs(group.s, key.s)
Protected result.s, prefs.s = GetEnvironmentVariable("PB_TOOL_Preferences")
If OpenPreferences(prefs)
PreferenceGroup(group)
result = ReadPreferenceString(key, "")
ClosePreferences()
EndIf
ProcedureReturn result
EndProcedure
Define.s File = ProgramParameter()
Define FF, Format
FF = CreateFile(#PB_Any, File)
If FF
Select ReadPBPrefs("CompilerDefaults", "TextEncoding")
Case "1"
Format = #PB_UTF8
Default
Format = #PB_Ascii
EndSelect
WriteStringFormat(FF, Format)
WriteStringN(FF, "; ==============================================================", Format)
WriteStringN(FF, "; COMPILER OPTIONS:", Format)
Select ReadPBPrefs("CompilerDefaults", "InlineASM")
Case "0"
WriteStringN(FF, "; [ ] Enable inline ASM support", Format)
Default
WriteStringN(FF, "; [x] Enable inline ASM support", Format)
EndSelect
Select ReadPBPrefs("CompilerDefaults", "Unicode")
Case "0"
WriteStringN(FF, "; [ ] Create unicode executable", Format)
Default
WriteStringN(FF, "; [x] Create unicode executable", Format)
EndSelect
Select ReadPBPrefs("CompilerDefaults", "Thread")
Case "0"
WriteStringN(FF, "; [ ] Create threadsafe executable", Format)
Default
WriteStringN(FF, "; [x] Create threadsafe executable", Format)
EndSelect
Select ReadPBPrefs("CompilerDefaults", "OnError")
Case "0"
WriteStringN(FF, "; [ ] Enable OnError lines support", Format)
Default
WriteStringN(FF, "; [x] Enable OnError lines support", Format)
EndSelect
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Select ReadPBPrefs("CompilerDefaults", "XPSkin")
Case "0"
WriteStringN(FF, "; [ ] Enable XP skin support", Format)
Default
WriteStringN(FF, "; [x] Enable XP skin support", Format)
EndSelect
Select ReadPBPrefs("CompilerDefaults", "VistaAdmin")
Case "0"
WriteStringN(FF, "; [ ] Request Administrator mode for Windows Vista", Format)
Default
WriteStringN(FF, "; [x] Request Administrator mode for Windows Vista", Format)
EndSelect
Select ReadPBPrefs("CompilerDefaults", "VistaUser")
Case "0"
WriteStringN(FF, "; [ ] Request User mode for Windows Vista (no virtualization)", Format)
Default
WriteStringN(FF, "; [x] Request User mode for Windows Vista (no virtualization)", Format)
EndSelect
CompilerEndIf
WriteStringN(FF, "; Library Subsystem: " + ReadPBPrefs("CompilerDefaults", "SubSystem"), Format)
Select ReadPBPrefs("CompilerDefaults", "TextEncoding")
Case "1"
WriteStringN(FF, "; File Format: UTF-8", Format)
Default
WriteStringN(FF, "; File Format: ASCII", Format)
EndSelect
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Select ReadPBPrefs("CompilerDefaults", "ExeFormat")
Case "1"
WriteStringN(FF, "; Executable Format: Console", Format)
Case "2"
WriteStringN(FF, "; Executable Format: Shared DLL", Format)
Default
WriteStringN(FF, "; Executable Format: Windows", Format)
EndSelect
CompilerElse
Select ReadPBPrefs("CompilerDefaults", "ExeFormat")
Case "1"
WriteStringN(FF, "; Executable Format: Console", Format)
Case "2"
WriteStringN(FF, "; Executable Format: Shared .so", Format)
Default
WriteStringN(FF, "; Executable Format: Linux", Format)
EndSelect
CompilerEndIf
WriteStringN(FF, ";", Format)
WriteStringN(FF, "; Created on: " + FormatDate("%dd/%mm/%yyyy %hh:%ii", Date()), Format)
WriteStringN(FF, "; App/Lib-Name: " + #APP_NAME_DEFAULT$, Format)
WriteStringN(FF, "; Author: " + #AUTHOR_DEFAULT$, Format)
WriteStringN(FF, "; Version: " + #VERSION_DEFAULT$, Format)
WriteStringN(FF, "; Compiler: " + GetPBCompilerVersion(), Format)
WriteStringN(FF, "; ==============================================================", Format)
WriteStringN(FF, "", Format)
WriteStringN(FF, "EnableExplicit", Format)
WriteStringN(FF, "", Format)
CloseFile(FF)
EndIf
Code: Select all
; ==============================================================
; COMPILER OPTIONS:
; [ ] Enable inline ASM support
; [x] Create unicode executable
; [ ] Create threadsafe executable
; [ ] Enable OnError lines support
; [x] Enable XP skin support
; [ ] Request Administrator mode for Windows Vista
; [x] Request User mode for Windows Vista (no virtualization)
; Library Subsystem:
; File Format: UTF-8
; Executable Format: Windows
;
; Created on: 13/10/2012 21:21
; App/Lib-Name: Example
; Author: Thomas <ts-soft> Schulz
; Version: 0.0
; Compiler: PureBasic 5.00 Beta 5 (Windows - x64)
; ==============================================================
EnableExplicit