Author Topic: Passing Values  (Read 2388 times)

Technomancer

  • Jr. Member
  • **
  • Posts: 98
  • I have a bad feeling about this...
Passing Values
« on: April 27, 2021, 07:23:12 PM »
I'm having a hard time wrapping my brain around Passing Values in Execute Another Command.

Just as an example:  If I put "TEST" in the Text box, how does the executed command use/access it???

For example: How would executed command Say "TEST" with TTS??  {TXT:????}  ?

I'm totally lost.   :o

Thanx

Technomancer

  • Jr. Member
  • **
  • Posts: 98
  • I have a bad feeling about this...
Re: Passing Values
« Reply #1 on: April 27, 2021, 07:36:52 PM »
OK, wth is going on.  I've refreshed like 3 times and Pfiel still hasn't answered my question.

What kinda joint you running here Gary??

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing Parameters
« Reply #2 on: April 27, 2021, 07:37:25 PM »
If you input
Code: [Select]
TESTinto the "Text" field, that would be interpreted as a variable name, and the value of that variable would be copied to and made available within the executed command in the "~passedText1" text variable. If "TEST" is not set, the value of "~passedText1" would then of course also be not set.

If you instead input
Code: [Select]
"TEST"into the "Text" field, that would be interpreted as a literal text value, which is made available within the executed command in the "~passedText1" text variable (I.E. the value stored in "~passedText1" would be "TEST").


Note that these variables are command-scoped, so only the called command (and not any of its subcommands) will be able to access them.
Also, as they are separate variables, they only contains a copy of any data you stored in them, and as such modifying that data within the command will not have any effect on the original data (I.E. any variables whose names you entered, and whose values were copied).

Technomancer

  • Jr. Member
  • **
  • Posts: 98
  • I have a bad feeling about this...
Re: Passing Values
« Reply #3 on: April 27, 2021, 07:42:59 PM »
LOL!!!

You answered at the same time I posted my last comment.

Thanx, you da man!!

This is where I'm stuck.  Is this "~passedText1" literally what I would use to pickup the passed value??? Like {TXT:passedText1}.

Any chance you could lay out a really brief example?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing Values
« Reply #4 on: April 27, 2021, 07:49:51 PM »
"~passedText1" is the name of the text variable containing the first passed text value.

The tilde prefix ("~") denotes that it is a command-scoped variable (see the "Advanced Variable Control (Scope and Events)" section of VoiceAttackHelp.pdf for more information), and must be included when retrieving a passed value (as otherwise you'd be attempting to retrieve the value of a globally-scoped variable named "passedText1", which would be a completely different variable even if it existed).


E.G.
calling command
Code: [Select]
Execute command, 'called command' - passing values (and wait until it completes)
Where the "Text" field contains
Code: [Select]
"this text was passed"
And
called command
Code: [Select]
Write [Blue] '{TXT:~passedText1}' to log


When "calling command" is executed, "called command" would output
Code: [Select]
this text was passedto the log on the main window.

Technomancer

  • Jr. Member
  • **
  • Posts: 98
  • I have a bad feeling about this...
Re: Passing Values
« Reply #5 on: April 27, 2021, 07:59:51 PM »
Awesome!

I remembered something about the "~", but I couldn't remember the context of what I read so i didn't know exactly where to read more.

So, one last question, "~" could be followed by anything, right? Since it's scoped?  It could be {TXT:~sayThis}? or {TXT:~whatToSay}?

Thanx Pfeil!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing Values
« Reply #6 on: April 27, 2021, 08:06:42 PM »
The prefix is part of the variable name, so if you create a variable named "~sayThis", it would be command-scoped, if that's what you're asking.

Passed values always follow the same pattern of "~passed", followed by the datatype (E.G. "Text"), and an index (E.G. 1) that reflects the position of that value within the list it was passed from (E.G. if you pass "value";"another value";"one more value", "~passedText1" would contain "value", "~passedText2" would contain "another value", and "~passedText3" would contain "one more value")


There is a section at the end of this post that attempts to sum up the most essential information regarding variable scope.

Technomancer

  • Jr. Member
  • **
  • Posts: 98
  • I have a bad feeling about this...
Re: Passing Values
« Reply #7 on: April 27, 2021, 10:51:56 PM »
Thanx man!

That post cleared it up.  I just couldn't wrap my head around how to set up the executing command.

I just kept thinking (for some reason) that "~passedTEXT1" was kinda like a generic place-holder that was being used in the manual to replace what I would use at the receiving end, instead of the *actual* variable.  LOL.

Once it made sense, now i read the manual again and smh at myself...    :-[

eavdmeer

  • Newbie
  • *
  • Posts: 2
Re: Passing Values
« Reply #8 on: August 30, 2022, 01:19:30 PM »
Even though this post mostly clears things up, I am unable to pass on something like this: {CMDSEGMENT:1}. It just always receives 'not set':

command 1: say [hello; goodbye]
- Execute command 'speak it' - passing values (and wait for it to complete)
  Passing {CMDSEGMENT:1} through the first (Text) box of passed values

command 2: speak it
- Say 'passed argument is {TXT:~passedText1}'

EDIT: answering my own question: use quotes like this: "{CMDSEGMENT:1}"
« Last Edit: August 31, 2022, 08:14:21 AM by eavdmeer »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing Values
« Reply #9 on: August 30, 2022, 01:23:34 PM »
...did you wrap the token in double quotes, as is mentioned both in the documentation and this topic?

eavdmeer

  • Newbie
  • *
  • Posts: 2
Re: Passing Values
« Reply #10 on: August 31, 2022, 08:16:55 AM »
The quotes are confusing. They are used for literal values. Everywhere else, {CMDSEGMENT:0} is not quoted. Also, in the input field, variables should *not* be quoted. This is a variable. Hence my confusion.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Passing Values
« Reply #11 on: August 31, 2022, 08:19:26 AM »
Tokens are not variables.

Variables and tokens summed up