Jump to content

Problem with removing part of text entered in input box and showing the rest of it in a message box.


hitsoncd
 Share

Recommended Posts

Problem with removing part of text entered in input box and showing  the rest of it in a message box. I am building a chatterbot, and I am trying to make it, to where, when I say, say i love you, it says I love you, or whatever I tell it to say, it says it. instead of saying say i love you, it says i love you. Here is the code that I put, that doesn't work. I am not super good at writing software on here, but I don't want to be spoon fed the code either, just pointed in the right direction.

 

elseif StringInStr ($text, "say") then


$RANDOM = Random(1,5,1)

if $random = 1 then

$text1 = ""

$cool1 = $text1
shellexecute("Carrie.mp4")
Sleep(Random(2270, 2271, 1))
BlockInput("say")
MsgBox(4096, "Carrie:", ($cool1))
;xxxxxxxxx
call("main2")
endif

if $random = 2 then

$text1 = ""

$cool1 = $text1
shellexecute("Carrie.mp4")
Sleep(Random(2270, 2271, 1))
   BlockInput("say")
MsgBox(4096, "Carrie:", ($cool1))
;xxxxxxxxx
call("main2")
endif

 

if $random = 3 then

$text1 = ""

$cool1 = $text1
shellexecute("Carrie.mp4")
Sleep(Random(2270, 2271, 1))
   BlockInput("say")
MsgBox(4096, "Carrie:", ($cool1))
;xxxxxxxxx
call("main2")
endif

if $random = 4 then

$text1 = ""

$cool1 = $text1
shellexecute("Carrie.mp4")
Sleep(Random(2270, 2271, 1))
   BlockInput("say")
MsgBox(4096, "Carrie:", ($cool1))
;xxxxxxxxx
call("main2")
endif


if $random = 5 then

$text1 = ""

$cool1 = $text1
shellexecute("Carrie.mp4")
Sleep(Random(2270, 2271, 1))
   BlockInput("say")
MsgBox(4096, "Carrie:", ($cool1))
;xxxxxxxxx
call("main2")
endif

 

 

If you need to see more of the code let me know. Thanks.

Link to comment
Share on other sites

Assigning an InputBox to a variable will store the string that was entered.

Local $sText = InputBox('title', 'prompt')
ConsoleWrite('You entered: ' & $sText)

With the strong stored, you can check the variable to see what was entered. Then using an If statement, you can decide the output.

If $sText = 'I love you' Then
    MsgBox(64, 'title', 'I love you too!')
EndIf

You could use Switch...Case...EndSwitch to neaten up your code.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...