Page 1 of 2

The topic is to reach a value, in a batch file with only one setted variable

Posted: 30 Aug 2016 10:06
by ledlightjungled
To plenish all usefull information for redirecting the commands from batch files through command line, time
is most common exit to windows surface.

Handling files and folders is an abstract use for the tools in reach.

In my orbit a function is closer to set variables, then the whole concept of files and folders.

To build a usefull menu with the command line at least, in my case one variable should be changed using
same line and row.

Finding a line in a row to search an adress in a command line output i need a variable value that has
a force to change while runtime to build adresses.

The batch wrote i start with is

Code: Select all

@echo off
setlocal enabledelayedexpansion

for /l %%g in (1,1,15) do (
   set /a i=i+1
   set day[!i!]=0%%g
)

for /l %%f in (16,1,30) do (
   set /a y=y+1
   set odd[!y!]=%%f
)

for /f "tokens=1,2 usebackq" %%d in ('[ ]') do set "mixit=altgraphik=%%d,closed=%%e"

set "%mixit:,=" & set "%"

for /l %%c in (1,1,15) do (
for /f "tokens=1,2 usebackq" %%a in ('!day[%%c]:~-2! !odd[%%c]!') do echo %altgraphik%%%a%closed% __ %altgraphik%%%b%closed%)

endlocal disabledelayedexpansion
pause


to change the numbers inside the squared brackets at all.

A substrat is a ground to grow on, replenish.

Batch files can be empty in a textfile environment, and a setted variable named new. . .
could hold empty value one value to change if possible.

Redirecting runtime to value is not to be seen in output although a textfile can be changed.

What are the possibilties to make a change in command line output that changes in likewise a textfile can
be seen in the command line output. For my case i Need to Change an only one Output number without clearscreen.

And the second step to do while a value in a variable is to be reached from batch file input to change
the value while runtime.
One Batch file only one setted variable, is it possible to reach the value for once and more often.

??

the example in reach > Textfile

> command line Output while runtime

The second example empty batch file with one setted named variable %justname%, to build a environment
to reach the value for an input and to be changed while runtime.

I appreciate answers that can be done, no match must not be supplied.
Glad Riddler
Stefan

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 30 Aug 2016 11:44
by aGerman
I really tried hard. But unfortunately I'm not able to understand your requirements :(

Steffen

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 31 Aug 2016 01:42
by ShadowThief
aGerman wrote:I really tried hard. But unfortunately I'm not able to understand your requirements :(

Steffen

I'm usually good at speaking Google Translate, but I'm totally blanking here.

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 31 Aug 2016 02:38
by ledlightjungled
Sorry for my chained steps in written language without grip.

I can direct an cmd Output to a Textfile, and with the direct keyborad sign > replace the value.
I try to figure a way to replace a value of an cmd Output while runtime.
That is my first step.

My second step should be, for a setted %variable% in a Batch file in each case empty and with a value to reach, inside the
Shell of the setted %variable% or the value saved from there.
I try in that case to use another second Batch file to do that, but not able to writte it.
Maybe with a for call case.

If i can´t manage what i have, to reach Information for manipulating the %1 parameter while runtime, i only mention well
i fought to find, the journey goes on.

When possible thanks with regardes

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 31 Aug 2016 14:16
by foxidrive
ledlightjungled, see https://translate.google.com/

If you have not used google translate, then please write in your native langauge and use google translate to change your words to English.

It may be easier for us to understand your task, because you have some language difficulty.

German

Wenn Sie nicht verwendet haben, Google zu übersetzen, dann schreiben Sie bitte in Ihrer Mutterlangauge und die Verwendung von Google übersetzen Ihre Worte Englisch zu ändern.

Es kann einfacher sein, um Ihre Aufgabe zu verstehen, weil Sie einige Sprachschwierigkeiten haben.

Swedish

Om du inte har använt Google translate , vänligen skriv in ditt eget langauge och använda google translate att ändra dina ord till engelska.

Det kan vara lättare för oss att förstå din uppgift, eftersom du har något språk svårigheter.

Dutch

Als u nog niet hebt gebruikt google translate, dan kunt u schrijven in uw moedertaal langauge en gebruik google translate om uw woorden in het Engels te veranderen.

Het kan makkelijker zijn voor ons om je taak te begrijpen, want je hebt wat taalproblemen.

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 31 Aug 2016 23:23
by ShadowThief
foxidrive wrote:ledlightjungled, see https://translate.google.com/

I was under the assumption that this is what caused the issue in the first place.

My old dictionary doesn't have the word "setted".

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 01 Sep 2016 10:56
by pieh-ejdsch
I didn't understand your Question.
here is an Example of Code you want - so i think.

Code: Select all

@echo off
prompt $g$s
setlocal enabledelayedexpansion
 rem Parameter

set begin=307
set end=1550

 rem End Parameter

set /a odd=2*end +1 -begin
call :strLen odd len

set /a pre=1
for /l %%i in (1 1 %len%) do set /a "pre*=10"
set /a "bBegin=(pre +begin) *pre +end +1 ,eEnd=(pre +end) *pre +odd ,next=pre+1"

for /l %%n in (%bBegin% %next% %eEnd%) do (
  set "out=%%n"
  set "out=!out:*1=!"
  echo [!out:^~0^,^-%len%!] __ [!out:^~^-%len%!]
)
pause


exit /b
:strLen string len -- returns the length of a string
::                 -- string [in]  - variable name containing the string being measured for length
::                 -- len    [out] - variable to be used to return the string length
:: Many thanks to 'sowgtsoi', but also 'jeb' and 'amel27' dostips forum users helped making this short and efficient
:$created 20081122 :$changed 20101116 :$categories StringOperation
:$source http://www.dostips.com
(   SETLOCAL ENABLEDELAYEDEXPANSION
    set "str=A!%~1!"&rem keep the A up front to ensure we get the length and not the upper bound
                     rem it also avoids trouble in case of empty string
    set "len=0"
    for /L %%A in (12,-1,0) do (
        set /a "len|=1<<%%A"
        for %%B in (!len!) do if "!str:~%%B,1!"=="" set /a "len&=~1<<%%A"
    )
)
( ENDLOCAL & REM RETURN VALUES
    IF "%~2" NEQ "" SET /a %~2=%len%
)
EXIT /b


Phil

PS: for the Translation i use this site http://www.online-translator.com/#!/Computer/

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 02 Sep 2016 07:51
by ledlightjungled
Für den Code

Code: Select all

@echo off
setlocal enabledelayedexpansion

for /l %%g in (1,1,15) do (
   set /a i=i+1
   set day[!i!]=0%%g
)

for /l %%f in (16,1,30) do (
   set /a y=y+1
   set odd[!y!]=%%f
)

for /f "tokens=1,2 usebackq" %%d in ('[ ]') do set "mixit=altgraphik=%%d,closed=%%e"

set "%mixit:,=" & set "%"

for /l %%c in (1,1,15) do (
for /f "tokens=1,2 usebackq" %%a in ('!day[%%c]:~-2! !odd[%%c]!') do echo %altgraphik%%%a%closed% __ %altgraphik%%%b%closed%)

endlocal disabledelayedexpansion
pause


mit der Ausgabe

[01] __ [16]
[02] __ [17]
[03] __ [18]
[04] __ [19]
[05] __ [20]
[06] __ [21]
[07] __ [22]
[08] __ [23]
[09] __ [24]
[10] __ [25]
[11] __ [26]
[12] __ [27]
[13] __ [28]
[14] __ [29]
[15] __ [30]
Drücken Sie eine beliebige Taste . . .

habe ich für mich ein Format geschrieben, dass ich nicht ändere, um einzelne Teile der Ausgabe ändern zu können.

Mit einer ersten Batchdatei würde ich gerne auf den Parameter %1 einer zweiten Batchdatei zugreifen
können.

Der Parameter %1 sollte nur mit einer %variable% besetzt sein und ich würde gerne den Wert der Schale
%variable% nach belieben speichern und ändern können.

Die zweite Batchdatei sollte wenn möglich an der Stelle Parmeter %1 eine %variable% stehen haben,
mit der ich während einer command line Laufzeit, ohne den Befehl clear screen cls, die Nummer
01 der Ausgabe [01] ändern kann.

Das Ausgabe Format [01] bis [30] sollte sich nicht ändern, sondern nur die Nummern.

Für den Anfang sollte ich nur die Nummer 01, nach belieben ändern können.

For the code

Code: Select all

@echo off
setlocal enabledelayedexpansion

for /l %%g in (1,1,15) do (
   set /a i=i+1
   set day[!i!]=0%%g
)

for /l %%f in (16,1,30) do (
   set /a y=y+1
   set odd[!y!]=%%f
)

for /f "tokens=1,2 usebackq" %%d in ('[ ]') do set "mixit=altgraphik=%%d,closed=%%e"

set "%mixit:,=" & set "%"

for /l %%c in (1,1,15) do (
for /f "tokens=1,2 usebackq" %%a in ('!day[%%c]:~-2! !odd[%%c]!') do echo %altgraphik%%%a%closed% __ %altgraphik%%%b%closed%)

endlocal disabledelayedexpansion
pause


with the issue

[01] __ [16]
[02] __ [17]
[03] __ [18]
[04] __ [19]
[05] __ [20]
[06] __ [21]
[07] __ [22]
[08] __ [23]
[09] __ [24]
[10] __ [25]
[11] __ [26]
[12] __ [27]
[13] __ [28]
[14] __ [29]
[15] __ [30]
Drücken Sie eine beliebige Taste . . .

I wrote for myself a format that I do not change in order to change individual parts of the output can.

With a first batch file I would like to access the parameters %1 of a second batch file
can.

The parameter %1 should be filled only with %variable% and I would like the value of the shell
Can save %variable% at will and change.

The second batch file should have if possible at the point parmeter a %variable% are %1,
with the I during a commandline runtime without the clear screen cls command, the number
01 may change the output [01].

The output format [01] to [30] should not be changed, but only the numbers.

For starters, should I only number 01, can change at will.

changed with https://translate.google.com.my/?hl=en&tab=wT

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 03 Sep 2016 13:06
by ledlightjungled
With a second reply a row starts.
I finish this row in my second step, with a maybe i get reply.
Like i understand wath i have gathered without an additional reply i don´t post a third one in a row.

My wish was to reach parameter one.
For a most convenient start i writte, echo %0, is the ouput of the path in a C:\ directory.

Now i use three batch files to get a grip on my steps.
start.bat includes

set variable=value
echo %variable% > "C:\Users\Stefan Mihael\Desktop\parameter.bat"
call "C:\Users\Stefan Mihael\Desktop\output.bat"

2.parameter.bat

value

3.output.bat

for /f "usebackq" %%a in ("C:\Users\Stefan Mihael\Desktop\parameter.bat") do echo %%a
pause

The command line output would be

>set variable=value
>echo value 1>"C:\Users\Stefan Mihael\Desktop\parameter.bat"
>call "C:\Users\Stefan Mihael\Desktop\output.bat"
>for /F "usebackq" %a in ("C:\Users\Stefan mihael\Desktop\parameter.bat") do echo %a
>echo value
value
>pause
Drücken Sie eine beliebige Taste . . .

In an other output, as follow

[01] __ [16]
[02] __ [17]
[03] __ [18]
[04] __ [19]
[05] __ [20]
[06] __ [21]
[07] __ [22]
[08] __ [23]
[09] __ [24]
[10] __ [25]
[11] __ [26]
[12] __ [27]
[13] __ [28]
[14] __ [29]
[15] __ [30]

i am searching for a line with my tokens, to replace 01 with the output from parameter %1, value.
I won´t bother a third step.
Thank´s for this task, so far.

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 04 Sep 2016 02:17
by foxidrive
ShadowThief wrote:
foxidrive wrote:https://translate.google.com/

I was under the assumption that this is what caused the issue in the first place.

Your comment made me think about it and I wasn't sure if translate was used there, so I made that point just in case the fellow didn't understand that he could use it in that way.

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 04 Sep 2016 05:39
by foxidrive
ledlightjungled wrote:W
Now i use three batch files to get a grip on my steps.

start.bat includes

set variable=value
echo %variable% > "C:\Users\Stefan Mihael\Desktop\parameter.bat"
call "C:\Users\Stefan Mihael\Desktop\output.bat"

2.parameter.bat

value

3.output.bat

for /f "usebackq" %%a in ("C:\Users\Stefan Mihael\Desktop\parameter.bat") do echo %%a
pause

The command line output would be

>set variable=value
>echo value 1>"C:\Users\Stefan Mihael\Desktop\parameter.bat"
>call "C:\Users\Stefan Mihael\Desktop\output.bat"
>for /F "usebackq" %a in ("C:\Users\Stefan mihael\Desktop\parameter.bat") do echo %a
>echo value
value
>pause



In an other output, as follow

[01] __ [16]
[02] __ [17]
[03] __ [18]
[04] __ [19]
[05] __ [20]
[06] __ [21]
[07] __ [22]
[08] __ [23]
[09] __ [24]
[10] __ [25]
[11] __ [26]
[12] __ [27]
[13] __ [28]
[14] __ [29]
[15] __ [30]

i am searching for a line with my tokens, to replace 01 with the output from parameter %1, value.


You show the output of the three short scripts and that is straightforward.

However I do not understand how the numbers relate to the three batch scripts.

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 04 Sep 2016 09:34
by ledlightjungled
The conditions for a pattern in a line with text and batch code i have to discover, while it is not
suited for a dostip frame with common habit.

The batchfiles were not named 2.parameter and 3.ouput.
I just counted and added numders.

On my Desktop the origin for the three batch File names are

start

parameter

output

The row from [01] to [30] is my nutcase to change 01 or any other number with a second step in a row.
In this case 02 to 31.

I try to reach counting with batch programming, by implementing a variable that has the possibility to be changed.
Clear screen command cls is an option, still i can not reach a death end trying to redirect parameter %1
for a case i have not found.
The case would be a parameter saved with a 01 output and while runtime changed to 02 ouput.
The second option is to have an error script log that the option is not useable.

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 04 Sep 2016 17:16
by douglas.swehla
ledlightjungled wrote:

Code: Select all

@echo off
setlocal enabledelayedexpansion

for /l %%g in (1,1,15) do (
   set /a i=i+1
   set day[!i!]=0%%g
)

for /l %%f in (16,1,30) do (
   set /a y=y+1
   set odd[!y!]=%%f
)

for /f "tokens=1,2 usebackq" %%d in ('[ ]') do set "mixit=altgraphik=%%d,closed=%%e"

set "%mixit:,=" & set "%"

for /l %%c in (1,1,15) do (
for /f "tokens=1,2 usebackq" %%a in ('!day[%%c]:~-2! !odd[%%c]!') do echo %altgraphik%%%a%closed% __ %altgraphik%%%b%closed%)

endlocal disabledelayedexpansion
pause



The code above can be simplified like this:

Code: Select all

:: fixed_columns.bat
@echo off
setlocal enabledelayedexpansion

for /l %%L in (1,1,15) do (
   set day=0%%L
   set /a odd=%%L+15
   echo [!day:~-2!] __ [!odd!]
)

endlocal
exit /b


If you want more flexibility in what numbers are used, you can use this:

Code: Select all

:: flex_columns.bat
@echo off
setlocal enabledelayedexpansion

set /a start=%~1, step=%~2, end=%~3, day_diff=%~4, odd_diff=%~5 2>nul
if not defined day_diff set /a day_diff=0
if not defined odd_diff set /a odd_diff=%~3

for /l %%L in (%start%,%step%,%end%) do (
   set /a day=%%L+day_diff
   set /a odd=%%L+odd_diff
   set day=0!day!
   set odd=0!odd!
   echo [!day:~-2!] __ [!odd:~-2!]
)
endlocal
exit /b


The code above takes three required arguments, and two optional argument. The required arguments are the START, STEP, and END numbers that go into the FOR /L command. The optional arguments are numbers that modify the values output into the columns. You can use it like this:

Code: Select all

:: flex_columns_test.bat
@echo off
setlocal

call flex_columns.bat 1 1 15
echo ------------
call flex_columns.bat 1 1 15 0 15
echo ------------
call flex_columns.bat 1 1 15 0 20
echo ------------
call flex_columns.bat 3 4 24 2 20
echo ------------
call flex_columns.bat 3 4 24 2
echo ------------
call flex_columns.bat 16 1 31 0 15

endlocal
exit /b


Here is the output of test script:

Code: Select all

:: flex_columns_test.txt
flex_columns.bat 1 1 15
[01] __ [16]
[02] __ [17]
[03] __ [18]
[04] __ [19]
[05] __ [20]
[06] __ [21]
[07] __ [22]
[08] __ [23]
[09] __ [24]
[10] __ [25]
[11] __ [26]
[12] __ [27]
[13] __ [28]
[14] __ [29]
[15] __ [30]

flex_columns.bat 1 1 15 0 15
[01] __ [16]
[02] __ [17]
[03] __ [18]
[04] __ [19]
[05] __ [20]
[06] __ [21]
[07] __ [22]
[08] __ [23]
[09] __ [24]
[10] __ [25]
[11] __ [26]
[12] __ [27]
[13] __ [28]
[14] __ [29]
[15] __ [30]

flex_columns.bat 1 1 15 0 20
[01] __ [21]
[02] __ [22]
[03] __ [23]
[04] __ [24]
[05] __ [25]
[06] __ [26]
[07] __ [27]
[08] __ [28]
[09] __ [29]
[10] __ [30]
[11] __ [31]
[12] __ [32]
[13] __ [33]
[14] __ [34]
[15] __ [35]

flex_columns.bat 3 4 24 2 20
[05] __ [23]
[09] __ [27]
[13] __ [31]
[17] __ [35]
[21] __ [39]
[25] __ [43]

flex_columns.bat 3 4 24 2
[05] __ [27]
[09] __ [31]
[13] __ [35]
[17] __ [39]
[21] __ [43]
[25] __ [47]

flex_columns.bat 16 1 31 0 15
[16] __ [31]
[17] __ [32]
[18] __ [33]
[19] __ [34]
[20] __ [35]
[21] __ [36]
[22] __ [37]
[23] __ [38]
[24] __ [39]
[25] __ [40]
[26] __ [41]
[27] __ [42]
[28] __ [43]
[29] __ [44]
[30] __ [45]
[31] __ [46]



If you run flex_columns.bat from the command line, you do not need to use CALL:

Code: Select all

:: CMD output
C:\test>flex_columns.bat 1 1 5
[01] __ [16]
[02] __ [17]
[03] __ [18]
[04] __ [19]
[05] __ [20]
[06] __ [21]
[07] __ [22]
[08] __ [23]
[09] __ [24]
[10] __ [25]
[11] __ [26]
[12] __ [27]
[13] __ [28]
[14] __ [29]
[15] __ [30]
C:\test>

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 04 Sep 2016 17:31
by douglas.swehla
@aGerman,
I trust your translation more than Google's. Can you help us out here?

@ledlightjungled,
It looks like you are trying to use arrays. Batch files do not have native support for array data structure. If you want to, you can create your own, and we can show you how.

Square brackets ([]) are not special characters in batch files, so you do not need to assign them to variables. This code is not necessary, and it is also too complicated:

Code: Select all

:: complicated
for /f "tokens=1,2 usebackq" %%d in ('[ ]') do set "mixit=altgraphik=%%d,closed=%%e"
set "%mixit:,=" & set "%"

:: simple, but not needed
set "altgraphik=["
set "closed=]"


ledlightjungled wrote:during a commandline runtime without the clear screen cls command, the number
01 may change the output [01].

This sounds like you want to change text that is already on the screen. This is not possible without writing directly to the screen memory. I think there used to be a way to do that long ago, but it is hard or impossible now. It is much easier to recalculate, clear the screen, and re-send the output.

It will be much easier to help you if we know what you are really trying to do. What do the columns of numbers represent? Is it a calendar? Should there always be two columns and fifteen rows? Should the numbers always go from 01 to 30? What is this for?

Re: The topic is to reach a value, in a batch file with only one setted variable

Posted: 05 Sep 2016 00:34
by aGerman
douglas.swehla wrote:@aGerman,
I trust your translation more than Google's. Can you help us out here?

I can't translate bad English into good English as long as I don't understand a word. Sorry.

Steffen