Author Topic: работа с переменными  (Read 3774 times)

0 Members and 1 Guest are viewing this topic.

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
работа с переменными
« on: January 06, 2016, 04:20:13 PM »
как правильно работать с переменными
Прошу помощи
При создании переменной к примеру

Results.SetVar    sheld    4

а дольше требуется следующее

if    (A)<(B)      a= 0                  b={var.sheld}
DxInput.KeyPress     q
Results.SetVar  sheld  = {var.sheld}-1
TTS.Speak {var.sheld}

как правильно сделать вычисление переменной {var.sheld}  а именно  ее уменьшение или увеличение

я уже всю голову сломал.  Я понимаю что этот пример не правильный  и буду благодарен за любую помошь или наводку  в каком направлении искать
зарание благодарю за ответ .


how to work with variables
Please help
When you create a variable for example

Results.SetVar sheld 4

a longer requires the following

if ( A) < (B ) A= 0, B = {var.sheld}
DxInput.KeyPress   q
Results.SetVar sheld = {var.sheld}-1
TTS.Speak {var.sheld}

how to make a calculation of the variable{var.sheld} namely its increase or decrease

I broke the whole head . I understand that this example is not valid and will be grateful for any assistance conditional or tip in what direction to search
Thank you for your response .
« Last Edit: January 06, 2016, 04:31:41 PM by mr.niki »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: работа с переменными
« Reply #1 on: January 06, 2016, 04:50:47 PM »
You need to enable the Python plugin (PY) for calculations.

Here is your example.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.4-->
<command id="129" name="Calculations require the Python plugin" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>sheld</param>
      <param>4</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>0&amp;&amp;{var.sheld}</ifParams>
    <then>
      <action>
        <cmdType>DxInput.KeyPress</cmdType>
        <params>
          <param>q</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>result = {var.sheld} - 1</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Results.SetVar</cmdType>
        <params>
          <param>sheld</param>
          <param>{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>{var.sheld}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
</command>

You can select the code, copy it, and paste it into your command tree.
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)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: работа с переменными
« Reply #2 on: January 06, 2016, 05:02:47 PM »
Is your question: How can I do math?

If so, my response above is complete.

However, if you are trying to understand how to repeat a command 4 times, there is probably a better solution. :)
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)

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Re: работа с переменными
« Reply #3 on: January 06, 2016, 05:06:15 PM »
Я только начинаю в этом разбираться и поэтому прошу вас поподробнее описать всю процедуру
зарание спасибо за помощь. Да интересует именно математическое вычисление

I'm just beginning to understand this , and so I ask you to describe in detail the whole procedure
Thank you in advance for your help ,
Yes, it is interested in the mathematical calculation
« Last Edit: January 06, 2016, 05:08:20 PM by mr.niki »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: работа с переменными
« Reply #4 on: January 06, 2016, 06:01:20 PM »
I'm sorry that I cannot provide the explanation in Russian. Obviously, that would be better.

I hope that automatic translation will be good enough.

VoxCommando does not have any built-in mathematical functions. The Python plugin allows us to create Python scripts to enhance VoxCommando.

For very basic calculations, we can use the VoxCommando "action" PY.ExecString

It is also possible to create complex Python scripts and load them when VoxCommando starts. But that is not what you require here.

In my example, I added one action:

Code: [Select]
PY.ExecString --> result = {var.X} - 1
This is a line of Python code, in which the variable "result" is calculated.

The Python variable "result" is the VoxCommando variable {LastResult}.

So, you can add a Python calculation line, and then set your variable in VoxCommando to be {LastResult}.

---
Yandex says:

Мне жаль, что я не могу предоставить объяснение на русском языке. Очевидно, это было бы лучше.

Я надеюсь, что автоматического перевода будет достаточно хорош.

VoxCommando не имеет каких-либо встроенных математических функций. Питон-плагин позволяет создавать скрипты на языке Python для повышения VoxCommando.

Для очень простых расчетов, мы можем использовать VoxCommando "action" PY.ExecString

Также возможно создавать сложные скрипты Python, и загружать их при VoxCommando начинается. Но это не то, что вы требуете здесь.

В моем примере, я добавил одно "action":
Code: [Select]
PY.ExecString --> result = {var.X} - 1
Это строки из Python-кода, в которой переменная "результат" рассчитывается.

Питон переменной "result" ("результат") является VoxCommando переменной {LastResult} ("Последний результат").

Так, вы можете добавить питона расчет линии, а затем установить переменную в VoxCommando быть {LastResult}.

Вы можете использовать Python для множества {lastresult} ни к чему:

Code: [Select]
result = 44/2
Затем переменная {LastResult} будет равна 22. (Then {LastResult} will be 22.)

etc.

For example, we have commands that make a game of learning multiplication, for children:

Например, у нас есть команды, которые делают игру обучения умножения, для детей:
http://voxcommando.com/forum/index.php?topic=2165.0
« Last Edit: January 06, 2016, 06:03:51 PM 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)

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Re: работа с переменными
« Reply #5 on: January 06, 2016, 06:19:39 PM »
я догодался уже сам благодаря вашему ответу выше   огромное спасибо за ответы и потраченное время

I realized he had because of your answer above thank you for your time and answers

Once again many thanks for the quick response and assistance conditional