1.

Solve : grammar?

Answer»

I don't have a computer with me, but try ^!
THANKS alot...using ^! its work thank you

now
-------------------------------------------------------------------

set bI=1
set bwash=2
set bthe=3
set bcar=4
set byesterday=5

if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!"
echo !bI!>>"bword.txt"
)
goto :eof

if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)
goto :eof

if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)
goto :eof

if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)
goto :eof

if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eof

-------------------------------------------------------------------
each set plus 1

but output becomes

set bI=2
set bwash=2
set bthe=2
set bcar=2
set byesterday=2

not

set bI=2
set bwash=3
set bthe=4
set bcar=5
set byesterday=6any ONE?
Quote

goto :eof
d
That is not in the right place. What you WANT it to mean?
Are your thinking about a CASE statement?
Batch does not have a CASE statement, not does it lend itself to a graceful way of making something like a CASE or SELECT structure.


i put goto :eof because i dont want it run all not necessary script.

-----------------------------------------------------------------------------------

i put value to each set

set bI=1
set bwash=2
set bthe=3
set bcar=4
set byesterday=5

went i run this script below

if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!"
echo !bI!>>"bword.txt"
)
goto :eof

if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)
goto :eof

if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)
goto :eof

if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)
goto :eof

if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eof

------------------------------------------------------------------
this script should make each set +1

from this to
plus 1 each of set
set bI=1 1+1=2 set bI=2
set bwash=2 2+1=3 set bwash=3
set bthe=3 3+1=4 set bthe=4
set bcar=4 4+1=5 set bcar=5
set byesterday=5 5+1=6 set byesterday=6


but output on bword.txt becomes like this

set bI=2
set bwash=2
set bthe=2
set bcar=2
set byesterday=2

you know how to solve this?Just remove all of goto :eof and it might work.it not work

it just going run all script...

output on bword.txt becomes

set bI=2
set bI=3
set bI=4
set bI=5
set bI=6
set bwash=2
set bwash=3
set bwash=4
set bwash=5
set bwash=6
set bthe=2
set bthe=3
set bthe=4
set bthe=5
set bthe=6
set bcar=2
set bcar=3
set bcar=4
set bcar=5
set bcar=6

it run all not necessary script.

if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!" if i remove goto :eof its will be run all not necessary script below
echo !bI!>>"bword.txt"
)
goto :eof

if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)
goto :eof

if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)
goto :eof

if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)
goto :eof

if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eofThis is as FAR as I can help you.
This term
"%word%"
is a persistent entity in the code you gave. It does not wear mutilate or change value by itself.
When the test of
==
meaning really equal to,
is used, the result is exclusive for a persistent entity tested on unique values., but not null null values. You were supposed to learn that back in Programming 101 some time ago.
Sorry, if you don't grasp this, I can not help you.

The script you gave has blocks that are mutually exclusive, so a break is not needed. Take out all the gooto.
@echo off
setlocal enabledelayedexpansion

echo 1 scan document
echo 2 create document
echo 3 reset document
set/p "pilih=^>"
if %pilih%==1 goto :scan
if %pilih%==2 goto :create
if %pilih%==3 goto :reset

:reset

set bI=0
set bwash=0
set bthe=0
set bcar=0
set byesterday=0



goto enter

:create

set bI=1
set bwash=2
set bthe=3
set bcar=4
set byesterday=5


if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!"
echo !bI!>>"bword.txt"
)


if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)


if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)


if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)


if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eof

:enter
echo enter text and enter
set /p input=:

:savebword


:scan
set /p input=file name with (.txt) :
type "%input%"
echo.
echo.

:loop
for /f "delims=" %%A in ('type "%input%"') do (
for %%B in (%%A) do (
echo %%B
call :set "%%B"
call :save "%%B"
call :create "%%B"
echo.
)
)

goto :end

:set

echo set " %~1 " as
echo 1 (pronoun)
echo 2 (noun)
echo 3 (verb)
echo 4 (adverb)
echo 5 (adjective)
echo 6 (preposition)
echo 7 (subject)
echo 8 (object)

set/p "cho=^>"
if %cho%==1 goto SOMEWERE
if %cho%==2 goto SOMEWERE
if %cho%==3 goto SOMEWERE
if %cho%==4 goto SOMEWERE
if %cho%==5 goto SOMEWERE
if %cho%==6 goto SOMEWERE
if %cho%==7 goto SOMEWERE
if %cho%==8 goto SOMEWERE
echo Invalid choice.
goto :eof

:save
set "word=%~1"
set "if=if"

set "tword=word"
set "code=word"

set "tset=set"
set "tbword=b!word!"

set "techo=echo"
set "simbol=^!"


set "output=!if! "%%!tword!%%"=="!word!" goto !tbword!"
set "outputt=:!tbword!"
echo !output!>>"word.txt"
echo !outputt!>>"word.txt"


set "output2=!tset! !tbword!=0"
echo !output2!>>"setword.txt"


set "output3=!tset! /a !tbword!=%%!tbword!%%+1"
echo !output3!>>"word.txt"

echo (set /a bword=%bword%+1)

set (bof=%bof%)





set "output4=!tset! !tbword!=%%!tbword!%%"

set "output6=!tset! "!tbword!=!simbol!tset!simbol! !simbol!tbword!simbol!=!simbol!!tbword!!simbol!""
set "output7=!techo! !simbol!!tbword!!simbol!>>"bword.txt""
set "output8=goto :eof"
echo !output6!>>"word.txt"
echo !output7!>>"word.txt"
echo !output8!>>"word.txt"

echo word " %~1 " now save
if "%~1"=="" goto nothaveit

goto :eof


:end
echo END OF CODE
pause>nul


this full script i make so far...

the problem is here

if "%word%"=="I" do (
set /a bI=%bI%+1
set "bI=!tset! !tbword!=!bI!"
echo !bI!>>"bword.txt"
)
goto :eof

if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)
goto :eof

if "%word%"=="the" do (
set /a bthe=%bthe%+1
set "bthe=!tset! !tbword!=!bthe!"
echo !bthe!>>"bword.txt"
)
goto :eof

if "%word%"=="car" do (
set /a bcar=%bcar%+1
set "bcar=!tset! !tbword!=!bcar!"
echo !bcar!>>"bword.txt"
)
goto :eof

if "%word%"=="yesterday" do (
set /a byesterday=%byesterday%+1
set "byesterday=!tset! !tbword!=!byesterday!"
echo !byesterday!>>"bword.txt"
)
goto :eof

it should create output like this

set bI=2
set bwash=3
set bthe=4
set bcar=5
set byesterday=6

but

set bI=2
set bwash=2
set bthe=2
set bcar=2
set byesterday=2

!bI!, !bwash!, !bthe! ,!bcar! and !byesterday! all =2...
why?

this is the problem that i need help to solveTry changing your set /a to

Code: [Select]Set /a %var%+=1
Quote
if "%word%"=="wash" do (
set /a bwash=%bwash%+1
set "bwash=!tset! !tbword!=!bwash!"
echo !bwash!>>"bword.txt"
)


1. There is no IF .... DO in batch language. (Are you making the syntax up as you go?) I am amazed you have not seen lots of error messages (or are you running batch scripts by double clicking them?)

2. To alter, or set and then read a variable inside parentheses you need delayed expansion. (Read about it).

I suggest you read the documentation for each command or keyword, either from the prompt by typing the command FOLLOWED by /? (example: if /?) or you can use a site like ss64.com

http://ss64.com/nt/

Start with simple scripts and learn how each command or keyword works. You are just making up code by guesswork, and that will just lead to very long threads like this one.





Discussion

No Comment Found