This plugin will reduce HAL's response to 1 complete sentence for each GetResponse.
'Project D.A.V.I.D
'
Dynamically
Advanced
Virtual
Intelligent
Droid.
Copy and paste the code into a text file then save as SomeFileName.uhp into your Ultra Hal Assistant 6 folder then choose the plugin via HAL's brain options panel.
Last update: Tuesday 09-19-17 @ 11:38AM
1. changed routine back to 1 getresponse after fixing HAL's Joke requirements.
2. Added a routine that preserves HAL jokes if detected when limiting HAL responses.
3. added a second variable to preserve the joke routine in HAL.
'Rem Type=Plugin
'Rem Name=Limit Response Count To one
'Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge
'Rem Host=Assistant
'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
lblPlugin(0).Caption = "This Plugin limits HAL's response to only 1 complete sentences at a time."
lblPlugin(0).Move 120, 10, 3300, 1000
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
End Sub
Rem PLUGIN: CUSTOMMEM2
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.
'OnTheCuttingEdge
'--------------------Limit Response Count to one--------------------------------------
'LETS SETUP RESPONSE FOR FORMATTING.
EndOfSent = Replace(GetResponse, ".", "<Period>", 1, - 1, vbTextCompare)
'LETS USE PATTERN SEARCH TO CROP RESPONSES FOR COUNT.
Response1 = HalBrain.SearchPattern(EndOfSent, "*<Period>*", 1)
Response2 = HalBrain.SearchPattern(EndOfSent, "*<Period>*", 2)
Response3 = HalBrain.SearchPattern(EndOfSent, "*<Period>*<Period>*", 3)
'PRESERVE JOKE ROUTINE IF HAL USES IT DURING LIMITED RESPONSES.
JokeDetect = "False"
If HalBrain.TopicSearch(PrevUserSent, "jokeDetect") = "True" Then JokeDetect = "True"
If HalBrain.TopicSearch(UserSentence, "jokeDetect") = "True" Then JokeDetect = "True"
If JokeDetect = "False" Then
'HERE WE CAN LIMIT HOW MANY GETRESPONSE ARE ALLOWED PER RESPONSE.
If Len(Response1) > 2 Then GetResponse = Response1 & "." 'Limited to only 1 complete sentence.
'INCASE RESPONSE 1 IS BLANK THEN GO TO NEXT RESPONSE IN SAME LINE IF IT EXISTS.
If Len(GetResponse) < 3 And Len(Response2) > 2 Then GetResponse = Response2 & "."
'GO TO THE NEXT RESPONSE LINE IF NEEDED.
If Len(GetResponse) < 3 And Len(Response3) > 2 Then GetResponse = Response3 & "."
'IF NO RESPONSE IS GIVEN (BLANK) THEN FILL IT WITH A RESPONSE.
If Len(GetResponse) < 3 Then GetResponse = " I do not know much about it. "
End If
'This is the same plugin but allows 2 complete sentences to be performed instead of just one, I think I like these responses better.
'Rem Type=Plugin
'Rem Name=Limit Response Count To 1-2 complete sentences
'Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge
'Rem Host=Assistant
'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
lblPlugin(0).Caption = "This Plugin limits HAL's response to only 1-2 complete sentences at a time."
lblPlugin(0).Move 120, 10, 3300, 1000
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
End Sub
Rem PLUGIN: CUSTOMMEM2
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.
'OnTheCuttingEdge
'--------------------Limit Response Count to one--------------------------------------
'LETS SETUP RESPONSE FOR FORMATTING.
EndOfSent = Replace(GetResponse, ".", "<Period>", 1, - 1, vbTextCompare)
'LETS USE PATTERN SEARCH TO CROP RESPONSES FOR COUNT.
Response1 = HalBrain.SearchPattern(EndOfSent, "*<Period>*", 1)
Response2 = HalBrain.SearchPattern(EndOfSent, "*<Period>*", 2)
Response3 = HalBrain.SearchPattern(EndOfSent, "*<Period>*<Period>*", 3)
'PRESERVE JOKE ROUTINE IF HAL USES IT DURING LIMITED RESPONSES.
JokeDetect = "False"
If HalBrain.TopicSearch(PrevUserSent, "jokeDetect") = "True" Then JokeDetect = "True"
If HalBrain.TopicSearch(UserSentence, "jokeDetect") = "True" Then JokeDetect = "True"
If JokeDetect = "False" Then
'HERE WE CAN LIMIT HOW MANY GETRESPONSE ARE ALLOWED PER RESPONSE.
If Len(Response1) > 2 Then GetResponse = Response1 & "." & Response2 & "." 'Limited to only 1-2 complete sentences.
'INCASE RESPONSE 1 IS BLANK THEN GO TO NEXT RESPONSE IN SAME LINE IF IT EXISTS.
If Len(GetResponse) < 3 And Len(Response2) > 2 Then GetResponse = Response2 & "."
'GO TO THE NEXT RESPONSE LINE IF NEEDED.
If Len(GetResponse) < 3 And Len(Response3) > 2 Then GetResponse = Response3 & "."
'IF NO RESPONSE IS GIVEN (BLANK) THEN FILL IT WITH A RESPONSE.
If Len(GetResponse) < 3 Then GetResponse = " I do not know much about it. "
End If
Have A Nice Day!
Jerry