You are not logged in.
Pages: 1
File one.bat starts 2.bat a batch file in the same directory and when 2.bat is done how can I go back to file one.bat and search for a specific piece of text and start on the x th number that is found x being a number in num.txt a text file in the same directory.
If this isn't clear let me try to show you a snippet of code
@echo off
Cls
:: file one.bat
2.bat
Echo I'm back
Pause
@echo off
Cls
::2.bat
Echo doing stuff...
Set /a %var%+1>file.txt
Call file one.bat && search for 2.bat and find the one that is x down and continue on next line
:: so that would echo I'm back
I know this can be done with the call command but I am looking for a way to do this without the call command thanks!
Offline
There is NO WAY to go to a line that have no label! This is a way to do that (based on a label):
@echo off
setlocal
if defined return goto %return%
Cls
echo File one.bat
set "return=Ret1"
2.bat
:Ret1
Echo I'm back
Pause
@echo off
::2.bat
Echo 2.bat: doing stuff...
Set /a %var%+1
one.bat
Antonio
Offline
Why can't you use the call command? It exists for a reason!
The best solution I can come up with is to allow one.bat to take in a label as a parameter and use a goto to skip there.
:: Valid parameters are the words "one" and "two"
@echo off
setlocal enabledelayedexpansion
cls
if not "%~1"=="" goto :%~1
:zero
echo No parameter was given.
goto :eof
:one
echo Parameter ONE was given.
goto :eof
:two
echo Parameter TWO was given.
goto :eof
Offline
Posts and threads with crap, useless, bogus, misleading questions should just be deleted.
The internet is becoming full of them - every tech forum - and they are going to be of absolutely no use to any reader in the future.
I'm officially applying for my curmudgeon badge!
Last edited by foxidrive (16 Jan 2016 04:18)
Offline
This could be useful if some knucklehead has gone and created a call.bat and stuck it in one of the %PATH% directories or the current directory.
Offline
I can't follow the question Shadow Thief, and there's no actual text about the task explaining what it's supposed to do...
This line for example. What function does it serve?
Set /a %var%+1>file.txt
My rant continues below :
Batch scripting has become such a different field, where questions are asked with bogus information, and there is no discussion about the task, and add to that - the examples you see are made up and don't reflect the actual task.
Programming isn't something that lets you guess what the person wants to do - and batch scripting is most effective, simple and straightforward when it is designed around the real task.
Young programmers don't realise this:
- that information about the exact task allows you and I to write robust and efficient code.
- They aren't aware that they waste the time of people who are helping them free of charge.
Offline
@foxidrive: I completely agree with you. When beginners post nonsense questions is a waste of our time trying to understand what they mean. I usually just ignore these questions.
However, now and then these "nonsense" beginner questions include some point that may suggest a new approach or method that may lead to a new or different way to solve a problem. This approach would not even be considered from more experienced users. At least two of my original tricks had emerged from this type of questions, so I consider they as a source of inspiration. Be gentle with they... ...
Antonio
Last edited by Aacini (16 Jan 2016 15:29)
Offline
In reply to Antonio:
I may have been unreasonably annoyed, as my health is very poor.
I would have liked to have seen some explanation of why call can't be used, as that has a bearing on the final solution.
@foxidrive: I completely agree with you. When beginners post nonsense questions is a waste of our time trying to understand what they mean. I usually just ignore these questions.
I could just ignore them as you wisely suggest - but I'd end up ignoring 90% of the posts.
If I had been clearer in my post I would have commented that a great deal of the time it's not the beginners that do this.
However, now and then these "nonsense" beginner questions include some point that may suggest a new approach or method that may lead to a new or different way to solve a problem. This approach would not even be considered from more experienced users. At least two of my original tricks had emerged from this type of questions, so I consider they as a source of inspiration. Be gentle with they... ...
Antonio
Yes, that's a good point and good advice, thanks.
Last edited by foxidrive (16 Jan 2016 18:03)
Offline
Pages: 1