Search found 243 matches

by T3RRY
10 Jan 2023 21:16
Forum: DOS Batch Forum
Topic: Shapes and rotation
Replies: 1
Views: 18584

Re: Shapes and rotation

Found this gem while doing some research on Bresenham's Line algorithm for a Batch tower defense game I'm working on. Love your work with the Line and Plot macro's, but the game I'm making demanded a bit more in the way of efficiency, So I needed to refactor the macro. There was a number of superflu...
by T3RRY
09 Jan 2023 10:51
Forum: DOS Batch Forum
Topic: Need help with an structure and compare inputs
Replies: 3
Views: 7611

Re: Need help with an structure and compare inputs

To perform substring modification using variables as the search replace strings, you need to have delayed expansion enabled and use expansion like so: set "board=!board:%choice%=%turn%!" Ther is however are much more preferable way to take input for single character choices, which is the Choice comm...
by T3RRY
09 Jan 2023 05:53
Forum: DOS Batch Forum
Topic: Escaping special characters in a variable in for loop
Replies: 3
Views: 7529

Re: Escaping special characters in a variable in for loop

Special handling of the environment state is required to preserve Exclamation characters. Variable assignment must occur before DE is enabled, DE then gets toggled on and of during the loop, with an additional for loop required to tunnel the concatenation variable across the endlocal. After the loop...
by T3RRY
06 Dec 2022 02:17
Forum: DOS Batch Forum
Topic: Maze game questions
Replies: 3
Views: 7718

Re: Maze game questions

- A simple collision system (that can detect if one character just took the spot of another character and can run a command after that happens) For this, the objects you are testing for collision need to have defined information for their Y and X coordinates and Width and height if greater than one...
by T3RRY
26 Nov 2022 02:11
Forum: DOS Batch Forum
Topic: reverse string without goto
Replies: 10
Views: 13905

Re: reverse string without goto

Hi Again! :) Belated thanks to Aacini and T3RRY for their excellent contributions. Below is my final word on the topic—a Batch/JScript hybrid: @if (@X==@Y) @then :: Batch @echo off & setLocal enableExtensions disableDelayedExpansion set ^"strFwd=short ^" ^< %% ^| ^^ ! string^" set "strRev=" & for /...
by T3RRY
04 Nov 2022 23:30
Forum: DOS Batch Forum
Topic: parsing strings
Replies: 1
Views: 1606

Re: parsing strings

When working with variables in loops or code blocks, Variables are parsed with the value the had prior to the commencement of the codeblock To access their current value, Delayed expansion is required to be enabled and variables expanded using the ! reference character, IE: !variable! @Echo off & CD...
by T3RRY
04 Aug 2022 07:44
Forum: DOS Batch Forum
Topic: How to replace all characters in a variable with another character?
Replies: 4
Views: 3290

Re: How to replace all characters in a variable with another character?

Another way: @Echo off Set "Var=Some !@#$%%^& string" Set Var Call:Mask Var Set Var Goto:Eof :Mask Setlocal DISABLEdelayedexpansion If "%~1" == "" Exit /b 1 Set "String=" For /f "UsebackQ tokens=2 Delims=:" %%G in (`cmd /V:On /u /c ^"^<nul set/p "=!%~1!"^"^| find /v "" ^| findstr /n "^"`)Do Call Set...
by T3RRY
03 Aug 2022 13:44
Forum: DOS Batch Forum
Topic: How to replace all characters in a variable with another character?
Replies: 4
Views: 3290

Re: How to replace all characters in a variable with another character?

I'm assuming you mean to mask input as it's entered, which is a very different task from what you've actually stated. Please correct me if I'm mistaken. If I'm correct, a simple method: @echo off Set "HideInput=For %%n in (1 2)Do if %%n==2 ((set /P "=_" < NUL > "!Str!" & findstr /A:1E /V "^$" "!Str!...
by T3RRY
22 Feb 2022 09:42
Forum: DOS Batch Forum
Topic: Help with menu
Replies: 2
Views: 3460

Re: Help with menu

You mean something like this?
viewtopic.php?t=6581
by T3RRY
21 Feb 2022 06:27
Forum: DOS Batch Forum
Topic: reverse string without goto
Replies: 10
Views: 13905

Re: reverse string without goto

I am very late to this party but I like this problem Antonio Same - My take, doesn't bother getting string length - splits string by character and rebuilds string in reverse order. Usage: %reverse% StringVar ReturnVar DE need not be enabled prior to expansion. @echo off Set "$Example=/?! ^&f><oo%%....
by T3RRY
15 Feb 2022 07:14
Forum: DOS Batch Forum
Topic: Recursively expand variables in strings
Replies: 5
Views: 4810

Re: Recursively expand variables in strings

Where an extra level of expansion is required, it is generally simpler to use call or a for loop to expand component delayed variables of macros. A short example of using call to trigger an extra parsing step for the sort of use case you propose: @Echo off For /f delims^= %%e in ('echo Prompt $E^|cm...
by T3RRY
06 Feb 2022 08:42
Forum: DOS Batch Forum
Topic: How to spool batch script logic to create another batch script but not expanded?
Replies: 5
Views: 5391

Re: How to spool batch script logic to create another batch script but not expanded?

Thats another escaping issue. When redirecting from within a parenthesised code block, closing parentheses to be output need caret escaping. likewise, Pipes, redirectors and ampersands that are intended to be output literally need caret escaping. A somewhat simpler way is described here: https://sta...
by T3RRY
06 Feb 2022 05:43
Forum: DOS Batch Forum
Topic: How to spool batch script logic to create another batch script but not expanded?
Replies: 5
Views: 5391

Re: How to spool batch script logic to create another batch script but not expanded?

Escape the Percent characters with themselves for any variables you don't want expanded
by T3RRY
15 Jan 2022 09:15
Forum: DOS Batch Forum
Topic: Wokring out battle messages and lol
Replies: 3
Views: 3587

Re: Wokring out battle messages and lol

What i'd recommend before getting carried away with ill concieved approcahes to accomplish your end goals is to spend some time researching and understanding the different ways of utilizing data structures in batch files. Lists, arrays, lookup tables and even methods of implementing OOP principles i...
by T3RRY
14 Jan 2022 07:28
Forum: DOS Batch Forum
Topic: Errorhandling in dos .bat files
Replies: 3
Views: 9388

Re: Errorhandling in dos .bat files

basically just place errorlevel strings where you feel you are likely to have errors and move them around to narrow down the potential causes. Microsofts website lists over 16,000 errorcodes! will echo an error code IF ERRORLEVEL 1 ECHO %ERRORLEVEL% will inact error resolution1 if that fails error ...