Posted: Tue Jan 24, 2006 3:47 pm
Then if a procedure returns a string, you can't make it a constant?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
; ResidentCreator created by KCC thanks to the great tips of PB
; http://www.purebasic.fr/english/viewtopic.php?p=120641#120641
Procedure CreationFichierResident(FilePath.s)
NameFile.s = ReplaceString(GetFilePart(FilePath), ".pb", "")
If FileSize(#PB_Compiler_Home + "Residents\" + NameFile + ".res") <> - 1
AnswerOverWrite = MessageRequester("ResidentCreator", "The file ''" + NameFile + ".res'' already exist, do you want to overwrite it ?", #PB_MessageRequester_YesNo )
If AnswerOverWrite <> 6
ProcedureReturn 0
EndIf
DeleteFile(#PB_Compiler_Home + "Residents\" + NameFile + ".res")
EndIf
If RunProgram(#PB_Compiler_Home + "Compilers\pbcompiler.exe", FilePath + " /resident " + NameFile + ".res /IGNORERESIDENT", #PB_Compiler_Home + "Compilers\", #PB_Program_Wait|#PB_Program_Hide)
While FileSize(#PB_Compiler_Home + "Compilers\" + NameFile + ".res") = - 1
Delay(10)
Wend
CopyFile(#PB_Compiler_Home + "Compilers\" + NameFile + ".res", #PB_Compiler_Home + "Residents\" + NameFile + ".res")
DeleteFile(#PB_Compiler_Home + "Compilers\" + NameFile + ".res")
MessageRequester("ResidentCreator", "The new file résident ''" + NameFile + ".res'', is created in the folder of résidents of PureBasic" + Chr(13) + "For use it, restart the PureBasic IDE.")
EndIf
EndProcedure
FileChoose$ = OpenFileRequester("Please, choose the Pbfile countain your constants", "c:\", "Resident PB|*.pb", 0)
If Trim(FileChoose$) <> ""
CreationFichierResident(FileChoose$)
EndIf
Code: Select all
Procedure ControleListeResident(SourceResident.s)
ReadFile(1, SourceResident)
If FileSize("c:\TestResidents.pb") <> - 1
DeleteFile("c:\TestResidents.pb")
EndIf
CreateFile(2 , "c:\TestResidents.pb")
Repeat
Donnee$ = ReadString(1)
If Left(Trim(Donnee$), 1) = "#"
NomConstante$ = StringField(Donnee$, 1, "=")
If FindString(Donnee$, Chr(34), 1)
WriteStringN(2, "Debug " + Chr(34) + NomConstante$ + " = " + Chr(34) + " + " + NomConstante$)
Else
WriteStringN(2, "Debug " + Chr(34) + NomConstante$ + " = " + Chr(34) + " + Str(" + NomConstante$ + ")")
EndIf
EndIf
Until Eof(1) <> 0
CloseFile(1)
CloseFile(2)
MessageRequester("ResidentControlor", "The file ''c:\TestResidents'' is created, load and run it in the IDE, for control all the CONSTANTS and his value.")
EndProcedure
FichierChoisi$ = OpenFileRequester("Please, choose the Pbfile countain your constants", "c:\", "Resident PB|*.pb", 0)
If Trim(FichierChoisi$) <> ""
ControleListeResident(FichierChoisi$)
EndIf