Token for Active pane path?
Moderators: fgagnon, nikos, Site Mods
Token for Active pane path?
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.
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.
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):
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...
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
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...
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
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.
In this reality (where a unicorn floats around the Earth filling our tummies with sweets if we're good dancers ), the chasm betwixt "should be" and "will be" is inconceivably large.IneedHelp wrote:In this case a token should be added...
That said, a little humour also increases the chances, semantic bug or not.
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.
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.
- FrizzleFry
- Platinum Member
- Posts: 1241
- Joined: 2005 Oct 16, 19:09
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...
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...
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.
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.