ZTree.com  | ZEN  | About...  

 Index   Back

adding 1 more %, doubling it, still dont work, so i was wondering if it was bug   [Q]

By: Nick Williams     West Sussex, England (forum time +5 hrs)  
Date: Aug 29,2017 at 16:19
In Response to: adding 1 more %, doubling it, still dont work, so i was wondering if it was bug (Ryan)

> > SET "N=20"
> > CALL ECHO:%%P1:~0,%N%%%
This example I gave you, definitely works. Have you actually tried it ?

> BB=works in command line (i meant as in batch)
> SET N=20
> ECHO %%P1:~0,%N%%%
> it worked in a batch, so it must work in F9(=ztreemenu script)... but
This could not possibly have worked, for 2 reasons:-
(1) As I've already said,

needs double quotes (as in my example).
(2) You're missing the CALL before the ECHO (again, see my example)

> >must double-up all those percent
> but i have this problem, not a problem but more of the definitions that
> are going around
> 1. sometimes % works in F9 without adding more %
> 2. sometimes % works in F9 with adding 1 more %
> 3. sometimes % works in F9 with doubling it
> i always try 1. 2. 3.
Nope, only 3. is correct.

To make my example work in [F9] Menu, you would need to copy and paste it, then double-up the percent signs, as follows:-

SET "N=20"
CALL ECHO:%%%%P1:~0,%N%%%%%%
Don't forget to use CALL ECHO

> SetLocal EnableExtensions EnableDelayedExpansion
> SET AA=50
> ECHO !P1:~0,%%AA%%!
> it worked in F9, but DelayedExpansion interferes with the data with
> "!" so badly, this is my last resort to use.
Yes, avoid EnableDelayedExpansion for the reason you've given -- there's no need for it in this particular case.

> > using it SET "A=123" instead of SET A=123
I admit that double quoting SET A=123 is unnecessary -- I do it out of habit.
But try running this line without double quotes:-

SET directory=C:\Documents & Settings
It definitely needs to be:-

SET "directory=C:\Documents & Settings"

Hope this helps. Just so you know, I would never send you (or anybody) any code examples if I hadn't tested them first.

Kind regards

Thread locked

Messages in this Thread

95,067 Postings in 11,984 Threads, 350 registered users, 62 users online (0 registered, 62 guests)
Index | Admin contact |   Forum Time: Aug 7, 2020 - 10:51 am EDT  |  Hits:32,930,561  (13,602 Today )
RSS Feed