ZTree.com  | ZEN  | About...  

 Index   Back

An even simpler solution without using SETLOCAL or GOTO   [Q]

By: Ryan       
Date: Sep 22,2017 at 06:50
In Response to: An even simpler solution without using SETLOCAL or GOTO (Nick Williams)

AA=
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

SET TEST3=TEST3^!
SET "TEST5=TEST5^!"

ECHO !TEST3!
ECHO !TEST5!
PAUSE


BB=
SET A1=
SET A1=GG
IF DEFINED A1 GOTO END
ECHO %A2% |FIND " " /C GOTO END


right now, my brian ceases to function when i see many "" around the variables like "SID2=". i have been writing basic's and reading fortran's so long, i actually couldnt modify a slightly long batch script with "" around all variables, especially "" is automated for long names.

but i keep it in mind that "SID2=" is a better choice. i try to use it in a small scale or local area. i need more time

i use BB= in an important batch where there are no mistakes allowed. to me, i can read and recognize BB= better than "" around the variables.

in AA=, however, putting "" makes the difference, then ^ this caret symbol, i dont know much about it. i havent got to use ^'s except for ^|


CC=
FOR /F "SKIP=1 DELIMS=" %%V IN ('"%SID1%"') DO (
SET "SID2=%%V"
GOTO :BREAK
)
:BREAK

i will replace my nested loop to find the 2nd line with CC=
i will choose CC= over the definded one for this, i can read CC= a little better and it definitely reads it till 2nd line. while defined one also checks the 3rd line which could make OS update dependant or future OS dependant. now i understood a basic meaning of skip=, thanks

----------------
i am so used to with % and %%% than %% and %%%%%, they help me put them all in 80 columns. if ztree fixes this, my F9 bacthes will be in trouble.

but i will never use % and %%% where i need to combine them like %P1%%P2%, i must double them

292 views      
Thread locked
 

Messages in this Thread

 
94,426 Postings in 11,918 Threads, 348 registered users, 10 users online (0 registered, 10 guests)
Index | Admin contact |   Forum Time: Sep 18, 2019 - 11:45 am EDT  |  Hits:28,648,619  (1,366 Today )
RSS Feed