Page 1 of 1

Variable resolving issue

Posted: 09 Apr 2018 14:20
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.

Re: Interpolation Issue

Posted: 09 Apr 2018 14:29
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);

Re: Interpolation Issue

Posted: 09 Apr 2018 14:39
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:

Re: Interpolation Issue

Posted: 09 Apr 2018 14:53
by highend
I'm renaming this thread into "Variable resolving issue", ok?

Re: Interpolation Issue

Posted: 09 Apr 2018 15:04
by murdock01
Thats fine. I thought about just removing it; or putting into the stupid category.

Re: Interpolation Issue

Posted: 09 Apr 2018 15:20
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:

Re: Variable resolving issue

Posted: 09 Apr 2018 15:56
by murdock01
:D :beer: :beer: