Jump to content

Hi, I am trying to troubleshoot a small piece of code i put together in batch but it seems to not be working,
it is meant to output 20000, then ad 5000, then repeat untill it hits 100000, then go back to 20000 and add one, then continue.
 

excuse the long scrolling

the output should be as follows

20000
25000
30000

35000
40000
45000
50000
55000
60000
65000
70000
75000
80000
85000
90000
95000
20001
25001
30001
35001
40001
45001
50001
55001
60001
65001
70001
75001
80001
85001
90001
95001
20002
25002
30002
35002
40002
45002
50002
55002
60002
65002
70002
75002
80002
85002

90002
95002
e.t.c

 

here is my code:

@[member=Echo] offcolor 0aset size=20000set inc=1set num=100000:1echo %size%set /a size=%size%+5000if /I %size% LEQ %num%(set /a size=20000+%inc%set /a inc=%inc%+1goto :1)else(goto :1

i don't know why but it just closes

 

plz help

Link to comment
https://linustechtips.com/topic/25947-troubleshooting-some-small-batch-code/
Share on other sites

Link to post
Share on other sites

@[member=Echo] off

wait wait wait...

 

Doesnt this hide the CMD window? Or am I just retard?

CPU: Intel i7 4790K @4.8GhZ  CPU Cooler: Be Quiet! Dark Rock Pro 2  Motherboard: Gigabyte Z97 UD3H  GPU: Asus ROG RX 480 8G OC Memory: 32GB Gskill Ares 2400Mhz  Storage: 2x Crucial M4 512GB SSD (raid0)  / 1TB Seagate FireCuda SSHD Case: Phanteks Enthoo Evolv ATX PSU: EVGA SuperNOVA P2 750W  Operating System: Windows 10 Enterprise LTSB (64 bit) Other: NZXT Hue+ LED Controller with 8 LED Strips for desk and PC lighting

 

Link to post
Share on other sites

Ah fun little task.  First correcting the code so I could run it in command prompt

@[member=Echo] offcolor 0aset size=20000set inc=1set num=100000:1echo %size%set /a size=%size%+5000if /I %size% LEQ %num% goto :2goto :1:2set /a size=20000+%inc%set /a inc=%inc%+1goto :1

Not much change, just the adding goto :2 to make it not throw an syntax error when I tried running it.

 

The next correction is to make it run more to what you wanted it as

@[member=Echo] offcolor 0aset size=20000set inc=1set num=100000:1echo %size%set /a size=%size%+5000if /I %size% GEQ %num% goto :2goto :1:2set /a size=20000+%inc%set /a inc=%inc%+1goto :1

The only real change is the LEQ to GEQ. The LEQ is less than or equal to, so size being 20000 would be less than 100k thus resetting size to 20000+%inc%, so you essentially would be going 20001 20002...etc

0b10111010 10101101 11110000 00001101

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×