Author Topic: parameter containing only spaces is not saved correctly  (Read 3878 times)

0 Members and 1 Guest are viewing this topic.

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
parameter containing only spaces is not saved correctly
« on: April 18, 2014, 01:29:35 AM »
Update: Sorry this should probably be in Command Builder Reference thread, mods please move if possible

I have VC command on VC2v1.9.2.1
When i test it it works via the LCB and testing payloads with save/execute.

I have a command to use a payload dictation of spelling type.  However when the payload gets input, it has trailing spaces which throws my commands off, so
I'm using a results.setlasteresult to record the payload
Then results.replace to strip the spaces via args of 1=(literal space key press), arg2 = default no entry
But I can't get it to save as expected.
Everytime I hit the Save icon and the command doesnt work and I notice in the LCB that the space is no longer in arg1 anymore?
However the  the xml shows a space <param> </param>
Anyone encounter this? Even if though with the test payload, save/execute works is a better alternative for spaces necessary?

I found the log entries below (also of note interesting my log is working, but the Enable Log is unchecked)
4/17/2014 11:08:32 PM   803   doCommand:SendKeyDictate
4/17/2014 11:08:32 PM   803   action repeat set to: 1
4/17/2014 11:08:32 PM   803   Action:  Results.SetLastResult -  n c i s
4/17/2014 11:08:32 PM   803   action repeat set to: 1
4/17/2014 11:08:32 PM   803   Action:  Results.Replace -
4/17/2014 11:08:32 PM   803   unexpected error in action: Results.Replace
System.ArgumentException: String cannot be of zero length.
Parameter name: oldValue
   at System.String.ReplaceInternal(String oldValue, String newValue)
   at System.String.Replace(String oldValue, String newValue)
   at VoxCommando.ResultsVars.actionReplace(String[] allParams)
   at eval_e.eval_ᜂ(macroElement A_0, List`1 A_1)
   at eval_e.eval_ᜁ(macroElement A_0, List`1 A_1)
« Last Edit: April 18, 2014, 02:21:49 AM by vulcanjedi »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Results.replace (space)
« Reply #1 on: April 18, 2014, 07:03:23 AM »
Hi vulcanjedi, can you post the command or group which contain the command?
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Results.replace (space)
« Reply #2 on: April 18, 2014, 08:16:48 AM »
That's an interesting bug discovery, vulcanjedi.

Though I think this will be fixed with the next release, the workaround is to use Results.RegexReplace instead. http://voxcommando.com/mediawiki/index.php?title=Actions#RegExReplace

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.2.1-->
<command id="1164" name="say {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <params>
      <param>\s</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}nospaces</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>say</phrase>
  <payloadDictation>payloadDictation: Spelling</payloadDictation>
</command>

As Kalle says, in the future please post your command so that we can copy/paste it into our trees to make sure there's nothing else going on. Also, sometimes it's difficult to explain in words, and easier for a global audience to understand and diagnose the problem when they can see the actual command.
« Last Edit: April 18, 2014, 08:31:13 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Results.replace (space)
« Reply #3 on: April 18, 2014, 08:49:56 AM »
I don't think you mean trailing spaces.  Trailing spaces would be at the end, and I don't think VoxCommando would generate any when using spelling dictation. It doesn't on mine anyway.

If you do actually mean trailing spaces then the regex pattern would probably need to be

Code: [Select]
\s+$

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: parameter containing only spaces is not saved correctly
« Reply #4 on: April 18, 2014, 07:49:19 PM »
Sorry to clarify when referring to trailing spaces I meant, after each character dictated I get a trailing space, not just after the entire payload.
As seen in my log. Saying 'NCIS' results in a payload of 'N C I S'
I backed up my VCv2 folder and created a new one and reinstalled and still having the same behavior.
Also my log works even though the enable log option remains unchecked.  Also even if just entering
Attached command group via XML as the code insert in the preview still seemed rather large. If people would still prefer inline xml insertion I can certainly oblige.

Here's a webm vid capture to better describe my experience. Sorry first time I tried this native vid cap feature.
The dropbox viewing didnt work so well if you pull it down it plays fine though locally via Chrome. 9MB
https://www.dropbox.com/s/g9t3w5lqwxi0l94/xin7voxBMC-2014-04-18T22-56-50-328390000Z.webm
As you can see  my log works now, without Enable Log checked
And the save behaviour being erratic.
« Last Edit: April 18, 2014, 10:41:28 PM by vulcanjedi »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: parameter containing only spaces is not saved correctly
« Reply #5 on: April 18, 2014, 08:44:55 PM »
We told you the whitespace parameter not saving would probably be fixed in a future version, and gave you a working solution.  Did you try it?  We tried it and it works.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: parameter containing only spaces is not saved correctly
« Reply #6 on: April 18, 2014, 09:05:32 PM »
Thanks for the heads up on the log issue.

With what version of VC are you seeing this log behaviour?

If it was only with the latest release of VC2 then it was a side effect of something I was debugging.  I have since corrected it but did not realize it snuck into the last public release.  If it is on some other version then I am flummoxed.

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re:
« Reply #7 on: April 18, 2014, 10:05:24 PM »
I hadn't tried the workaround yet was simply providing more context of my scenario since you mentioned it wasn't the case for you and I was scared it was simply me or something.  Just trying to be more thorough in case I hadnt been clear. Had to run an errand and can try the work around when get back.  Im on the latest I am aware of v1.9.2.1 VC2

Update: Affirm I am on VC V2, v1.9.2.1
Code: [Select]
\s+$Does not appear to work for me

Code: [Select]
\sWorks for me

Save/Execute works, and save button and Reentering the LCB without making any changes and immediately closing no longer prompts to erroneously save like it was doing.
Thanks for the workaround and feedback as always everyone.
« Last Edit: April 18, 2014, 10:50:51 PM by vulcanjedi »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re:
« Reply #8 on: April 19, 2014, 08:29:29 AM »
Update: Affirm I am on VC V2, v1.9.2.1
Code: [Select]
\s+$Does not appear to work for me

That's correct. That should not have worked for you, because your problem was not actually "trailing spaces" but spaces between each letter. As James originally said, the regular expression that he provided (per above) would specifically solve the problem of trailing spaces.

Quote
Code: [Select]
\sWorks for me

Right. Based on the problem you encountered, this was the solution we suggested you should implement.

Glad it solved your problem.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)