I would like to have a error level (i think) for the below code, basically what i would like to do is run the below code if the word Unreported occurs in ims.txt. If the word Unreported does not occur in ims.txt i would like it to go back to MENU. Originally i thought i could do a simple ERRORLEVEL command but i cannot seem to get it to work. I would provide you with my attempts but i mistakenly deleted them!!!

Why would you even want it to process for the loop if it is not in the IMS file?

15 May 2012 07:59

Matt20687

Joined: 02 May 2012 14:42Posts: 54

Re: ErrorLevel Command Required?

Squashman wrote:

Why would you even want it to process for the loop if it is not in the IMS file?

If it is in the ims file the need for it to carry on is not required. If it is not in the ims file i need it to carry on with the loop.

The reason for this is because if the loop carries on and it is already at the unreported status it will cause serious issues as the .exe file has a set amount of steps which manipulates the web page using autohotkey, this works well but I need to be able to ensure the script knows not to run the .exefile when the word unreported is within ims.txt. Again it needs to do a search for the id %%b and see if the word unreported exists, this was explained in my previous post.

15 May 2012 10:52

Squashman

Joined: 23 Dec 2011 13:59Posts: 2388

Re: ErrorLevel Command Required?

Then change the double || to a double && in Foxi's code.

15 May 2012 15:48

foxidrive

Joined: 10 Feb 2012 02:20Posts: 4696

Re: ErrorLevel Command Required?

I'm unsure of your needs Matt but if you want to process the loop anyway, and only allow ChangeToKT.exe to run when unreported does not exist, then this will do that.

Code:

find "Unreported" <ims.txt>nul || start ChangeToKT.exe

If you want to avoid the loop altogether when "Unreported" does exist, then Squashman's suggestion of changing the || to && in my original suggestion should work.

You have said the exact opposite so I'm unsure which is what you need.

Matt20687 wrote:

If the word Unreported does not occur in ims.txt i would like it to go back to MENU.

15 May 2012 19:43

Squashman

Joined: 23 Dec 2011 13:59Posts: 2388

Re: ErrorLevel Command Required?

I certainly agree with Foxidrive. You seem to be contradicting yourself.

Matt20687 wrote:

If the word Unreported does not occur in ims.txt i would like it to go back to MENU.

Matt20687 wrote:

If it is not in the ims file i need it to carry on with the loop.

16 May 2012 05:35

Matt20687

Joined: 02 May 2012 14:42Posts: 54

Re: ErrorLevel Command Required?

Squashman wrote:

I certainly agree with Foxidrive. You seem to be contradicting yourself.

Matt20687 wrote:

If the word Unreported does not occur in ims.txt i would like it to go back to MENU.

Matt20687 wrote:

If it is not in the ims file i need it to carry on with the loop.

Sorry about the confusion!!

The correct statement is if the word Unreported occurs in ims.txt then i would like it to skip starting the .exe and start the loop again for the next ID. So i would need to alter your code Foxi to replace || to &&? So it would look like:

The correct statement is if the word Unreported occurs in ims.txt then i would like it to skip starting the .exe and start the loop again for the next ID.

You need this line within the loop;

Code:

find "Unreported" <ims.txt>nul || start ChangeToKT.exe

|| means "If it can't find that word then run the exe file"

16 May 2012 18:55

Matt20687

Joined: 02 May 2012 14:42Posts: 54

Re: ErrorLevel Command Required?

Hello,

This is not working exactly how i wanted. It is searching for the word 'Unreported' in ims.txt. Foxi i need to be able to search for the word Unreported which is on the same line as the variable %%c which is the sps_id in the sed command.

I do not know if it helps but the word unreported is laid out in the code as below.

As you can see <td> is before the word Unreported and the closest unique identifier (sps_id) is a fair way away, is there any way to create a command that works within the sed loop that searches the ims.txt which returns the 3 different variables, do you remember creating this bit of code for me?

So to conclude i need a piece of code that will fit into and work within the sed loop and look at %%c which is the sps_id shown above and then look back to the left see if the word Unreported exists until it gets to <td>. If it does exist it is to not run the .exe, if it doesnt exist it is to run the .exe as stated in the previous posts.

18 May 2012 09:40

foxidrive

Joined: 10 Feb 2012 02:20Posts: 4696

Re: ErrorLevel Command Required?

I'm unable to test this without the strings in ims.txt but this might work: