Token for Active pane path?

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

User avatar
IneedHelp
Gold Member
Gold Member
Posts: 612
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Token for Active pane path?

Post by IneedHelp »

Seems there are two ways to get the active pane's path.

One way is using the $P token, but that only works if there's at least one file in the folder (because it needs a child to get the parent).

The other way is using the $L token, but that only works for the left pane if dual pane mode is active.

Is there a way to get the active pane's path even when it displays an empty folder?

I'm currently using $L which returns the active pane's path in single pane mode, but if there's no solution I'd like a token that gives the current pane's path regardless of pane mode.
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

This smells to me like a bug that will remain unfixed, as Nikos will never admit it may bother the senseless masses.  I presume you want to know the active pane's folder in order to pass it to an external programme?  The best I can think of is to just write a small handler script to which you pass $L $R $I and <Prog>, which would compare $I to $L and return $R, or $I to $R and return $L, and pass the return to <Prog>.  If your <Prog> is just a script anyway, just incorporate the logic into it.

As a rudimentary proof-of-concept (which will work in single or dual-pane mode):

Code: Select all

; Usage: > "NikoGoofo.exe" "$L" "R" "$I" <Prog>

If $CmdLine[0] < 3 Then
	MsgBox(0, "NikoGoofo", "Insufficient Parameters")
	Exit
EndIf

Switch $CmdLine[3]
	Case $CmdLine[1]
		$Pane = $CmdLine[2]
	Case $CmdLine[2]
		$Pane = $CmdLine[1]
	Case Else
		MsgBox(0, "NikoGoofo", "The Rain in Spain is now falling in Ireland, sadly")
		Exit
EndSwitch

If $CmdLine[0] > 3 Then
	Run("""" & $CmdLine[4] & """" & " " & $Pane)
Else
	MsgBox(0, "NikoGoofo", $Pane)
EndIf
:shrug:

That said, $P really should return it regardless if there's content or not... but until 2015 when the silent masses revolt, you might just get used to living in Workaround Hell...
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 612
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

Excellent idea comparing the inactive pane path with the left or right pane to find out which pane is active. Thank you!

Now, more about the $P token. It works only when  a file is selected. So it doesn't work even if a folder isn't empty (I assumed it would work if the folder isn't empty because I thought that the first item is selected by default... that dotted rectangle).

I wouldn't call it a bug if analyzing by the token's description in the manual which says Parent folder path. In x2, the token's description dosplays just Path- so from this point of view it may be called a bug.

Considering the manual's description, for the token to return the parent of a file (the active pane's path), a file must be selected- then it is understandable. In this case a token should be added to return the active pane's path, just like we have $I- Inactive pane path.

I'm trying to be Nikos-friendly here :D More chances to get an extra token if naming it missing feature than calling the existing one buggy :D
Last edited by IneedHelp on 2011 Aug 12, 19:29, edited 1 time in total.
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

IneedHelp wrote:In this case a token should be added...
In this reality (where a unicorn floats around the Earth filling our tummies with sweets if we're good dancers :wink:), the chasm betwixt "should be" and "will be" is inconceivably large.

That said, a little humour also increases the chances, semantic bug or not. :D
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 612
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

Since this world is so absurd that even the crazy people are ready to admit it, I suggest Nikos to introduce the Pay-per-feature service.
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

IneedHelp wrote:I suggest Nikos to introduce the Pay-per-feature service.
I take it you missed this Help option?

Image
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 612
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

Yeah, but it's not my fault. It misses the pile of golden coins icon... and you know us teenagers- we can't be bothered to read anything, everything has to be visual.
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

Ah, youth - it indeed is wasted upon the young.
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 612
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

Kilmatead wrote:Ah, youth - it indeed is wasted upon the young.
Au contraire, my dearest most wise elder of all, youth lives its moments of glory now more than it ever did or will.
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

The trouble with that assumption (which every generation believes, by the way), is that youth and glory are mutually exclusive entities: one is given freely, the other may only be earned.  That which comes without price is (by definition) blind to true value.  Pleasure is, as always, nothing but an irrelevant distraction in the human sphere... those who put it on a pedestal and confuse it with substantive freedom are destined to be crushed by its antonym.  But youth cannot learn that one until it's too late.  Which is why everyone else just smiles a wan smile of irony when the weeping starts, and the cold comfort of illusion dissolves.

Then the youth raise their weary eyes and gaze with recalcitrant abandon upon he who says simply, "Welcome to Life".  There is, without doubt, the piquant smugness of Glory being born then - and only then - into the world anew.

You'll see.  :wink:
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 612
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

A funny fact is that the only substantive freedom which has the same meaning to everyone is the freedom everybody* is running from.







*not available if your name is Achmed and you're wearing a belt of C4.
User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1241
Joined: 2005 Oct 16, 19:09

Post by FrizzleFry »

This is another of those x2 annoyances...

There should be an easy way to determine the active folder even if no file is focused... if not $P then a new token... oh, well, I have argued this before.

Kil's workaround will come in handy though.
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 612
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

Yes, creative imagination.

His idea translated to my MacroScheduler script resumes to:
//compare right pane with the inactive pane
IF>%right_dir%=%inactive_dir%
   //left pane is active
   Let>dir=%left_dir%
ELSE
   //right pane is active
   Let>dir=%right_dir%
ENDIF
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

Keep in mind that I did limited testing on this - in the same way as C language variables are not guaranteed to have a default of nought unless explicitly so defined (variables declared merely reserve memory, they don't initialise it), I'm unsure what value $I might be if x2 starts up without an explicit second pane showing - it could be something that was "last used" whenever the settings were last saved, it could be simply blank, indeed in single-pane mode there's no way of knowing if $I and $R would even be equal if both are uninitialised (our logic merely assumes they might be) - considering the odd things that occur when you toggle some things in x2 I have my doubts even Nikos would know off the top of his head without pondering through the code.

For example, what might happen if (on the odd chance) the value of the right pane was actually Null if opened in single-pane mode - if you pass three arguments to a conductive script, you in reality may only be passing a single argument (both $R and $I could conceivably be Null, while only $L is guaranteed to have a value, hence "$L" + "" + "" would register as 1 argument, not 3), which the script needs to be able to compensate for, considering it's actually "expecting" those 3 distinct parameters.

Rudimentary testing shows that it works, but it can't be guaranteed.

Anyway, just caveats in the wind...
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 612
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

Another useful feature for a different token would be reading the clipboard memory. Since most of the time it's mainly text and bitmap information, contents could be passed as various parameters to various applications.

If it's image information, the the clipboard token acts just like the $> token, creating a temp .bmp file and returning a string to its path, and if the clipboard is just text, then it returns all of it just like the rest of the tokens.
Post Reply