Author Topic: Can this be fixed  (Read 3966 times)

Holllywood

  • Sr. Member
  • ****
  • Posts: 357
    • View Profile
Can this be fixed
« on: January 20, 2007, 02:19:46 pm »
Can this error be fixed?

  "Halscript error on line 5857 col. 0:Type mismatch: 'WC'


   HalDebug Scipt:

'Function Count Words (CW)
CW = WC(UserSentence)

'Custom Relavence For Universal GetResponse.
'This function tries to match as many words between GetResponse and the OriginalSentence.

For i = 1 To CW

   If i > 0 Then SearchIt = "* " + SearchIt
      SearchIt = Replace(SearchIt, vbCrLf, Chr(8) & " ", 1, - 1, vbTextCompare)
      SearchIt = Replace(SearchIt, "", "", 1, - 1, vbTextCompare)
      SearchIt = Replace(SearchIt, "  ", " ", 1, - 1, vbTextCompare)
   Next

   TemUserSent = OriginalSentence

   For i = 1 To CW

      If i > 0 Then PatternRel = HalBrain.SearchPattern(TemUserSent, SearchIt, i)

          PatternRel = Trim(Ucase(PatternRel))
         PatternRel2 = HalBrain.ExtractKeywords(PatternRel)
         PatternRel3 = HalBrain.AlphaNumericalOnly(PatternRel2)

         HalsResponse = Trim(Ucase(GetResponse))
         KeyHalWord = HalBrain.ExtractKeywords(HalsResponse)
         KeyHalWord2 = HalBrain.AlphaNumericalOnly(KeyHalWord)

         If InStr(1, KeyHalWord2, PatternRel3, vbTextCompare) > 0 Then PattBrainRel = 1 + PattBrainRel Else PattBrainRel = 0
         'Here we use the custom relavence for any Universal GetResponse.
            PatternRelavance = FormatPercent(PattBrainRel/CW)
            'PatternRel uses a Percentage scale to match the GetResponse to a OriginalSentence.
            'The more matches found the higher the PatternRelavance in percentage will be, 100 would
            'be a 100% match, we try to avoid 100% matches because it could be a repeat of the User for the response.
            'We try to maintain a PatternRelavance between 20% and 80% for percentage matches.
            'PatternRelavance finds these percentages by adding the number of matched keywords divided by the number of words
            'in the user's sentence.
         If (PatternRelavance >= "20" And PatternRelavance <= "80") And HalBrain.CheckRepetition(GetResponse, PrevSent) = False Then GetResponse = HalsResponse Else GetResponse = GetResponse & ShortPhrase
   Next

Hollywood

vrossi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://vrconsulting.it
Can this be fixed
« Reply #1 on: January 21, 2007, 05:37:56 am »
Hi Holliwood.

I don't know if this problem is the same you posted in our Virtual Humans Forum. However see my answer there:
http://www.vrconsulting.it/vhf/topic.asp?TOPIC_ID=39&whichpage=2

Looking at the source code you posted here, I can only tell you that this is not one of my plugins, so you should first find out which plugin gives this error. Please follow the steps I suggest you in the above topic.

Bye
« Last Edit: January 21, 2007, 05:38:51 am by vrossi »

onthecuttingedge2005

  • Guest
Can this be fixed
« Reply #2 on: January 21, 2007, 06:15:13 am »
Hi Holllywood.

This is the plugin below for which you have mentioned.

I have selected it in my plugin options and it seems to run fine.

there may be another plugin that is conflicting with it that may be using the same function name which is causing the type mismatch.

Code: [Select]

Rem Type=Plugin
Rem Name=ALF's Custom Relevence
Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005
Rem Host=All

'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
lblPlugin(0).Caption = "This is ALF's Custom Relevence Response Handler for Universal Responses that tend to stay on topic. "
lblPlugin(0).Move 120, 10, 3300, 1000
lblPlugin(0).WordWrap = True
lblPlugin(0).Visible = True
End Sub

Rem PLUGIN: PLUGINAREA7

'Function Count Words (CW)
CW = WCF(UserSentence)

'Custom Relavence For Universal GetResponse.
'This function tries to match as many words between GetResponse and the OriginalSentence.

For i = 1 To CW

If i > 0 Then SearchIt = "* " + SearchIt
SearchIt = Replace(SearchIt, vbCrLf, Chr(8) & " ", 1, - 1, vbTextCompare)
SearchIt = Replace(SearchIt, "", "", 1, - 1, vbTextCompare)
SearchIt = Replace(SearchIt, "  ", " ", 1, - 1, vbTextCompare)
Next

TemUserSent = OriginalSentence

For i = 1 To CW

If i > 0 Then PatternRel = HalBrain.SearchPattern(TemUserSent, SearchIt, i)

   PatternRel = Trim(Ucase(PatternRel))
PatternRel2 = HalBrain.ExtractKeywords(PatternRel)
PatternRel3 = HalBrain.AlphaNumericalOnly(PatternRel2)

HalsResponse = Trim(Ucase(GetResponse))
KeyHalWord = HalBrain.ExtractKeywords(HalsResponse)
KeyHalWord2 = HalBrain.AlphaNumericalOnly(KeyHalWord)

If InStr(1, KeyHalWord2, PatternRel3, vbTextCompare) > 0 Then PattBrainRel = 1 + PattBrainRel Else PattBrainRel = 0
'Here we use the custom relavence for any Universal GetResponse.
            PatternRelavance = FormatPercent(PattBrainRel/CW)
            'PatternRel uses a Percentage scale to match the GetResponse to a OriginalSentence.
            'The more matches found the higher the PatternRelavance in percentage will be, 100 would
            'be a 100% match, we try to avoid 100% matches because it could be a repeat of the User for the response.
            'We try to maintain a PatternRelavance between 20% and 80% for percentage matches.
            'PatternRelavance finds these percentages by adding the number of matched keywords divided by the number of words
            'in the user's sentence.
If (PatternRelavance >= "20" And PatternRelavance <= "80") And HalBrain.CheckRepetition(GetResponse, PrevSent) = False Then GetResponse = HalsResponse Else GetResponse = GetResponse & ShortPhrase
Next

Rem PLUGIN: FUNCTIONS

'Word Count Function.

Function WCF(UserSentence)
FilUserSent = HalBrain.AlphaNumericalOnly(UserSentence)
Str = FilUserSent
Str = Trim(Str)

Do While InStr(1, Str, "  ")
Str = Replace(Str, "  ", " ")
Loop

aWords = split(Str, " ")
WCF = Ubound(aWords) + 1
End Function



You could try selecting the ALF's Custom Relevence plugin by itself to see if you still have the error, if that's the case then you might try opening the plugin ALFsCustomRelevence.uhp and copy and paste the above code to replace it.

Jerry[8D]
« Last Edit: January 21, 2007, 06:08:36 pm by onthecuttingedge2005 »

Holllywood

  • Sr. Member
  • ****
  • Posts: 357
    • View Profile
Can this be fixed
« Reply #3 on: January 21, 2007, 12:52:18 pm »
Jerry, I unchecked all plugins. It is the "Custom Rel..." I copied and pasted your code and I still get the same error message.

"Halscript error on line 1816 col. 0:Type mismatch: 'WC'

'Function Count Words (CW)
Line 1816 CW = WC(UserSentence)

'Custom Relavence For Universal GetResponse.
'This function tries to match as many words between GetResponse and the OriginalSentence.

For i = 1 To CW

   If i > 0 Then SearchIt = "* " + SearchIt
      SearchIt = Replace(SearchIt, vbCrLf, Chr(8) & " ", 1, - 1, vbTextCompare)
      SearchIt = Replace(SearchIt, "", "", 1, - 1, vbTextCompare)
      SearchIt = Replace(SearchIt, "  ", " ", 1, - 1, vbTextCompare)
   Next

   TemUserSent = OriginalSentence

   For i = 1 To CW

      If i > 0 Then PatternRel = HalBrain.SearchPattern(TemUserSent, SearchIt, i)

          PatternRel = Trim(Ucase(PatternRel))
         PatternRel2 = HalBrain.ExtractKeywords(PatternRel)
         PatternRel3 = HalBrain.AlphaNumericalOnly(PatternRel2)

         HalsResponse = Trim(Ucase(GetResponse))
         KeyHalWord = HalBrain.ExtractKeywords(HalsResponse)
         KeyHalWord2 = HalBrain.AlphaNumericalOnly(KeyHalWord)

         If InStr(1, KeyHalWord2, PatternRel3, vbTextCompare) > 0 Then PattBrainRel = 1 + PattBrainRel Else PattBrainRel = 0
         'Here we use the custom relavence for any Universal GetResponse.
            PatternRelavance = FormatPercent(PattBrainRel/CW)
            'PatternRel uses a Percentage scale to match the GetResponse to a OriginalSentence.
            'The more matches found the higher the PatternRelavance in percentage will be, 100 would
            'be a 100% match, we try to avoid 100% matches because it could be a repeat of the User for the response.
            'We try to maintain a PatternRelavance between 20% and 80% for percentage matches.
            'PatternRelavance finds these percentages by adding the number of matched keywords divided by the number of words
            'in the user's sentence.
         If (PatternRelavance >= "20" And PatternRelavance <= "80") And HalBrain.CheckRepetition(GetResponse, PrevSent) = False Then GetResponse = HalsResponse Else GetResponse = GetResponse & ShortPhrase
   Next
Hollywood

onthecuttingedge2005

  • Guest
Can this be fixed
« Reply #4 on: January 21, 2007, 06:04:53 pm »
quote:
Originally posted by Holllywood

Jerry, I unchecked all plugins. It is the "Custom Rel..." I copied and pasted your code and I still get the same error message.

"Halscript error on line 1816 col. 0:Type mismatch: 'WC'

'Function Count Words (CW)
Line 1816 CW = WC(UserSentence)

'Custom Relavence For Universal GetResponse.
'This function tries to match as many words between GetResponse and the OriginalSentence.

For i = 1 To CW

   If i > 0 Then SearchIt = "* " + SearchIt
      SearchIt = Replace(SearchIt, vbCrLf, Chr(8) & " ", 1, - 1, vbTextCompare)
      SearchIt = Replace(SearchIt, "", "", 1, - 1, vbTextCompare)
      SearchIt = Replace(SearchIt, "  ", " ", 1, - 1, vbTextCompare)
   Next

   TemUserSent = OriginalSentence

   For i = 1 To CW

      If i > 0 Then PatternRel = HalBrain.SearchPattern(TemUserSent, SearchIt, i)

          PatternRel = Trim(Ucase(PatternRel))
         PatternRel2 = HalBrain.ExtractKeywords(PatternRel)
         PatternRel3 = HalBrain.AlphaNumericalOnly(PatternRel2)

         HalsResponse = Trim(Ucase(GetResponse))
         KeyHalWord = HalBrain.ExtractKeywords(HalsResponse)
         KeyHalWord2 = HalBrain.AlphaNumericalOnly(KeyHalWord)

         If InStr(1, KeyHalWord2, PatternRel3, vbTextCompare) > 0 Then PattBrainRel = 1 + PattBrainRel Else PattBrainRel = 0
         'Here we use the custom relavence for any Universal GetResponse.
            PatternRelavance = FormatPercent(PattBrainRel/CW)
            'PatternRel uses a Percentage scale to match the GetResponse to a OriginalSentence.
            'The more matches found the higher the PatternRelavance in percentage will be, 100 would
            'be a 100% match, we try to avoid 100% matches because it could be a repeat of the User for the response.
            'We try to maintain a PatternRelavance between 20% and 80% for percentage matches.
            'PatternRelavance finds these percentages by adding the number of matched keywords divided by the number of words
            'in the user's sentence.
         If (PatternRelavance >= "20" And PatternRelavance <= "80") And HalBrain.CheckRepetition(GetResponse, PrevSent) = False Then GetResponse = HalsResponse Else GetResponse = GetResponse & ShortPhrase
   Next




Hi Holllywood.

Could you send me the brain you are using and the HalScript.dbg to my e-mail address and I will run it on my system to see if I can get the same error.

I also modified the functions in the above script a bit from my prior posting, see if that makes a difference, copy and paste the code over the code inside the ALF's Custom Relevence plugin.

I changed the WC to WCF to see if some other variable has the same name as this function within your brain.

Jerry[8D]
« Last Edit: January 21, 2007, 06:12:04 pm by onthecuttingedge2005 »

Bill819

  • Hero Member
  • *****
  • Posts: 1483
    • View Profile
Can this be fixed
« Reply #5 on: January 21, 2007, 06:31:12 pm »
Hollywood
I may be mistaken but the answer to your problem appears to be right in front of your eyes. The red line number shows CW = WC .....
The error message says that the WC is not right. That would mean that one or the other is wrong. Try changing the WC to CW or if that does not work try changing the CW to WC.
I could be wrong but it looks like that is what the programs error message is pointing out.
Bill819