Search found 1062 matches

by jeb
13 Aug 2025 06:05
Forum: DOS Batch Forum
Topic: Echo ( and ) within a block
Replies: 1
Views: 28

Re: Echo ( and ) within a block

Hi miskox,

simply use delayed expansion, that solves also problems with all other special characters.

Code: Select all

@echo off
setlocal enableDelayedExpansion
set str=somestringABCDEF
(echo/)&&(echo !str!)

set str=somestring(ABCDEF)
(echo/)&&(echo !str!)
by jeb
11 Aug 2025 13:54
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 77
Views: 145624

Re: strLen boosted

However what puzzles me is why it even makes any difference if it comes before the caret (or after it, as this seems to work too). It forces the delayed expansion phase to trigger. The delayed expansion phase only have an effect, when at least one exclamation mark is in the line (and it must still ...
by jeb
11 Aug 2025 05:49
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 77
Views: 145624

Re: strLen boosted

I have made the creation of the exclamation mark and caret a little shorter, which happens before the macro is created. Code: Select all FOR /F "tokens=1-3" %%! IN ("! ! ^ ^^^! . ^^^^") DO ^ It looks a little strange, but since the first caret disappears in delayed expansion, it can already be used...
by jeb
06 Jul 2025 14:32
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 77
Views: 145624

Re: strLen boosted

Hi, nice to see progress here. However, I don't like your style of writing code. It's really unreadable, and the variable names are, at best, ugly. :D So I built it differently, independently of delayed expansion mode, but with a completely different solution. I only copy the text string once at the...
by jeb
24 Feb 2025 23:53
Forum: DOS Batch Forum
Topic: Put Desktop to sleep from Laptop
Replies: 5
Views: 7730

Re: Put Desktop to sleep from Laptop

If you are using at least windows 10 you could use ssh. Laptop> ssh desktopuser@[DesktopName or DesktopIP] "Desk_Sleep.bat" But you have to enable the ssh server on the desktop Get started with OpenSSH for Windows . Then you need to create an ssh keypair on your laptop Generate new ssh keys in Windo...
by jeb
14 Feb 2025 06:22
Forum: DOS Batch Forum
Topic: ok if i ask a DOSbox-X batch, need to read 2nd string
Replies: 2
Views: 5639

Re: ok if i ask a DOSbox-X batch, need to read 2nd string

Hi nnnmmm, i need a batch that returns a var ABC 2nd line is an empty line are there batch commands to get the 2nd string ABC? I suppose not, but you could solve it with a trick. Build one config file which contains only the "ABC". Then you can build the spec file before you start the compiler by ec...
by jeb
26 Dec 2024 04:57
Forum: DOS Batch Forum
Topic: is there a way to display the list without the quotation marks when ampersands present?
Replies: 3
Views: 10619

Re: is there a way to display the list without the quotation marks when ampersands present?

And I learned a new variant for the trick last month, now it's enough to use %%" instead of %%~". FOR /F "tokens=* delims=X" %%^" in ("X") do ( echo %%" Special characters &..|..^..<..> echo %%" Event a closing bracket ) doesn't harm ) It's possible to create a single FOR meta-variable that's empty....
by jeb
21 Oct 2024 02:34
Forum: DOS Batch Forum
Topic: Progress bar
Replies: 6
Views: 43134

Re: Progress bar

And now my own try of a progress bar. But with the use of 8 different steps per single character. It shows the progress bar in the window and in the title I'm using the unicode characters from U+2588 to U+258F. ▏ ▎ ▍ ▌ ▋ ▊ ▉ █ How it looks depends on the selected font. My best results are with a uni...
by jeb
17 Oct 2024 02:05
Forum: DOS Batch Forum
Topic: How to break from a .cmd?
Replies: 2
Views: 21899

Re: How to break from a .cmd?

You can use a small function to exit only the current batch :exit-current-batch for /L %%# in (0 1 40) DO ( (goto) 2> NUL call set "_tmp=%%0" call set "_tmp=%%_tmp:~0,1%%" call set "_tmp=%%_tmp::=%%" if defined _tmp ( REM Current Batch entry found exit /b ) ) exit /b Just use CALL :exit-current-batc...
by jeb
16 Oct 2024 10:06
Forum: DOS Batch Forum
Topic: help with multilinea macro in not delayed
Replies: 4
Views: 43791

Re: help with multilinea macro in not delayed

Is it possible to bypass the endlocal barrier/tunnel inside a call of variables that have LF or in any case the code to create multiline macros? Yes. You can even make it so that it's possible to return the macro to whatever mode it was in before. The :lineReturnTest test enables delayed expansion ...
by jeb
22 Sep 2024 09:36
Forum: DOS Batch Forum
Topic: help with multilinea macro in not delayed
Replies: 4
Views: 43791

Re: help with multilinea macro in not delayed

Hi einstein1969, I don't see the relation between delayed expansion and line feeds here. Using of line feeds in macros just depends on code blocks. It is essential to use the parenthesis in the macro. rem define a line feed for using in macro definitions (Set $\n=^^^ %= this line is required =% ) se...
by jeb
13 Sep 2024 00:40
Forum: DOS Batch Forum
Topic: Observations about the tilde-dollar syntax %~$variable:I
Replies: 3
Views: 58434

Re: Observations about the tilde-dollar syntax %~$variable:I

After reading Batch: How to Properly Use CHOICE Inside of CALL Function? The problem was probably a previously set of the errorlevel variable. I was curious whether it is possible to recognize this programmatically. "if defined variableName" doesn't work here, because it's true for pseudovariables, ...
by jeb
12 Sep 2024 11:10
Forum: DOS Batch Forum
Topic: scrolling region test
Replies: 8
Views: 59872

Re: scrolling region test

Hi,

a bit nitpicking :D

new functions: :chr, :asc, :asciiMap (Fri Apr 01, 2011 10:34 pm)

I probably developed the ESC, DEL and CR (buffer overflow) technique, but the rest was just a copy and paste.

jeb
by jeb
07 Sep 2024 02:47
Forum: DOS Batch Forum
Topic: Observations about the tilde-dollar syntax %~$variable:I
Replies: 3
Views: 58434

Re: Observations about the tilde-dollar syntax %~$variable:I

1) Undefined variables and an empty variable names behave differently (#5 and #6). Perhaps an empty variable name accesses some random existing variable :?: After some more testing, I found the behavior for an empty searchPath-variable name. If you use the expression "%%~$:X" or ""%%~$====:X" the n...
by jeb
06 Sep 2024 14:28
Forum: DOS Batch Forum
Topic: Observations about the tilde-dollar syntax %~$variable:I
Replies: 3
Views: 58434

Observations about the tilde-dollar syntax %~$variable:I

I would like to share some insights about the rarely used syntax of "%~$PATH:I" %~$PATH:I Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first directory found. If the environment variable name isn't defined or the file isn't found b...