Debug and Rate AI code

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
RedBeard
Posts: 2
Joined: 26 Nov 2020 13:46

Debug and Rate AI code

#1 Post by RedBeard » 20 Jun 2022 16:07

I found an open AI and decided to have it write a batch file, tell me whats wrong with it (because it doesnt work) and rate the AIs skill level.

Here is what was asked:

"Write batch file code for windows 7 that uses a key to encrypt and decrypt messages in window."

Code: Select all

@echo off

setlocal

set key=1234

:start

echo Enter 1 to encrypt a message, 2 to decrypt a message, or 3 to exit

set /p choice=

if %choice%==1 (

echo Enter the message to encrypt:

set /p message=

for /f "tokens=*" %%a in ('%message%') do set "encrypted=!encrypted!%%a"

echo The encrypted message is: %encrypted%

)

if %choice%==2 (

echo Enter the message to decrypt:

set /p message=

for /f "tokens=*" %%a in ('%message%') do set "decrypted=!decrypted!%%a"

echo The decrypted message is: %decrypted%

)

if %choice%==3 exit

goto start

batmanbatmanbatmen
Posts: 9
Joined: 23 Sep 2022 22:13

Re: Debug and Rate AI code

#2 Post by batmanbatmanbatmen » 24 Sep 2022 03:09

First, use setlocal enabledelayedexpansion
2rd, inside for loop, you can try ('echo xxx') instead of ('xxx'). Sometime is ok.
3nd, I don't understand your encrypted message method. Do you want to remove space in "message" or merge all input message to one ?

For example as below, is it correct ?
1st round:
message=I am a boy. The encrypted message= I am a boy
2nd round:
message=You are a girl. The encrypted message= I am a boyYou are a girl

Post Reply