Search found 7 matches

by Birage
12 Mar 2019 20:53
Forum: DOS Batch Forum
Topic: Setting a variable value to single whitespace
Replies: 6
Views: 6496

Re: Setting a variable value to single whitespace

Ah thanks for clearing my confusion :) I think my initial test case of echo !var1! VS what is in my script echo Values: !var1! !var2! further confused me.. There is no way to print the blank space in the case of echo !var1! , as a single blank space is not a valid value as stated by aGerman ?
by Birage
12 Mar 2019 08:29
Forum: DOS Batch Forum
Topic: Setting a variable value to single whitespace
Replies: 6
Views: 6496

Re: Setting a variable value to single whitespace

Squashman wrote:
12 Mar 2019 08:01
You do not use variable expansion with the IF DEFINED command.
Oh, thanks for the heads up, didn't know that :)

Any idea on how to go about resetting the variable back to a clean slate ?

Cheers.
by Birage
12 Mar 2019 07:09
Forum: DOS Batch Forum
Topic: Setting a variable value to single whitespace
Replies: 6
Views: 6496

Re: Setting a variable value to single whitespace

Oh thanks a lot for the advice ! It works, but due to the logic in my script, it doesn't work. Perhaps I should have stated the logic at the start, my bad. I wish to set var1 value to empty or null at the end of the loop, otherwise if there are no values in the file for the next iteration, it will e...
by Birage
12 Mar 2019 04:59
Forum: DOS Batch Forum
Topic: Setting a variable value to single whitespace
Replies: 6
Views: 6496

Setting a variable value to single whitespace

I have a variable which I wish to set to empty or null, and then echo the value to a file, preferably a whitespace, as I do not want anything to be shown. I set the variable to null by set var1= . However, echo !var1! results in "Echo is OFF", which is due to var1 being undefined. Is there a way to ...
by Birage
18 Feb 2019 07:51
Forum: DOS Batch Forum
Topic: Unable to set correct parameters in for loop
Replies: 1
Views: 2803

Unable to set correct parameters in for loop

cmd has multiline output, and I am trying to extract something out of each line by using tokens. I assigned each line to a repeating var1,var2 and so on, in this line set var!count!=%%H . However, I am unable to code this for loop for /f "tokens=1" %%S in (!tempvar!) do ( to properly accept the corr...
by Birage
17 Feb 2019 20:34
Forum: DOS Batch Forum
Topic: First read from file always fails
Replies: 3
Views: 4520

Re: First read from file always fails

Thanks a lot for the tip guys ! setlocal enabledelayedexpansion did the trick.
by Birage
17 Feb 2019 08:39
Forum: DOS Batch Forum
Topic: First read from file always fails
Replies: 3
Views: 4520

First read from file always fails

As titled, the first read from the file always fails, as the displayed output will be "ECHO is off." Subsequent reads will be fine, as the IP address in IP.txt file will be displayed. @echo off for /F %%A in (C:\Users\user1\Desktop\IP.txt) do ( set F=%%A echo %F% ) Sample output when script is run 3...