Resident-Maker
Posted: Mon Mar 25, 2013 8:13 pm
Hi,
here is a little tool to make resident files by ease. First you have to create an executable from this code. Afterwards please add an entry in the tools menu which points to the executable and set %FILE as argument. By running this tool, the current source file will be compiled thru the resident maker and a *.res file will be saved in the resident folder. To let the created or changed resident take effect, you have at least to restart the compiler or restart the PB IDE. That's all.
Best regards
Uwe
here is a little tool to make resident files by ease. First you have to create an executable from this code. Afterwards please add an entry in the tools menu which points to the executable and set %FILE as argument. By running this tool, the current source file will be compiled thru the resident maker and a *.res file will be saved in the resident folder. To let the created or changed resident take effect, you have at least to restart the compiler or restart the PB IDE. That's all.
Code: Select all
EnableExplicit
Define.s src, ext, nam, res, path, cmd, arg, out
#Title = "Resident-Creator"
;check if the filename was handed over
If CountProgramParameters() <> 1
MessageRequester(#Title, "Use %FILE as argument.")
Else
;get src filename
src = ProgramParameter()
;make resident name
ext = "." + GetExtensionPart(src)
nam = ReplaceString(GetFilePart(src), ext, ".res")
;OS relevant stuff
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
#Option = "/RESIDENT"
#Separator = "\"
#Residents = "Residents"
CompilerElse
#Option = "-r"
#Separator = "/"
#Residents = "residents"
nam = LCase(nam)
CompilerEndIf
;delete existing resource name
res = #PB_Compiler_Home + #Residents + #Separator + nam
If FileSize(res) >= 0 And Not DeleteFile(res)
MessageRequester(#Title, "The Resident-File could not be deleted!")
Else
;create startup parameters
path = #PB_Compiler_Home + "compilers" + #Separator
cmd = path + "pbcompiler"
arg = #DQUOTE$ + src + #DQUOTE$ + " " + #Option + " " + #DQUOTE$ + res + #DQUOTE$
;compile
Define p = RunProgram(cmd, arg, path, #PB_Program_Hide | #PB_Program_Open | #PB_Program_Read)
If IsProgram(p)
While ProgramRunning(p)
If AvailableProgramOutput(p)
out.s + ReadProgramString(p) + #CRLF$
EndIf
Wend
CloseProgram(p)
EndIf
;show output message
MessageRequester(#Title, out)
EndIf
EndIf
Uwe