please help me to write this
Moderator: DosItHelp
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
please help me to write this
Hi,
I want to write this nombers with batch file:
1, 1, 2, 3, 5, 8, 13, 21, ...
and another batch file that I write for example 1000 and batch file write for me thousandth of nombers above.
for example when I write 4 the batch file write 3
thank u
I want to write this nombers with batch file:
1, 1, 2, 3, 5, 8, 13, 21, ...
and another batch file that I write for example 1000 and batch file write for me thousandth of nombers above.
for example when I write 4 the batch file write 3
thank u
Re: please help me to write this
Hi Mohammad_Dos,
and at which point in your batch file do you have problems?
It would be much more effective, if you can post your batch with a description of your current problems.
hope it helps
jeb
and at which point in your batch file do you have problems?
It would be much more effective, if you can post your batch with a description of your current problems.
hope it helps
jeb
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: please help me to write this
I dont know too much about dos and batch file commans. please write for me all of that
one of my problems:
how to plus 2 nomber?
for example we have:
how to plus them into %nom3% ?
and more problems ...
one of my problems:
how to plus 2 nomber?
for example we have:
Code: Select all
%nom1%=4
%nom2%=6
how to plus them into %nom3% ?
and more problems ...
Re: please help me to write this
Code: Select all
@echo off
rem take input to num, if no input set num to 46
if "%1"=="" (set /a num=46) else (set /a num=%1)
rem set beginning values of vars $q,$r,$s to 0,0,1
set /a $q=$r=0
set /a $s=ser=1
rem start cycle from 2 to %num% by 1
for /l %%a in (2,1,%num%) do (
rem shift values of vars $q <- $r <- $s
set /a $q=$r
set /a $r=$s
rem calculation new $s
set /a $s=$q+$r
rem add new $s to serial
call set "ser=%%ser%%, %%$s%%"
)
rem output serial
echo %ser%
example: serial.cmd 46
46 is maximum
Last edited by !k on 06 Dec 2010 12:37, edited 1 time in total.
Re: please help me to write this
version 2
maximum is 92
clc.exe here: http://cmdlinecalc.sourceforge.net/
Code: Select all
@echo off
setlocal enableextensions enabledelayedexpansion
if "%1"=="" (set /a num=92) else (set /a num=%1)
set /a $q=$r=0
set /a $s=ser=1
for /l %%a in (2,1,%num%) do (
set "$q=!$r!"
set "$r=!$s!"
for /f %%s in ('clc.exe !$q!+!$r!') do set "$s=%%s"
set "ser=!ser!, !$s!"
)
echo %ser%
maximum is 92
clc.exe here: http://cmdlinecalc.sourceforge.net/
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: please help me to write this
!k wrote:call serial.cmd 46Code: Select all
@echo off
if "%1"=="" (set /a num=46) else (set /a num=%1)
set /a $q=$r=0
set /a $s=ser=1
for /l %%a in (2,1,%num%) do (
set /a $q=$r
set /a $r=$s
set /a $s=$q+$r
call set "ser=%%ser%%, %%$s%%"
)
echo %ser%
46 is maximum
thank u a lot !k
please explain that
Re: please help me to write this
viewtopic.php?p=5671#p5671
Sorry for my English
Sorry for my English
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: please help me to write this
ok
thank u
but I dont understand this line:
please explain a little about for command in this line
thank u
but I dont understand this line:
Code: Select all
for /l %%a in (2,1,%num%) do ...[/b]
please explain a little about for command in this line
Re: please help me to write this
FOR/? wrote:FOR /L %variable IN (start,step,end) DO command [command-parameters]
The set is a sequence of numbers from start to end, by step amount.
So (1,1,5) would generate the sequence 1 2 3 4 5
and (5,-1,1) would generate the sequence 5 4 3 2 1
Code: Select all
set /a num=10
for /l %%a in (2,1,%num%) do echo counter = %%a
output:
counter = 2
counter = 3
counter = 4
counter = 5
counter = 6
counter = 7
counter = 8
counter = 9
counter = 10
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: please help me to write this
!k wrote:FOR/? wrote:FOR /L %variable IN (start,step,end) DO command [command-parameters]
The set is a sequence of numbers from start to end, by step amount.
So (1,1,5) would generate the sequence 1 2 3 4 5
and (5,-1,1) would generate the sequence 5 4 3 2 1Code: Select all
set /a num=10
for /l %%a in (2,1,%num%) do echo counter = %%a
output:counter = 2
counter = 3
counter = 4
counter = 5
counter = 6
counter = 7
counter = 8
counter = 9
counter = 10
that worked in batch file but doesn't work in command prompt. why?
Re: please help me to write this
Please ...
Read For /? and cmd /? and set /?
Read For /? and cmd /? and set /?
Re: please help me to write this
Mohammad_Dos wrote:that worked in batch file but doesn't work in command prompt. why?
In prompt you should use one % in var %x
Code: Select all
for /l %a in (2,1,%num%) do echo counter = %a