AutoIncluder for PB-IDE [win]
Posted: Mon Apr 09, 2007 2:00 pm
Open automatically all Includes, used by the actuell source, was loaded!
IDE options is set to only one instance!
Is not the fastest, but it works
Config:

download: http://ts-soft.eu/dl/autoincluder.zip
IDE options is set to only one instance!
Is not the fastest, but it works

Code: Select all
; OpenIncludes
; Autor: Thomas (ts-soft) Schulz
; PB4 erforderlich
EnableExplicit
Global Mutex.l
Procedure FindStringLeft(String.s, StringToFind.s, Startposition.l = 0)
Protected len, len2, index
len = Len(String)
len2 = Len(StringToFind)
If Startposition = 0
Startposition = len
EndIf
For index = Startposition To 1 Step - 1
If Mid(String, index, len2) = StringToFind
ProcedureReturn index
EndIf
Next
ProcedureReturn 0
EndProcedure
Procedure OnlyOne()
Mutex = CreateMutex_(0, 0, @"{112E4DF0-2388-41B2-87F4-CE683443180E}")
If GetLastError_() = #ERROR_ALREADY_EXISTS
ReleaseMutex_(Mutex)
CloseHandle_(Mutex)
ProcedureReturn #False
EndIf
ProcedureReturn #True
EndProcedure
Define.s Line, Path, Path2, IFile, PBDir, File = ProgramParameter()
Define.l FF, Pos, PosB, PosE, Ft = #PB_Ascii
While Not OnlyOne()
Delay(10)
Wend
PBDir = GetPathPart(GetEnvironmentVariable("PB_TOOL_IDE"))
If File <> ""
Path = GetPathPart(File)
FF = ReadFile(#PB_Any, File)
If FF
If ReadStringFormat(FF) <> #PB_Ascii : Ft = #PB_UTF8 : EndIf
FileBuffersSize(FF, Lof(FF))
While Not Eof(FF)
IFile = ""
Path2 = ""
Line = ReadString(FF, Ft)
Pos = FindString(Line, "IncludePath", 1)
If FindStringLeft(Line, ";", Pos) Or FindStringLeft(Line, #DQUOTE$, Pos)
Pos = 0
EndIf
If Pos
PosB = FindString(Line, #DQUOTE$, Pos + 12) + 1
PosE = FindString(Line, #DQUOTE$, PosB)
If PosB And PosE
Path = Mid(Line, PosB, PosE - PosB)
EndIf
EndIf
Pos = FindString(Line, "IncludeFile", 1)
If FindStringLeft(Line, ";", Pos) Or FindStringLeft(Line, #DQUOTE$, Pos)
Pos = 0
EndIf
If Pos
PosB = FindString(Line, #DQUOTE$, Pos + 12) + 1
PosE = FindString(Line, #DQUOTE$, PosB)
If PosB And PosE
IFile = Mid(Line, PosB, PosE - PosB)
EndIf
EndIf
Pos = FindString(Line, "XIncludeFile", 1)
If FindStringLeft(Line, ";", Pos) Or FindStringLeft(Line, #DQUOTE$, Pos)
Pos = 0
EndIf
If Pos
PosB = FindString(Line, #DQUOTE$, Pos + 13) + 1
PosE = FindString(Line, #DQUOTE$, PosB)
If PosB And PosE
IFile = Mid(Line, PosB, PosE - PosB)
EndIf
EndIf
If FindString(Line, "#PB_Compiler_Home", Pos + 12)
Path2 = PBDir
EndIf
If IFile <> ""
If Path2 <> "" And FileSize(Path2 + IFile) > 0
RunProgram(Path2 + IFile, "", "", #PB_Program_Wait)
Else
If FileSize(IFile) > 0
RunProgram(IFile, "", "", #PB_Program_Wait)
Else
If FileSize(Path + IFile) > 0
RunProgram(Path + IFile, "", "", #PB_Program_Wait)
EndIf
EndIf
EndIf
EndIf
Wend
CloseFile(FF)
EndIf
EndIf
CloseHandle_(Mutex)

download: http://ts-soft.eu/dl/autoincluder.zip