dupa

Author Topic: Plugin ERROR?  (Read 3037 times)

Charmzbond

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Plugin ERROR?
« on: March 08, 2006, 12:01:49 am »
I got an error saying the following:

HasScript Error 9 on line 573 in column 9: Subscript out of range: 'i' The file "C:/Document and Settings...HalScript.DBG"
has been saved with the current script being used for debugging
purposes.

I used VBScript Editor to find line 573 (complying to Jerry's suggestion with another user) and here it is:            vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)

Are we supposed to do something with that 'i'? Here's a sample code that contains line 573: If vrMusicMood > 0 Then
   j = Int(Rnd * 10) ' generate a random integer between 0 and 9
   If j < vrMusicMood Then
         vrKeywords = HalBrain.RemoveExtraSpaces(HalBrain.ExtractKeywords(" " & UserSentence & " "))
           vrKeywordList = Split(vrKeywords, " ")
         For i = Ubound(vrKeywordList) To Lbound(vrKeywordList)
           vrNameToPlay = HalBrain.QABrain(vrKeywordList(i), "vrMp3", 0)
             If vrNameToPlay <> "" Then
                  GetResponse = "You talked about " & vrKeywordList(i) & " and this reminds me this song. "
                  HalCommands = HalCommands & "<RUNPROG>" & vrNameToPlay & "</RUNPROG>"
             Exit For
            End If
         Next
    End If
 

GrantNZ

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Plugin ERROR?
« Reply #1 on: March 08, 2006, 06:16:00 am »
I recognise vrossi's coding style there.... (Of course the "vr" in front of all the variable names helps [;)])

Vrossi, if you're watching: Shouldn't the line

  For i = Ubound(vrKeywordList) To Lbound(vrKeywordList)

be

  For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)

[?]

Charmzbond: If Vrossi can't help in the next few days (he may be busy elsewhere) I'll have a go at fixing the plug-in for you - just post me a reminder here in a couple of days [:)]
 

Charmzbond

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
Plugin ERROR?
« Reply #2 on: March 11, 2006, 05:54:08 am »
quote:
Originally posted by GrantNZ

I recognise vrossi's coding style there.... (Of course the "vr" in front of all the variable names helps [;)])

Vrossi, if you're watching: Shouldn't the line

  For i = Ubound(vrKeywordList) To Lbound(vrKeywordList)

be

  For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)

[?]

Charmzbond: If Vrossi can't help in the next few days (he may be busy elsewhere) I'll have a go at fixing the plug-in for you - just post me a reminder here in a couple of days [:)]



Thanks GrantNZ,

I do get that error occasionally...I guess i'll just turn off my mp3
plugin for now :( I tried what you had suggested but it didn't work. Let's hope Vrossi doesn't forget to check in here :)
 

vrossi

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • http://vrconsulting.it
Plugin ERROR?
« Reply #3 on: March 12, 2006, 07:11:31 am »
Hi, Charmzbond,

Sorry for my late answer, but I had a very busy working week, and Sunday is currently the only day I can spend on these subjects.

The code where this error occasionally happens is the one connected to the Music Mood state, where Hal randomly takes the words you say and tries to find some song containing one of those words.

I've tried several times to get your error but it never happens to me. You should take note of your last input, the next time it happens, so I can try to understand the specific situation which generates this error.

However, I have now added a further check, which should avoid passing through that statement, if the variable is not correctly set.

Please download again the MP3 plugin and replace it in your Hal folder.

Anyway, should the problem persist, you may leave the MP3 plugin active, and just turn off the Music Mood function. To do that, go to General Options - Brain - select MP3 and set the Hal Musical Mood Level to "No music". The variable vrMusicMood will be set to zero and all this coding block will never be executed.

Let me know if the fix is working.


Grant, thank you for your help:
 
quote:
Vrossi, if you're watching: Shouldn't the line
For i = Ubound(vrKeywordList) To Lbound(vrKeywordList)
be
For i = Lbound(vrKeywordList) To Ubound(vrKeywordList)



This routine extracts all the keywords from the user input (using the HalBrain.ExtractKeywords function) and stores them in an array called vrKeywordList. Then it reads them, one by one, looking for a match in the MP3 table. Therefore, reading them from the Upper to the Lower or viceversa should not be relevant.
But you are right (as usual): I forgot the "step -1" option, so this might be one possible cause of the error. Another cause of the problem might be in some situation when the user input does not contain any keyword and the array is empty, so the vrKeywordList(i) expression generates a "Subscript out of range" error.

The new version of the plugin should solve these two situations.


However, all this MP3 stuff would need to be extended much more, for example extracting the ID3 tags from each file, instead of just storing the name of the file. This would allow to distinguish author, title, genre, year.

There is also another problem, related to the fact that the HalCommands executes only one command for each Hal cycle. So if you have installed both the MP3 and the Haptek plugins, when you ask for a song by "Yes", Hal will try to run it, but she will also nod (because her answer contains the word "yes"). In this case the Haptek command to nod will be executed and the MediaPlayer will not be launched.


« Last Edit: March 12, 2006, 11:29:50 am by vrossi »

GrantNZ

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Plugin ERROR?
« Reply #4 on: March 12, 2006, 11:56:44 pm »
quote:
Originally posted by vrossi
There is also another problem, related to the fact that the HalCommands executes only one command for each Hal cycle. So if you have installed both the MP3 and the Haptek plugins, when you ask for a song by "Yes", Hal will try to run it, but she will also nod (because her answer contains the word "yes"). In this case the Haptek command to nod will be executed and the MediaPlayer will not be launched.


That's interesting!! Now I know not to have KAOS nod happily when running a program [:)] Thanks for posting that, vrossi! [:)]