|
Answer» here is my code: Code: [Select]@ECHO off set /p name= set name=%name:A=ka% & name=%name:B=tu% & name=%name:C=mi% & name=%name:D=te% & name=%name:E=ku% & name=%name:F=lu% & name=%name:G=ji% & name=%name:H=ri% & name:I=ki% & name=%name:J=zu% & name=%name:K=me% & name=%name:L=ta% & name=%name:M=rin% & name=%name:N=to% & name=%name:O=mo% & name=%name:P=no% & name=%name:Q=ke% & name=%name:R=shi% & name=%name:S=ari% & name=%name:T=chi% & name=%name:U=do% & name=%name:V=ru% & name=%name:W=me% & name=%name:X=na% & name=%name:Y=fu% & name=%name:Z=zi% cls echo %name% pause >nul exitbut when i write a name set command only change first letter... where is problem?The ampersand is used to construct compound commands. Nothing is implied. Either add a set commmand before each name= OR put each set command on a separate LINE.. You don't GET any extra credit for having the fewest number of lines in a batch file. Putting a prompt on the set /p name= statement wouldn't hurt either.
I dont get what you say... Can you tell me in simple way ? Its possible or not ?On Top of that it makes your post impossible to read .............The ampersand connects multiple instructions. You cannot write one set command and expect the processor to carry it across multiple ampersands.
Write all your set lines (except the first) as one line in your editor. If the editor wraps, that's ok, just keep typing (just like you did in your original post):
Code: [Select]@echo off set /p set name=Enter name: set name=%name:A=ka% & set name=%name:B=tu% & set name=%name:C=mi% & set name=%name:D=te% & set name=%name:E=ku% & set name=%name:F=lu% & set name=%name:G=ji% & set name=%name:H=ri% & set name:%name:I=ki% & set name=%name:J=zu% & set name=%name:K=me% & set name=%name:L=ta% & set name=%name:M=rin% & set name=%name:N=to% & set name=%name:O=mo% & set name=%name:P=no% & set name=%name:Q=ke% & set name=%name:R=shi% & set name=%name:S=ari% & set name=%name:T=chi% & set name=%name:U=do% & set name=%name:V=ru% & set name=%name:W=me% & set name=%name:X=na% & set name=%name:Y=fu% & set name=%name:Z=zi% cls echo %name% pause >nul exit
An alternative (and better) way is to put each set on a separate line:
Code: [Select]@echo off set /p set name=Enter name: set name=%name:A=ka% set name=%name:B=tu% set name=%name:C=mi% set name=%name:D=te% set name=%name:E=ku% set name=%name:F=lu% set name=%name:G=ji% set name=%name:H=ri% set name=%name:I=ki% set name=%name:J=zu% set name=%name:K=me% set name=%name:L=ta% set name=%name:M=rin% set name=%name:N=to% set name=%name:O=mo% set name=%name:P=no% set name=%name:Q=ke% set name=%name:R=shi% set name=%name:S=ari% set name=%name:T=chi% set name=%name:U=do% set name=%name:V=ru% set name=%name:W=me% set name=%name:X=na% set name=%name:Y=fu% set name=%name:Z=zi% cls echo %name% pause >nul exit
The set statement is not case sensitive. As far as I know there is no continuation character in batch language. I recommend you use one set statement per line.
I have no idea what you're doing but the results should be surprising oh ok thx u it work but there is other problem if i type ex. "b" it will make b=tu and t=chi u=do so output will be "chido" not "tu"It shouldn't be so surprising. Computers are fairly very dumb and and blindly do what they are programmed to do. I suspect you wanted to do one substitution per letter and not make SUBSTITUTIONS for the substituted letters.
With a little imagination you may be able to do this in batch (I'd hate to see that code) but with Windows you have other scripting languages available, either already installed (VBScript and JScript) or readily available on the net for free (Python, REXX, Perl and countless others).
Check out VBScript at the Script Center. It's surprisingly easy to learn and much more powerful than batch.
Good luck.
|