循环解析器的批处理 [英] Batch for loop parser

查看:95
本文介绍了循环解析器的批处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一小段代码应该通过一个名为data.dta的文件进行解析但是由于某种原因它一直在说(意外,这是代码(我在行中发表评论,给我一个错误) :



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%





data.dta的内容:





Contents of data.dta:

VERSION=ALPHA 2

推荐答案

请参阅我对该问题的评论并仍然考虑使用PowerShell:

http://en.wikipedia.org/wiki/PowerShell [ ^ ],

http://technet.microsoft .com / zh-CN / scriptcenter / dd742419.aspx [ ^ ]。



这是一个非常完善的脚本工具和语言,基于功能丰富且非常有趣的编程范例在.NET上(并将几乎所有.NET的功能暴露给脚本开发人员,以及WMI和WSH等许多其他东西)。自从它的第3版(2012年)以来,它还拥有如此强大而简单的开发IDE,甚至调试也变得非常愉快。



想想看吧。



-SA
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


这篇关于循环解析器的批处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆