|
Answer» how to make a list in .bat file where i'll input ex. a number and it go to second third etc place if i type 1 it will echo: Code: [Select]1: 1 2: 0 3: 0if 3 Code: [Select]1: 3 2: 1 3: 0etc etc sorry for bad engWhat is the application for this? More info can help. If a static list, you can have the VALUES passed in memory, but if you want to be able to close the batch and go back in and have it PICK up where it left off, you will want it to read and write from a text file like list.log
DaveIf you want to play with arrays, you can look into vbscriptCode: [Select]If a static list, you can have the values passed in memory, but if you want to be able to close the batch and go back in and have it pick up where it left offyes that im going to do but is it possible or no?anyone I've done this in C++ before, but not batch. Only written data to a file in batch.
Just Googled and this is what I came up with for you. One solution other than C++ is Perl. And the person with the problem got it working with the FOR instruction for their application.
http://www.aota.net/forums/archive/index.php/t-7059.htmli made somethink like this and it work Code: [Select]@echo off set num1=0 set num2=0 set num3=0 set num4=0 :A set /P num= if %num% geq %num1% set num2=%num1% & set num3=%num2% & set num1=%num% & goto B if %num% geq %num2% set num3=%num2% & set num2=%num% & goto B if %num% geq %num4% set num4=%num3% & set num3=%num% & goto B :B cls echo.1: %num1% echo.2: %num2% echo.3: %num3% goto Ahow can i do that i have in file Code: [Select]5 4 3and make Code: [Select]a=5 b=4 c=3 if you use the for loops and set some tokens, you can get what you want.yes i tryied work on it from hours and it dont workQuote from: ghostdog74 on JANUARY 22, 2008, 12:31:57 AM if you use the for loops and set some tokens, you can get what you want.
Quote from: devcom on January 22, 2008, 02:23:27 AMyes i tryied work on it from hours and it dont work
Ghostdog pretty much laid it out for you. Show us some code. We THRIVE on constructive criticism. i have something like this if there are some bugs tell me Code: [Select]@echo off if exist list.txt [Here i wont to do for loop like gostdog says] & goto A set num1=0 set num2=0 set num3=0 set num4=0 :A set /p num= if %num% geq %num1% set num2=%num1% & set num3=%num2% & set num1=%num% & goto B if %num% geq %num2% set num3=%num2% & set num2=%num% & goto B if %num% geq %num4% set num4=%num3% & set num3=%num% & goto B :B cls echo.%num1% %num2% %num2% >list.txt [Here i wont to do for loop like gostdog says] echo.1: %num1% echo.2: %num2% echo.3: %num3% goto A ok i have it Code: [Select]For /F "tokens=1-3 delims= " %%x in (list.txt) do ( set a=%%x set b=%%y set c=%%z )
|