ZTree.com  | ZEN  | About...  

 Index   Back

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

By: Ryan       
Date: Aug 28,2017 at 23:59
In Response to: [Q] N=20, ECHO %%%P1:~0,%%N%%%%, how can i make it work? [Bug?] (Nick Williams)

> SET P1=AAAABBBBBBBB DDDDDDDD DDDDDDDDDAAAAAAAAAAAAAAAAA
> Is the gap in "P1" intentional?
yes, it simulates as spaces

> SET "P1=AAAABBBBBBBB DDDDDDDDDDDDDDDDDAAAAAAAAAAAAAAAAA"
> SET "N=20"
> CALL ECHO:%%P1:~0,%N%%%
it was the same thing.

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

>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.

in batch %%P1:~0,%N%%% (2 1 3)
4. in F9, zero % adding it = %%P1:~0,%N%%% (2 1 3)
5. in F9, 1 more % adding it = %%%P1:~0,%%N%%%% (3 2 4)
6. in F9, doubling it = %%%%P1:~0,%%N%%%%%% (4 2 6)

4. 5. 6. didnt work in F9, this was so odd, it worked in a batch but not in F9.
so i had to ask if this was maybe a bug?

in batch "For %%X IN ()"
7. in F9, For %%X () doesnt work with 0 adding
8. in F9, For %%%X () works with 1 more adding
9. in F9, For %%%%X () works with doubling

F9 just shows %P1:~0,50% as a final echo-answer, but it doesnt run it.
so i am not sure which beat i need to dance with, so i am starting to add %s blindly after this point, sometimes it seemed to work for some joined variables A%%%B%%C

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.

>advice I can give you is to use batch (.BAT or .CMD) files for your code, not ZTreeMenu.
i have no skill to bring in the external variables called from a different batch
sss.bat=
call batchname.bat %1

> using it SET "A=123" instead of SET A=123
i dont know what to say about this one.
if i have to change one now, i may have to change all of my scripts, then it would take 6 months, besides i have not encountered the interferences yet associated with Set A=123, but if they show the interference by squeezing everything into 1 line batch, then i may intentionally avoid it for a personal use only. Set A=123 works nicely in my brian, it comes so naturally with LET A=123 in basic compiler. i need to find the interference natually, so i always strip off "" from set "a=123" from others coding for my search.

278 views      
Thread locked
 

Messages in this Thread

 
94,590 Postings in 11,932 Threads, 348 registered users, 16 users online (0 registered, 16 guests)
Index | Admin contact |   Forum Time: Nov 20, 2019 - 7:52 am EST  |  Hits:29,194,381  (7,622 Today )
RSS Feed