Search found 58 matches

by T3RRY
09 Sep 2020 14:12
Forum: DOS Batch Forum
Topic: NFL fantasy league draft batch program. Thoughts?
Replies: 1
Views: 180

Re: NFL fantasy league draft batch program. Thoughts?

alot of what your doing to control choices could be achived with the actual choice command. Setlocal EnableDelayedExpansion For %%v in (1 2 3)Do Set "rb%%v=0" :Pick For /F "Delims=" %%G in ('Choice /N /C 123')Do (If "!rb%%G!"=="0" (Set "rb%%G=1"&Goto RB%%G)Else (Echo/Pick %%G already Selected& Goto ...
by T3RRY
06 Sep 2020 10:31
Forum: DOS Batch Forum
Topic: Batch array scripts, to make life easier
Replies: 6
Views: 592

Re: Batch array scripts, to make life easier

A total absence of arrays in batches allows to implement them in different ways: -- arr[idx] (or something similar to) -- arr sep idx (like arr.idx or arr_idx etc) I think that the actual implementation of batch arrays lies on authors of the scripts they develop. I very much agree with the principl...
by T3RRY
05 Sep 2020 09:36
Forum: DOS Batch Forum
Topic: Batch array scripts, to make life easier
Replies: 6
Views: 592

Re: Batch array scripts, to make life easier

Anmerkung 2020-09-05 134427.png ¯\_(ツ)_/¯ Maybe some examples would be helpful. Steffen Helpful to be sure, there was also a change I made and failed to test appropriately before the last upload that cut off a lot of the Usage Error messages. That's now been fixed, and more detailed usage info prov...
by T3RRY
05 Sep 2020 03:57
Forum: DOS Batch Forum
Topic: Batch array scripts, to make life easier
Replies: 6
Views: 592

Re: Batch array scripts, to make life easier

The all in one package is complete Modes: [Def] Define, modify or clear an array. [Def] Switches: [/A:Groupname] [/F:Filepath.ext] [/D] [/O:Index#Arg] [/E:Element Sub value] [Sort-int] Sorts array by lowest or highest value using /L or /H switches [Sort-int] Switches: [/A:Groupname] [/N:New Groupnam...
by T3RRY
04 Sep 2020 12:11
Forum: DOS Batch Forum
Topic: Batch array scripts, to make life easier
Replies: 6
Views: 592

Batch array scripts, to make life easier

I often see questions on stackoverflow about defining "arrays" with batch. Here's a little something I whipped that I can use whenever I want to establish an array without having to code specifically for it. The usage info and Error checking for is reasonably thorough making it simple to use The scr...
by T3RRY
17 Aug 2020 10:18
Forum: DOS Batch Forum
Topic: Letter used in a variable.
Replies: 15
Views: 1212

Re: Letter used in a variable.

fyi, choice does accept numbers 0-9 in addition to alphabetical characters. Note using a for /f loop to iterate over the choice command will return letters in upper case, even if the choice options are declared using lower case. You can also obtain the available drives using wmic to define (and disp...
by T3RRY
16 Aug 2020 03:39
Forum: DOS Batch Forum
Topic: scripting problem
Replies: 2
Views: 470

Re: scripting problem

Not also there are simpler ways of constructing a batch file using choice to navigate menu's than cumbersome if conditions. A simple example: Echo/ [1] Option 1 [2] Option 2 [3] Option 3 For /F "Delims=" %%O in ('Choice /N /C:123') Do goto :1stmenu%%O Using a for /f loop to iterate over the choice c...
by T3RRY
13 Aug 2020 22:31
Forum: DOS Batch Forum
Topic: Letter used in a variable.
Replies: 15
Views: 1212

Re: Letter used in a variable.

A variant on the Choice for loop option I use when using single letter input to control script flow between labels that cleanly handles non existing labels: Echo/Select Drive: For /F "Delims=" %%L in ('Choice /N /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ') Do (Call :chkdsk_F_%%L || Call :chkdsk_F_other) 2> Nul r...
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: 1119

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: 1119

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: 1119

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: 1119

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: 1575

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: 746

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: 1890

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...