Search found 195 matches

by Sponge Belly
22 Nov 2015 11:01
Forum: DOS Batch Forum
Topic: call set bug?
Replies: 8
Views: 2165

Re: call set bug?

Hi Jeb, :)

Thanks for the explanation, but I think I’ll stick with Dave Benham’s icall macro if I ever find myself in a situation where I’m forced to make extensive use of call set.

Cheers!

- SB
by Sponge Belly
22 Nov 2015 10:47
Forum: DOS Batch Forum
Topic: two findstr questions
Replies: 27
Views: 8907

Re: two findstr questions

Hi Aacini! :)

I explored a findstr /no solution, but decided it was too messy. There’s no way to tell Unix and Windows line-endings apart, line numbers must be decremented, and what if the last line in the file happens to be the longest? :?

Cheers!

- SB
by Sponge Belly
21 Nov 2015 08:55
Forum: DOS Batch Forum
Topic: two findstr questions
Replies: 27
Views: 8907

find longest line in text file

Hello Again! I returned to this problem after a long break with a fresh perspective. Sure enough, the only practical solution, imho, is a hybrid script: @if (@X==@Y) @then @echo off & setlocal enableextensions disabledelayedexpansion for /f "tokens=1,2" %%A in (' cscript //nologo //e:j...
by Sponge Belly
21 Nov 2015 04:53
Forum: DOS Batch Forum
Topic: call set bug?
Replies: 8
Views: 2165

Re: call set bug?

Hi Jeb, Ah, now I get it! The weird syntax is to guard against the unlikely event that a user has a file called "set.bat" or "set<Space>.bat" on his/her PATH. However did you think to check for that? And one last thing, you said: I reinvent the wheel this year, but this time my n...
by Sponge Belly
18 Nov 2015 14:59
Forum: DOS Batch Forum
Topic: call set bug?
Replies: 8
Views: 2165

Re: call set bug?

Hi Penpen and Jeb! Thanks for the explanations. Just one more pitfall to look out for when writing a Batch file! On a related topic, Jeb wrote in this post : set "safeSet=set^ "" call %%safeSet%% var=123" I was wondering why you didn’t just write: set "safeSet=set" call...
by Sponge Belly
17 Nov 2015 14:26
Forum: DOS Batch Forum
Topic: Iterating For The Last 60 Days
Replies: 8
Views: 1878

Re: Iterating For The Last 60 Days

Hi Samir! :)

Perhaps this post from Nov 2013 may be of interest. ;)

- SB
by Sponge Belly
14 Nov 2015 15:10
Forum: DOS Batch Forum
Topic: call set bug?
Replies: 8
Views: 2165

call set bug?

Hello All! Sorry I haven’t posted in a while. My mind has been… elsewhere. Anyways, could someone please explain what’s going on here? @echo off & setlocal enableextensions disabledelayedexpansion set ^"str= hello ^&^"^& world! ^" (call;) call set "str1=%%str%%" ...
by Sponge Belly
10 Aug 2015 13:22
Forum: DOS Batch Forum
Topic: Using Variable As For-Loop Token Value
Replies: 7
Views: 3556

Re: Using Variable As For-Loop Token Value

Hello All! Sorry I’m late to the discussion, as usual. But my solution takes advantage of the popping the CALL stack technique Siberia-Man told us about on June 7th: @echo off & setlocal enableextensions disabledelayedexpansion set ^"str=^" ^&^^ ^"^^^&^"^& !^^!^^^...
by Sponge Belly
29 Jun 2015 15:35
Forum: DOS Batch Forum
Topic: re-use %* without corrupting it?
Replies: 5
Views: 1972

Re: re-use %* without corrupting it?

Hi Guys! Sorry for the delay in replying. Here’s what I (eventually) came up with: @echo off & setlocal enableextensions disabledelayedexpansion (call;) set "crlf=%tmp%\crlf.tmp" >"%crlf%" echo( for %%A in ("%crlf%") do set "crlfSize=%%~zA" if %crlfSize% n...
by Sponge Belly
23 Jun 2015 11:43
Forum: DOS Batch Forum
Topic: Exception Handling with batch using erroneous GOTO
Replies: 16
Views: 10141

Re: Exception Handling with batch using erroneous GOTO

Hello All! :)

Fascinating topic. But could someone show me how to use this new technique to stop a for /l loop in its tracks?

TIA!

- SB
by Sponge Belly
22 May 2015 10:10
Forum: DOS Batch Forum
Topic: split string into substrings based on delimiter
Replies: 37
Views: 22858

Re: split string into substrings based on delimiter

Hi Ed, Thanks for the explanation. Still can’t quite wrap my head around Aacini’s code, though. Will keep trying. In the meantime, I’ve rekindled my obsession with finding the best way to trim leading and trailing whitespace from a string: @echo off & setlocal enableextensions disabledelayedexpa...
by Sponge Belly
15 May 2015 16:21
Forum: DOS Batch Forum
Topic: re-use %* without corrupting it?
Replies: 5
Views: 1972

Re: re-use %* without corrupting it?

Hi Jeb, I was afraid you’d say something like that. But it’s even worse than I originally thought. If the program is executed from the command line using cmd like so: cmd /c prog.cmd "quoted ^ carets" unquoted ^^^^ carets The carets must be escaped a second time for the command line cmd. S...
by Sponge Belly
12 May 2015 14:13
Forum: DOS Batch Forum
Topic: re-use %* without corrupting it?
Replies: 5
Views: 1972

re-use %* without corrupting it?

Hello All! I want to make sure a script I’m writing runs in ANSI mode. The usual procedure is to check for a command line switch and call the script again if not present. The relevant line is: cmd /d /a /c call "%~dpnx0" /ansi %* Trouble is, when I run it with echo on, I notice that unquot...
by Sponge Belly
12 May 2015 13:52
Forum: DOS Batch Forum
Topic: split string into substrings based on delimiter
Replies: 37
Views: 22858

Re: split string into substrings based on delimiter

Hi Antonio, Your last example was amazing. Too bad I can’t understand it! Anyways, I was wondering if it’s possible to change the value of the original string from inside the loop caused by the string split operation… because if it is, we could append to the string what was just taken off, the strin...
by Sponge Belly
02 May 2015 13:25
Forum: DOS Batch Forum
Topic: split string into substrings based on delimiter
Replies: 37
Views: 22858

Re: split string into substrings based on delimiter

Hi Aacini,

Clever use of delayed expansion and set /a! 8)

Your method of storing all the intermediary results was so obvious when I read the example… so why didn’t I think of it myself? :cry:

Anyways, I changed the subject line as you suggested.

Laters!

- SB