Author Topic: [v1.5.12.31] "{TXTSUBSTR}" crashes VoiceAttack when Length is negative  (Read 3958 times)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
If the "{TXTSUBSTR}" token is given a negative Length, E.G. "{TXTSUBSTR:"Test":0:-1}" and used to write to the log, the command will run indefinitely and not produce output(the only indication it's running is a "Commands Running" warning when closing the "Edit a Profile" window).

However, if this same token is used to set a variable, E.G.
Code: [Select]
Set integer [Crash] value to the converted value of {TXTSUBSTR:"Test":0:-1}
VoiceAttack will freeze and run at 100% CPU(single core).


This does not occur when the start position is negative, nor does "{TXTPOS}" have the same issue. Perhaps a forgotten check on the last parameter of "{TXTSUBSTR}"?
« Last Edit: November 05, 2016, 07:52:39 PM by Pfeil »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: [v1.5.12.31] "{TXTSUBSTR}" crashes VoiceAttack when Lenght is negative
« Reply #1 on: October 31, 2016, 09:09:32 AM »
Thanks for the heads-up.  I just got back from travelling, so I will take a look at this later this evening.

I threw this together for Jerry before I left town so he would have something to work with.  Hope that's the only thing holding it up ;)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: [v1.5.12.31] "{TXTSUBSTR}" crashes VoiceAttack when Lenght is negative
« Reply #2 on: November 05, 2016, 07:52:18 PM »
The crash no longer occurs. Solved.

One thing to note is that a negative value will be treated as 0.
For the "Begin" parameter, this means it will return from the start of the string onward.
However, when the "Length" parameter is set to a negative number, it will result in blank output.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: [v1.5.12.31] "{TXTSUBSTR}" crashes VoiceAttack when Length is negative
« Reply #3 on: November 05, 2016, 08:04:17 PM »
Also 0 (length).

It's probably not going to happen that often, but I didn't want it to crash.

So, maybe if either is negative, the result is empty.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: [v1.5.12.31] "{TXTSUBSTR}" crashes VoiceAttack when Length is negative
« Reply #4 on: November 05, 2016, 08:21:05 PM »
So, maybe if either is negative, the result is empty.
That would allow a user to include a check, where a blank is a likely error in a previous action, and throw a warning in the log. Makes sense.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: [v1.5.12.31] "{TXTSUBSTR}" crashes VoiceAttack when Length is negative
« Reply #5 on: November 05, 2016, 10:41:11 PM »
Done.