I wrote a simple tool which have to be added to the PB IDE, after doing so, a resource file of assigned to the actual source code will be scanned and the drive letters will be changed to the correct value.
Code: Select all
Source.s=ProgramParameter()
Drive.s=UCase(Left(Source,3))
Resource.s
Backup.s
If Mid(Drive,2,2)=":\"
If ReadFile(#True,Source)
While Eof(#True)=#False
Line.s=ReadString(#True)
If PeekA(@Line)=';'
If Left(Line,15)="; AddResource ="
Resource=Trim(Mid(Line,16))
EndIf
EndIf
Wend
CloseFile(#True)
If Resource
If Left(Resource,1)="\" Or Mid(Resource,2,1)=":"
Debug resource
MessageRequester("Panik","Illegal resource file definition."+#CR$+"Please use relative path for your resource file definitions.")
Else
Resource=GetPathPart(Source)+Resource
Backup=GetExtensionPart(Resource)
Backup=Left(Resource,Len(Resource)-Len(GetExtensionPart(Resource)))+"bak"
DeleteFile(Backup)
If FileSize(Resource)>#True
If RenameFile(Resource,Backup)
If CreateFile(#True,Resource) And ReadFile(#False,Backup)
While Eof(#False)=#False
Line.s=ReadString(#False)
n=FindString(Line," ICON ")
If n
n+5
If PeekA(@Line+n)='"'
n+1
EndIf
If PeekA(@Line+n+1)=':'
PokeA(@Line+n,PeekA(@Drive))
EndIf
EndIf
Debug Line
WriteStringN(#True,Line)
Wend
CloseFile(#False)
CloseFile(#True)
MessageRequester("Ok","Modified resource file.",#MB_ICONINFORMATION|#MB_OK)
Else
MessageRequester("Panik","Could not write a new resource file"+#CR$+"'"+Resource+"'.")
EndIf
Else
MessageRequester("Panik","Could not create a backup for the resource file"+#CR$+"'"+Resource+"'.")
EndIf
Else
MessageRequester("Panik","Could not locate the resource file"+#CR$+"'"+Resource+"'.")
EndIf
EndIf
Else
MessageRequester("Panik","No resource file defined."+#CR$+"Compiler options / Resources")
EndIf
EndIf
Else
MessageRequester("Panik","Wrong tool configuration."+#CR$+"Please use ''%FILE'' as start parameter.",#MB_ICONERROR|#MB_OK)
EndIf