Search found 80 matches

by T3RRY
02 Aug 2020 10:55
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 1539

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

you cannot pass the value of a for variable to another script or subroutine in that way. The script / subroutine is proccessed in a new child environment outside the for loop, and as such does not have access to the for loops variable. You would have to assign the for variable to a "global" variabl...
by T3RRY
02 Aug 2020 09:15
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 1539

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

you cannot pass the value of a for variable to another script or subroutine in that way. The script / subroutine is proccessed in a new child environment outside the for loop, and as such does not have access to the for loops variable. You would have to assign the for variable to a "global" variable...
by T3RRY
02 Aug 2020 06:49
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 1539

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

The simplest solution then that wouldn't require any drastic change to your process would be to as mentioned previously use a non alphabetical for variable Ie:

Code: Select all

%%@
in the definition macro - any usable character that you would not ordinarialy otherwise use in any library that calls the macro definer
by T3RRY
02 Aug 2020 06:13
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 1539

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

I do believe this to be a known issue, but attempted search terms failed to locate a suitably relevant topic. From the help output for For /? Remember, FOR variables are single-letter, case sensitive, global, and you can't have more than 52 total active at any one time. For variables can be repeated...
by T3RRY
30 Jul 2020 13:52
Forum: DOS Batch Forum
Topic: Only accept a numeric number.
Replies: 20
Views: 2100

Re: Only accept a numeric number.

Code: Select all

@Echo Off
:Input <VarName>
  Setlocal EnableDelayedExpansion
:Fetch
  Set /P "input=Enter %1: "
  Echo/!input!|"%__AppDir__%findstr.exe" /RX "[0-9]*" >NUL||Goto :Fetch
If "!input!"=="0" (Goto :Fetch) Else If !Input! GTR 12 Goto :Fetch
(
  Endlocal & Set "%1=%input%"
  Exit /B
)
by T3RRY
17 Jul 2020 20:23
Forum: DOS Batch Forum
Topic: [SOLVED] cmd prompt will not run maximized after CALL script ends.
Replies: 2
Views: 846

Re: cmd prompt will not run maximized after CALL script ends.

the primary program resumes from the point the call is made - If the :menu label occurs prior to the call, it will not be parsed.
by T3RRY
15 Jul 2020 14:11
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 2200

Re: loop without for to read lines of a file

The following modification to Squahmans answer is a bit more robust: @Echo Off & CD "%~dp0" Setlocal EnableDelayedExpansion Set LB=0 Set L#=0 call :Read <"%~F0" pause GOTO :EOF :Read set "line[%L#%]=" Set /p "line[%L#%]=" if not "!line[%L#%]!"=="" ( Set LB=0 ) else ( Set /A LB+=1 If !LB! GTR 2 (GOTO...
by T3RRY
15 Jul 2020 08:09
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 1605

Re: Assign cmdline output to var with inner cmdline quotes?

The set command only assigns a string to a variable. In order to capture the output of a command for assignment, A 'For /F' Loop is required The typical syntax for iterating over a command containing quotes within a For /F loop is: For /F "Tokens=* UsebackQ" %%G in (`Command`) Do Set "Var=%%G" I mu...
by T3RRY
13 Jul 2020 08:59
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 2321

Re: Redirect output to file without using > sign?

If the xml lines are highly variable, it may be easier to write them with the aid of a macro: @Echo Off ::: { Set environment state for Macro Definitions Setlocal DisableDelayedExpansion (Set LF=^ %= Above Empty lines Required =%) Set ^"\n=^^^%LF%%LF%^%LF%%LF%^^" Set xml.write=For %%n in (1 2) Do I...
by T3RRY
12 Jul 2020 03:00
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 1605

Re: Assign cmdline output to var with inner cmdline quotes?

The set command only assigns a string to a variable. In order to capture the output of a command for assignment, A 'For /F' Loop is required The typical syntax for iterating over a command containing quotes within a For /F loop is: For /F "Tokens* UsebackQ" %%G in (`Command`) Do Set "Var=%%G" I must...
by T3RRY
11 Jul 2020 11:51
Forum: DOS Batch Forum
Topic: Why doesn't this replacement work?
Replies: 3
Views: 1194

Re: Why doesn't this replacement work?

The coma is a delimiter within the for loop set - much the same as space, which is what prevents the Substring modification from occuring when the for loop executes. The upside of this is that the substring modification is uneccesary, just use the variable as it's already defined. The output will be...
by T3RRY
10 Jul 2020 04:21
Forum: DOS Batch Forum
Topic: Problem with my Perlin Noise implementation?
Replies: 1
Views: 772

Re: Problem with my Perlin Noise implementation?

Just though a bit of quick testing, as dimensions increase, the value of px[final] scales to the point it (far) exceeds the 255 value limit of the RGB values hence the washed out colours. I added the following code to your script to generate the attatched log in order see whats happening with the va...
by T3RRY
07 Jul 2020 09:28
Forum: DOS Batch Forum
Topic: Figuring out which computer is being used at two different locations
Replies: 12
Views: 1813

Re: Figuring out which computer is being used at two different locations

Presuming the PC models are known and differ, you could use the PC model for comparison

(For /F "Delims=" %%G in ('wmic computersystem get Model /Format:Value') Do Set "%%G")>Nul
by T3RRY
06 Jul 2020 14:01
Forum: DOS Batch Forum
Topic: Paint & Animation Studio
Replies: 9
Views: 1970

Re: VT code Paint & Animation Studio

Layer support now added! Load objects from different projects into the animator by pressing INSERT when in Animate mode to select objects to load. Switch between loaded objects (Layers) using TAB while in animate mode. The active layer is retained as the Editable Object when returning to paint mode....
by T3RRY
04 Jul 2020 03:49
Forum: DOS Batch Forum
Topic: <LF> is allowed in variable names
Replies: 4
Views: 1318

Re: <LF> is allowed in variable names

All good points, I was missing the obvious in the output from the set display of the variable content, and working with the results of the the variable names that contained carets, not linefeeds.