Batch number system

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Batch number system

#1 Post by batchcc » 21 Aug 2015 09:59

I have a code where
if %num%==1 echo %pre determined value%

And so on untill 99 is there a way to make it so when thefb user types a number in between 201 and 299 it will echo cc%pre determined value% of the existing number for example user types 201 output is cc%value of one %

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch number system

#2 Post by foxidrive » 21 Aug 2015 10:27

Can you use more English words to describe what you want to do, and add some examples?

I can't follow what the task is.

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Batch number system

#3 Post by batchcc » 21 Aug 2015 10:53

I have a list of numeric values 1. - 200 and I want to set values for the values 201 - 299 the values mus be the same as the values 1 - 99 but with the letters cc infront of every value for example if the value for number 1 is a the the value for 201 would be cca but rather than type that for every value how can I just do it automatcly?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch number system

#4 Post by foxidrive » 21 Aug 2015 10:54

Ok. Where do you have the list of values for 1 to 200? In a file?

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Batch number system

#5 Post by batchcc » 21 Aug 2015 10:56

Yes my first file r.bat calls num.bat which contains the values

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch number system

#6 Post by foxidrive » 21 Aug 2015 11:02

The way a batch file provides the numbers depends on how you are using the 1 to 200 numbers.

Are they in an array, or are you searching with findstr? The details will determine how to help you.

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Batch number system

#7 Post by batchcc » 21 Aug 2015 14:06

R.bat
:top
set/p num=
Call num.bat

Num.bat
if %num%==1 echo a
If %num%==2 echo b
Code continues until 200 then goes to :top

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Batch number system

#8 Post by batchcc » 22 Aug 2015 16:07

is there a way to do this this way

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch number system

#9 Post by ShadowThief » 22 Aug 2015 17:32

You could just delete 200 from %num% if %num% is greater than 200 before you did all the other comparisons in num.bat

Code: Select all

if %num% gtr 200 (
    set /a num=%num%-200
)

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Batch number system

#10 Post by batchcc » 22 Aug 2015 19:40

Thanks shadow their but is there a way to use lss as well so if the value is grater that 299 the file uses
if %num% gtr 300 (
set /a num=%num%-300
)

Could this be added after to make the file deal with numbers over 300? Thanks

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch number system

#11 Post by ShadowThief » 22 Aug 2015 20:16

I would recommend adding it before the

Code: Select all

if %num% gtr% 200

line just so that both are used correctly, but sure.

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Batch number system

#12 Post by batchcc » 23 Aug 2015 04:38

Ok thanks so much

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Batch number system

#13 Post by batchcc » 23 Aug 2015 09:25

using


if %num% gtr 1000 (
type 1000.txt & set /a num=%num%-1000
)
if %num% gtr 900 (
type 900.txt & set /a num=%num%-900
)
if %num% gtr 800 (
type 800.txt & set /a num=%num%-800
)
if %num% gtr 700 (
type 700.txt & set /a num=%num%-700
)
if %num% gtr 600 (
type 600.txt & set /a num=%num%-600
)
if %num% gtr 500 (
type 500.txt & set /a num=%num%-500
)
if %num% == 400 echo CD
if %num% gtr 400 (
type 400.txt & set /a num=%num%-400
)
if %num% gtr 300 (
type 300.txt & set /a num=%num%-300
)
if %num% gtr 200 (
type 200.txt & set /a num=%num%-200
)

in num.bat and 400.txt the input for 400 is wrong it says CCCC rather than CD which is the only text in 400.txt
is there a way to fix this

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch number system

#14 Post by ShadowThief » 23 Aug 2015 09:47

Wait, are you writing a batch script to convert Arabic numerals to Roman numerals? That would have been really good to know from the beginning.

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: Batch number system

#15 Post by batchcc » 23 Aug 2015 10:01

No shadowtheif this has nothing to do with arabic however it does use roman numerals in this part of the code but roman numerals stop after the of the same letter III CCC LLL MMM but for the number 400 the code prints CCCC rather than cd is this because cd is a cmd command? It also doesn't work with 500 900 and 1000 but digits above that work for example 501 is displayed correctly even though 500 is incorrect.

Post Reply