irswat Posted January 22, 2017 Share Posted January 22, 2017 It's some what trivial but when my parser can not find a form that matches any of the words of a voice command, I would like to return null, or a blank form. When I try FormToReturn="", this gives me errors. When I created a blank form called SVCE_BlankForm and try returning FormToReturn=0511F099, this also does not compile.Is there a way to return a blank form, or a null form? Link to comment Share on other sites More sharing options...
irswat Posted January 22, 2017 Author Share Posted January 22, 2017 never mind if I doFormToReturn=Game.GetForm(0x0511F099)which is the blank form I created, it works. Link to comment Share on other sites More sharing options...
lofgren Posted January 22, 2017 Share Posted January 22, 2017 The examples confuse me. Is FormToReturn a string or a hex value? If it's a hex value then obviously you can't return an empty string, and if it is a string then you need to put quotes around your hex value. Link to comment Share on other sites More sharing options...
FrankFamily Posted January 22, 2017 Share Posted January 22, 2017 Couldn't it return none? It's the default value, i.e. null equivalent. that way you don't have to check against the specific blank form to know if it's valid or not, you can just autocast as bool Link to comment Share on other sites More sharing options...
irswat Posted January 22, 2017 Author Share Posted January 22, 2017 counter3=0 MatchingWords=TalleyofMatchingWords[LoopCounter] ListOfMatchingPercentages[LoopCounter]=(((MatchingWords as float/LengthOfCMDItem as float) * 100) as float) while counter3<=FormListSize if ListOfMatchingPercentages[counter3]>tempWinner tempWinner=ListOfMatchingPercentages[counter3] itempWinner=counter3 GreatestMatch=TalleyofMatchingWords[itempWinner] endif counter3+=1 endwhile if OverLoadSwitch=="Weapon" FormToReturn=WeaponFormList.GetAt(itempWinner) MatchFound=true elseif OverLoadSwitch=="Potion" FormToReturn=PotionFormList.GetAt(itempWinner) MatchFound=true elseif OverLoadSwitch=="Armor" FormToReturn=ArmorFormList.GetAt(itempWinner) MatchFound=true elseif OverLoadSwitch=="Spell" FormToReturn=SpellFormList.GetAt(itempWinner) MatchFound=true elseif OverLoadSwitch=="Arrow" FormToReturn=AmmoFormList.GetAt(itempWinner) MatchFound=true endif if GreatestMatch==0 FormToReturn=Game.GetForm(0x0511F099) endif form to return is a form. The problem was I found a bug in the code. it's a voice command engine and the engine was issued a nonsensical command. I thought it was a bug in this code here, and it partially is. What was happening is the function that extracts words from the voice command dump was not resetting the curCMDfromDump variable. So when I issued a command "use frostbite venom", the word "use" goes in curCMDfromDump. This command parsed and executed correctly, but the next cmd was nonsense. It was supposed to be "sheath quick" but windows SAPI thought I said "she's quick". The "use" CMD was still in curCMDfromDump from the previous command "use frostbite venom". Consequently the parser was expecting to find a potion, but the only thing to parse was "use". When no match was found it returned index 0 from the PotionsFormList, which is potion of minor healing. Solution was two parts: reset curCMDfromDump after every loop, and if there are 0 matching words simply return a blank form. hope that makes sense. Link to comment Share on other sites More sharing options...
lofgren Posted January 22, 2017 Share Posted January 22, 2017 So yeah, just return none. That's essentially a blank form. Link to comment Share on other sites More sharing options...
irswat Posted January 22, 2017 Author Share Posted January 22, 2017 I did not know you could return none. in code that's return none ? Link to comment Share on other sites More sharing options...
lofgren Posted January 22, 2017 Share Posted January 22, 2017 Or just formtoreturn = none Link to comment Share on other sites More sharing options...
Recommended Posts