After loading a source code into the IDE, this tool shows when it was last modified and with which compiler.
I recently continued working on a project and didn't realize that I had opened an old version due to a saved file link.
And I would like to know with which compiler the project was last compiled, because I often have to switch the IDE between x86 and x64.
To use it: add the compiled file as a IDE tool. Argument “%FILE” and trigger “Source code loaded”
Code: Select all
; PB IDE Tool - CheckCodeOnLoad
; by Dige 01/2025
; Get the meta info from the code to be loaded
Global G_Color.i = #Green
Procedure.s GetStringfromDate(dtg.i)
Protected diff.i, result.s
Protected y = 24*3600*365
Protected m = 24*3600*31
Protected d = 24*3600
Protected h = 3600
Protected i = 60
diff = date() - dtg
If diff > y
result = Strf(diff / y, 1) + " year"
ElseIf diff > m
result = Strf(diff / m, 1) + " month"
ElseIf diff > d
result = Strf(diff / d, 1) + " day"
ElseIf diff > h
result = Strf(diff / h, 1) + " hour"
ElseIf diff > i
result = Strf(diff / i, 1) + " min"
Else
result = Str(diff) + "sec"
EndIf
result = FormatDate("%dd.%mm.%yyyy %hh:%ii:%ss", dtg) + " [" + result + " ago]"
ProcedureReturn result
EndProcedure
Procedure.s ParseInInformations(file.s)
Protected fileid.i, dtg_modify.i, dtg_access.i, dtg_create.i, txt.s, ff, n, i
Protected NewList code.s()
if FileSize(file) <= 0
End
endif
dtg_create = GetFileDate(file, #PB_Date_Created)
dtg_access = GetFileDate(file, #PB_Date_Accessed)
dtg_modify = GetFileDate(file, #PB_Date_Modified)
fileid = ReadFile(#PB_Any, file, #PB_File_SharedRead|#PB_File_SharedWrite)
If fileid
ff = ReadStringFormat(fileid)
; Einlesen aller Zeilen die mit ; beginnen
While Not Eof(fileid)
txt = ReadString(fileid, ff)
If Mid(txt, 1, 1) = ";"
AddElement(code())
code() = txt
Endif
Wend
LastElement(code())
txt = ""
n = ListSize(code())
; Rückwärts alle IDE Settings einlesen
For i = 1 to n
txt = Mid(code(), 2) + #CRLF$ + txt
If FindString(code(), "; IDE Options = ", 0, #PB_String_NoCase)
If (FindString(code(), "x86", 0, #PB_String_NoCase) And #PB_Compiler_32Bit <> 1) or (FindString(code(), "x64", 0, #PB_String_NoCase) And #PB_Compiler_64Bit <> 1)
; IDE Options = PureBasic 6.20 Beta 2 (Windows - x86)
txt = "⚠ COMPILER CHANGED! ⚠" + #CRLF$ + #CRLF$ + txt
G_Color = #Red
EndIf
i = n + 1
EndIf
PreviousElement(code())
Next
CloseFile(fileid)
Endif
txt = GetFilePart(file) + #CRLF$ + #CRLF$ +
"Modify : " + GetStringfromDate (dtg_modify) + #CRLF$ +
"Create : " + GetStringfromDate (dtg_create) + #CRLF$ +
"Access : " + GetStringfromDate (dtg_access) + #CRLF$ +
#CRLF$ + txt
ProcedureReturn txt
EndProcedure
Procedure UpdateWindow()
ResizeGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20)
EndProcedure
Define.s file = ProgramParameter()
Define timeout = date() + 5
Define MouseX.i, MouseY.i
Define WindowRect.RECT
Define x, y
Define flags
If ExamineDesktops()
x = DesktopWidth(0)/2 - 200
y = DesktopHeight(0) - 280
EndIf
; file = "C:\Temp\x64Test.pb"
OpenWindow(0, x, y, 400, 200, GetFilePart(file), #PB_Window_NoActivate | #PB_Window_SizeGadget | #PB_Window_SystemMenu)
SetWindowColor(0, #Black)
TextGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20, ParseInInformations(file))
SetGadgetColor(0, #PB_Gadget_BackColor, #Black)
SetGadgetColor(0, #PB_Gadget_FrontColor, G_Color)
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), 0)
Repeat
Select WaitWindowEvent(200)
Case #PB_Event_CloseWindow
Break
Default
MouseX = DesktopMouseX()
MouseY = DesktopMouseY()
If GetWindowRect_(WindowID(0), @WindowRect)
If MouseX >= WindowRect\left And MouseX <= WindowRect\right And MouseY >= WindowRect\top And MouseY <= WindowRect\bottom
SetWindowTitle(0, file + " [wait]")
flags = #True
Else
flags = #Null
If timeout < date()
Break
EndIf
EndIf
EndIf
If not flags
SetWindowTitle(0, GetFilePart(file) + " [" + Str(date() - timeout) + "]")
Endif
EndSelect
ForEver