Search found 1041 matches
- 21 Jun 2023 05:54
- Forum: DOS Batch Forum
- Topic: User defined prompt with dynamic data
- Replies: 8
- Views: 3330
User defined prompt with dynamic data
Hi, I played a bit with the prompt to archive similar behavior like the bash prompt. export PS1="Time \$(date --iso=sec)" Each time I get a new prompt line, the date command will be executed. This exact example can be solved by simply use set "prompt=Time $T" But currently, it's not possible to exec...
- 21 Jun 2023 03:53
- Forum: DOS Batch Forum
- Topic: Reinterpreting macros in command-line context
- Replies: 9
- Views: 3281
Re: Reinterpreting macros in command-line context
That call set serves as a substitute for DisableDelayedExpansion, right? I'm not sure what purpose do ^" serve in the second for /f - is it to remove unneeded carets in tandem with that trailing exclamation mark? I believe I have a slight improvement over the first for /f: 1. That call set serves a...
- 13 Jun 2023 23:42
- Forum: DOS Batch Forum
- Topic: Reinterpreting macros in command-line context
- Replies: 9
- Views: 3281
Re: Reinterpreting macros in command-line context
1. sanitizing hazardous characters in a command-line context without toggling delayed expansion (I can either run cmd /v:on or cmd /v:off - there's no middle ground) ... Examining CMDCMDLINE in a code snippet curled into cmd.exe I would always opt for using a helper batch file, that would simplify ...
- 13 Jun 2023 04:53
- Forum: DOS Batch Forum
- Topic: Reinterpreting macros in command-line context
- Replies: 9
- Views: 3281
Re: Reinterpreting macros in command-line context
First, a minor problem. - I would use a different context detection if "%=^%=" == "%=%=" ( echo batch-context ) else echo cmd-context Because "%~f0"=="%~dpnx0" can be disturbed, by set "~f0"=="=& "^& XXXXXXXXXXXXX" if "%~f0"=="%~dpnx0" ( echo batch-context ) else echo cmd-context < no output at all ...
- 11 Jun 2023 05:09
- Forum: DOS Batch Forum
- Topic: Reinterpreting macros in command-line context
- Replies: 9
- Views: 3281
Re: Reinterpreting macros in command-line context
Hi mataha, it's a bit unclear what you want to achieve. Currently, I assume, you only want to compress already defined doskey macros. If this is the case, I would opt to define them without the indention, at the first definition, not redefine them later. I don't understand, if you try to define them...
- 21 May 2023 14:40
- Forum: DOS Batch Forum
- Topic: Is there any standard equivalent of a .bashrc script for cmd?
- Replies: 16
- Views: 14556
Re: Is there any standard equivalent of a .bashrc script for cmd?
Hi matha, I would opt for a hack. Because on my win10, the verb looks like (there is no %comspec% in the registry key, just cmd.exe) cmd.exe /s /k pushd "%V" @echo off setlocal EnableDelayedExpansion set "cmd=!cmdcmdline!" if "!cmd:~1,-2!" == "!comspec!" ( goto :autrun ) ELSE if "!cmd:~,22!" == ""cm...
- 21 May 2023 14:09
- Forum: DOS Batch Forum
- Topic: [SOLVED] Make Minutes & Seconds output 2 Digits
- Replies: 4
- Views: 1820
- 21 May 2023 08:47
- Forum: DOS Batch Forum
- Topic: [SOLVED] Make Minutes & Seconds output 2 Digits
- Replies: 4
- Views: 1820
Re: Make Minutes & Seconds output 2 Digits
You could prefix the values with "0" and take only the last two characters.
Code: Select all
set /a [Minutes]=%[T]% / 60
set "min=0%[minutes]%"
set "min=%min:~-2%"
echo %min_%
- 11 May 2023 05:53
- Forum: DOS Batch Forum
- Topic: create macro: Let's create a small handout with reports .
- Replies: 17
- Views: 4990
Re: create macro: Let's create a small handout with reports .
Hi einstein1969, Then I wanted to ask you why when there are quotation marks you need two ^ carets. Also why does it work with 3 ^ caret too?. see the example that t3rry did. You can use 2 or 3 carets, because only 2 are necessary, but one more doesn't harm in this case as the extra caret escapes th...
- 11 May 2023 05:52
- Forum: DOS Batch Forum
- Topic: create macro: Let's create a small handout with reports .
- Replies: 17
- Views: 4990
Re: create macro: Let's create a small handout with reports .
Hi einstein1969, Then I wanted to ask you why when there are quotation marks you need two ^ carets. Also why does it work with 3 ^ caret too?. see the example that t3rry did. You can use 2 or 3 carets, because only 2 are necessary, but one more doesn't harm in this case as the extra caret escapes th...
- 05 May 2023 00:15
- Forum: DOS Batch Forum
- Topic: create macro: Let's create a small handout with reports .
- Replies: 17
- Views: 4990
Re: create macro: Let's create a small handout with reports .
Currently there is no "ONE" simple guide with the "state of the art" techniques. You have to read many posts and none of them use the latest development state Macros with parameters appended https://www.dostips.com/forum/viewtopic.php?f=3&t=2518 But take post #4 for the better definition https://www...
- 02 May 2023 23:22
- Forum: DOS Batch Forum
- Topic: Notepad bug
- Replies: 10
- Views: 8658
Re: Notepad bug
Hi,
I created the file with
notepad out.txt
Shows a file beginning with a character similar to an underline and 768 crosses, tested on Windows10
I created the file with
Code: Select all
@echo off
setlocal enableDelayedExpansion
set "S= "
for /L %%n in (1,1,10) do set "S=!S!!S!"
> out.txt (
<nul set /p ".=T!S:~0,767!"
)
Shows a file beginning with a character similar to an underline and 768 crosses, tested on Windows10
- 27 Nov 2022 06:56
- Forum: DOS Batch Forum
- Topic: infinite loop with break condition
- Replies: 75
- Views: 96979
Re: infinite loop with break condition
Hi, I'm a little late to the party, but my two cents ... First, I agree with Aacini, some of the later posts are a bit off topic to the main problem. Then I rememberer, that I thought about the problem before with a different approach using nested loops. I see two drawbacks of the current sub-cmd-lo...
- 01 Sep 2022 23:39
- Forum: DOS Batch Forum
- Topic: ECHO. FAILS to give text or blank line - Instead use ECHO/
- Replies: 44
- Views: 210303
Re: ECHO. FAILS to give text or blank line - Instead use ECHO/
"call echo( /?" apparently suffers from the same issue I mentioned which suggests there might be a way to escape it somehow: It's a problem of the CALL, it's independent of the command, because the command is never be used, when the CALL detects the /? before. CALL echo /? CALL REM /? CALL :: /? CA...
- 30 Aug 2022 04:13
- Forum: DOS Batch Forum
- Topic: ECHO. FAILS to give text or blank line - Instead use ECHO/
- Replies: 44
- Views: 210303
Re: ECHO. FAILS to give text or blank line - Instead use ECHO/
Hi CJM, This subject seemed to tail off without resolution, yet using ECHO to reliably display information is such a necessity. In my opinion, there is a champion: echo( It's the most reliable in most of the cases. It fails only with: :case1 call echo( /? :case2 setlocal EnableDelayedExpansion set "...