Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a small block of code that is supposed to parse through a file called data.dta but for some reason it keeps saying ( unexpected, here is the code(I put a comment by the line that gives me an error):

:load
cd %appdata%\.Trek
FOR /f "eol=#" %%t IN (Resources\Data\data.dta) DO ( ::problem line
	set count=1
	set cor=0
	FOR /f "tokens=1-2 delims=^=" %%f IN ("%%t") DO (
		If %count% == 1 (
			IF %%f==VERSION set cor=1
		)
		If %count% == 2 (
			IF %cor%==1 (
				set cor=0
				set ver=%%f
			)
		)
		set /a count=%count%+1
	)
)
Title TREK Unmounted Console Version: %ver%


Contents of data.dta:

VERSION=ALPHA 2
Posted
Updated 28-Mar-13 12:57pm
v3
Comments
Sergey Alexandrovich Kryukov 28-Mar-13 18:01pm    
Is there any specific reason to use such an outdated and weak tool as batch for the problem of this complexity? People used to solve much trickier problems, but who want to dig into such stuff?
Why not using, for example, PowerShell, with its powerful debugging features and huge expressive power?
Why not using "real" programming? (This is a developer's site, by the way :-)
—SA
Sicppy 28-Mar-13 18:40pm    
I meant to make the a reply
Sicppy 28-Mar-13 18:30pm    
Batch is 'real' coding, you put together a sequence of commands to make a functioning program, and i'm using batch for fun, its just a little project im doing, its not complicated, so no need to use a more complex language
Sergey Alexandrovich Kryukov 28-Mar-13 18:43pm    
I do know how batch works and how to use it. It depends on what you call "real". Call it the way you want, it won't change the fact that you cannot use any effective debugging and development tools. So, I still cannot see why not using something else. By the way, I do understand the convenience of batch, I use it myself...
—SA
Sicppy 28-Mar-13 19:01pm    
Yes, it is very convenient, but other than that, I really enjoy coding in batch, also, alot of the functions of this program are going to be in java/c++, the batch is just a host, if you would like to see the whole project I can send you the zip file

1 solution

Please see my comments to the question and still consider using PowerShell:
http://en.wikipedia.org/wiki/PowerShell[^],
http://technet.microsoft.com/en-US/scriptcenter/dd742419.aspx[^].

It is a really fully-fledged scripting tool and the language, with feature-rich and very interesting programming paradigm based on .NET (and exposing nearly all power of .NET to the script developer, among many other things like WMI and WSH, and more). Since its v.3 (of 2012), it also got such a powerful yet simplistic development IDE, that even the debugging became a real pleasure.

Just think about it.

—SA
 
Share this answer
 
Comments
Sicppy 28-Mar-13 19:26pm    
I will learn powershell and have looked into it many times, but I would still like to finish this project the way I started it... With spaghetti logic
Sergey Alexandrovich Kryukov 28-Mar-13 19:29pm    
Whatever, but I hope you will remember this idea...
—SA
Allister Lindamood 28-Mar-13 19:58pm    
goto 4
:1
echo logic
goto 4.982
:2
echo good
goto 6
:4
echo spaghetti
goto 1
:4.982
echo is best
goto a
:6
echo sir
:a
echo logic
goto 2

exit
Sergey Alexandrovich Kryukov 28-Mar-13 20:05pm    
:-) :-)
Spaghetti... Even the batch language has calls (subroutines, with returns), did you know that?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900