Use "%FILE" "%TEMPFILE" in the parameters

Working on new editor enhancements?
AZJIO
Addict
Addict
Posts: 2165
Joined: Sun May 14, 2017 1:48 am

Use "%FILE" "%TEMPFILE" in the parameters

Post by AZJIO »

I didn't understand how to get the file path before. For saved ones it is "%FILE", for unsaved ones it is "%TEMPFILE". If I use "%FILE", the tool does not work with unsaved file. I've now figured out that you have to use both parameters at the same time: "%FILE" "%TEMPFILE".

This code polls all parameters until it finds an existing path.

Code: Select all

Count = CountProgramParameters()
For i = 1 To Count
	tmp$ = ProgramParameter()
	If Asc(tmp$) And FileSize(tmp$) > 3 And Left(GetExtensionPart(tmp$), 2) = "pb"
		Break
	EndIf
Next
I've added this code to all my tools: "alignment_of_comments", CodeLocalization, CommentLocalization, FindAllReferences (Linux), Include_Helper, no_comment, pb2html, Tidy. Who has encountered the problem, then update these plugins.
Little John
Addict
Addict
Posts: 4781
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Use "%FILE" "%TEMPFILE" in the parameters

Post by Little John »

AZJIO wrote: Wed Mar 12, 2025 3:31 pm For saved ones it is "%FILE", for unsaved ones it is "%TEMPFILE".
This is not quite correct. %TEMPFILE can be used for both saved and unsaved files.
AZJIO
Addict
Addict
Posts: 2165
Joined: Sun May 14, 2017 1:48 am

Re: Use "%FILE" "%TEMPFILE" in the parameters

Post by AZJIO »

Little John wrote: Wed Mar 12, 2025 4:48 pm This is not quite correct. %TEMPFILE can be used for both saved and unsaved files.
This behavior may have changed recently, but I've previously seen tools that use 2 parameters. Take a look at SearchForUnusedIdentifiers.pb

Code: Select all

; Tool Settings:
; - Arguments: "%FILE" "%TEMPFILE"
pbOptimizer
Post Reply