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  
Date: Aug 29,2017 at 20:19
In Response to: adding 1 more %, doubling it, still dont work, so i was wondering if it was bug (Ryan)

> > SET "P1=AAAABBBBBBBB DDDDDDDDDDDDDDDDDAAAAAAAAAAAAAAAAA"
> > 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 P1=AAAABBBBBBBB DDDDDDDDDDDDDDDDDAAAAAAAAAAAAAAAAA
> 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,


SET P1=AAAABBBBBBBB DDDDDDDDDDDDDDDDDAAAAAAAAAAAAAAAAA
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 "P1=AAAABBBBBBBB DDDDDDDDDDDDDDDDDAAAAAAAAAAAAAAAAA"
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
Nick

986 views      
Thread locked
 

Messages in this Thread

 
96,645 Postings in 12,231 Threads, 350 registered users, 74 users online (0 registered, 74 guests)
Index | Admin contact |   Forum Time: Apr 25, 2024 - 6:50 pm UTC  |  Hits:63,060,977  (31,971 Today )
RSS Feed