第一次运行时,用户可以选择他们学校的课程类型。
然后(当你进一步查看源代码时)将会出现各种科目的第一次测试的日期。
如果我使用它,它将打印我没有的程序主题。例如,如果我有“法学(Rettslere)”而不是“市场营销”,我不希望市场营销(Markedsforing)被程序主体发现,而只是“法学”。因此,它应该忽略我没有的所有程序课程。
我该怎么做?
具体的问题:我怎么做,它不会输出程序的日志不在programfag.txt文件中?
程序:
echo Rettslære (R)
echo sosialkunnskap (s)
echo markedsforing (m)
echo historie og filosofi (hf)
echo sosialantropologi (sa)
echo psykologi (p)代码:
@echo off &setlocal EnableDelayedExpansion
if not exist "%userprofile%/programfag.txt" goto programfag
goto hello
:programfag
echo Rettslære (R)
echo sosialkunnskap (s)
echo markedsforing (m)
echo historie og filosofi (hf)
echo sosialantropologi (sa)
echo psykologi (p)
set /p programfag=What is your programfag (r,s,m,hf,sa,p)?
if %programfag% == r echo rettslare > %userprofile%/programfag.txt
if %programfag% == m echo markedsforing > %userprofile%/programfag.txt
if %programfag% == s echo sosialkunnskap > %userprofile%/programfag.txt
if %programfag% == hf echo Historieogfilosofi > %userprofile%/programfag.txt
if %programfag% == sa echo sosialantropologi > %userprofile%/programfag.txt
if %programfag% == p echo psykologi > %userprofile%/programfag.txt
goto programfag
:hello
set "file_path=.\test2.txt"
if not exist "!file_path!" echo File "!file_path!" Does Not Exist >&2 & exit /b 2
for /f %%F in ("!file_path!") do set file_path=%%~sfF
copy nul "%TEMP%\~.ddf" >nul
makecab /D RptFileName="%TEMP%\~.rpt" /D InfFileName="%TEMP%\~.inf" -f "%TEMP%\~.ddf">nul
for /f "tokens=3-7" %%a in ('type "%TEMP%\~.rpt"') do (
if not defined current-date set "current-date=%%e-%%b-%%c"
if not defined current-time set "current-time=%%d"
if not defined weekday set "weekday=%%a"
)
del /q "%TEMP%\~.*"
rem echo %weekday% %current-date% %current-time%
set Jan=01
set Feb=02
set Mar=03
set Apr=04
set May=05
set Jun=06
set Jul=07
set Aug=08
set Sep=09
Set Oct=10
set Nov=11
set Dec=12
set auth=Malin Kristiane Pedersen
set abas=0
set auto=%abas%
for /F "tokens=1,2,3 delims=-" %%A in ("%current-date%") do (
set comparable_date=%%A!%%B!%%C
)
rem echo %comparable_date%
set /a nearest_date=99999999
for /F "tokens=1,2,3 delims=. " %%A in (%file_path%) do (
set /a possible_nearest_date=%%C%%B%%A
set /a old_result=!nearest_date!-comparable_date
set /a new_result=!possible_nearest_date!-comparable_date
if !new_result! LSS !old_result! set /a nearest_date=!possible_nearest_date!
)
if !nearest_date! EQU 99999999 echo something wrong with the file>&2 && endlocal && exit /b 3
set nearest_date=!nearest_date:~-2!.!nearest_date:~4,2!.!nearest_date:~0,4!
color 4E
echo(
echo(
rem type %file_path%
for /f "tokens=1,2* delims=()" %%L in ('type %file_path%^|find "!nearest_date!"') do (
for /f "tokens=1,2" %%t in ("%%L") do (
echo Neste prove: (!nearest_date!^)
echo fag: %%u
title %%u !nearest_date! grunder: %auth%
echo Tema: %%M^ )
)
)
echo(
echo(
set /p skriva=Do you want to see typical questions about this topic? (Y/N)
if %skriva% EQU Y goto !nearest_date!sporsmaal
if %skriva% EQU y goto !nearest_date!sporsmaal
else
pause>nul
cls
goto hello
exit
:28.10.2013sporsmaal
echo AAA
echo BBB
echo CCC
echo DDD
echo EEE
pause
exit以下是输出的来源:
if !nearest_date! EQU 99999999 echo something wrong with the file>&2 && endlocal && exit /b 3
set nearest_date=!nearest_date:~-2!.!nearest_date:~4,2!.!nearest_date:~0,4! color 4E
echo( echo( rem type %file_path% for /f "tokens=1,2* delims=()" %%L in ('type %file_path%^|find "!nearest_date!"') do (
for /f "tokens=1,2" %%t in ("%%L") do (
echo Neste prove: (!nearest_date!^)
echo fag: %%u
title %%u !nearest_date! grunder: %auth%
echo Tema: %%M^ )
)
) echo( echo(注意:
Test2.txt中的示例:
28.10.2013 Norsk (kunnskapsprøve).
29.10.2013 matte (prøve kapittel 1 og kapittel 3,1 - 3,6).programfag.txt中的示例
markedsforing正如我所说的,我希望当fag (在源代码中)被显示时,当它在程序中查看时,它只会显示它与programfag.txt中的相同
发布于 2013-09-24 17:53:46
备份"%userprofile%/programfag.txt"文件并尝试此操作。它只打印在"%userprofile%/programfag.txt"文件中找到的内容。
@echo off
>>"%userprofile%/programfag.txt" echo 11/22/2000 sosialkunnskap
>>"%userprofile%/programfag.txt" echo 4/12/2010 historie og filosofi
:programfag
for %%a in (
"Rettslære (R)"
"sosialkunnskap (s)"
"markedsforing (m)"
"historie og filosofi (hf)"
"sosialantropologi (sa)"
"psykologi (p)"
) do for /f "delims= " %%b in ("%%~a") do find "%%b" <"%userprofile%/programfag.txt" >nul && echo %%~a
pausehttps://stackoverflow.com/questions/18975299
复制相似问题