Variable resolving issue

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
murdock01
Posts: 55
Joined: 08 Nov 2010 19:35

Variable resolving issue

Post by murdock01 »

Hey,
What I am trying to do is create a little function to save myself some time. I am re-organizing my portable file structure. In my XY environment I "virtualize" everything I can; so I make use of XY variables (like <xydrive>) and substitution, i.e ?:\path\path...

My function should work like this: I copy a path to an executable to the clipboard using the function. The function takes whats in the clipboard and prunes off the drive letter and :. Then is adds a variable to the front of the string and puts the new path back to the clipboard so I can paste it where it needs to be.
So I copy "g:\portable path\some other path\someexe.exe" to the clipboard and then get "<xydrive>\portable path\some other path\someexe.exe" on the clipbpoard.
So what I am having a problem with is trying to add the variable to a copied path without it be interpolated. I have tried the single quotes, per the help file, to stop interpolation but it does not work.

Here is the current form of the function; its not as clean as I would like but I have been trying several things to get this to work.

Code: Select all

"XY Pre-Paste";
  copytext <curitem>;
  $x=(substr(<clipboard>, 2));
  $y='<' . 'xydrive' . '>' . $x;
  copytext $y;
In fact the weird thing about the above is if I copy "g:\portable path\some other path\someexe.exe" I will get "<xydrive>\someexe.exe" on the clipboard. I dont know where the rest of the path went.

I have tried things like $y='<xydrive>'$x and other. I am hoping that I am not missing something obvious.

I have not tried a similar function to get something like "?:\portable path\some other path\someexe.exe" as a result. So hopefully the solution to the question works for both <xydrive> and ?

Any help would be greatly appreciated.

jupe
Posts: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Interpolation Issue

Post by jupe »

Without changing your code, this should work:

Code: Select all

"XY Pre-Paste";
  copytext <curitem>;
  $x=(substr(<clipboard>, 2));
  $y='<xydrive>' . $x;
  copytext $y;
Changing your code this should work too:

Code: Select all

"XY Pre-Paste"
    copytext '<xydrive>' . substr(<curitem>, 2);

murdock01
Posts: 55
Joined: 08 Nov 2010 19:35

Re: Interpolation Issue

Post by murdock01 »

Hi Jupe,
Thanks for the quick response.
I think I tried that but I went and tried it again.
It works now. I think I know what the problem was. I think it was where the focus was :oops: I thought I was coping one file and was actually copying something else :oops:

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Interpolation Issue

Post by highend »

I'm renaming this thread into "Variable resolving issue", ok?
One of my scripts helped you out? Please donate via Paypal

murdock01
Posts: 55
Joined: 08 Nov 2010 19:35

Re: Interpolation Issue

Post by murdock01 »

Thats fine. I thought about just removing it; or putting into the stupid category.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Interpolation Issue

Post by highend »

or putting into the stupid category.
There is no such category (yet!) :mrgreen:

I'll ask Don if he's willing to add a category named "murdock01" but I very much doubt that it'll happen :beer:
One of my scripts helped you out? Please donate via Paypal

murdock01
Posts: 55
Joined: 08 Nov 2010 19:35

Re: Variable resolving issue

Post by murdock01 »

:D :beer: :beer:

Post Reply