| VoiceXML 2.1 Development Guide | Home | Frameset Home |
|
<var name="_MyVar"/>
<var name="MyVar$"/>
<var name="My.Var"/>
<var name="My-Var"/>
<var name="MyVar" expr="'Eat Canned Ham'"/>
<log expr="MyVar"/>
<form id="F1">
<block>
<assign name="MyVar" expr="'four twenty'"/>
<prompt> hey, its <value expr="MyVar"/> </prompt>
</block>
<form id="F1">
<block>
<var name="MyVar"/>
<assign name="MyVar" expr="'four twenty'"/>
<prompt> hey, its <value expr="MyVar"/> </prompt>
</block>
| ANNOTATIONS: EXISTING POSTS |
pipn
|
|
| How can I append data to a variable?
As an example, in C# it would be something like: Var1 = "Hello"; Var1 = Var1 + " World!"; Results: "Hello World!" I am trying to do something similar with variables. I have two forms with condition logic. Form1 saves a value to a variable called UpdateText. Then I need Form2 to append a value to the already existing data in the variable UpdateText. --Form1 <assign name="UpdateText" expr="Hello"> --Form2 <assign name="UpdateText" expr=UpdateText + " World!"> I know that is the wrong syntax but how would I accomplish this? Thanks |
|
Michael.Book
|
|
| Hello All,
The 'expr' attribute value is an ECMAScript expression, so you would use something like: __________________ --Form1 <assign name="UpdateText" expr="'Hello'"> --Form2 <assign name="UpdateText" expr="UpdateText + ' World!'"> __________________ The single quotes here denote a string value. Without single quotes references an existing variable. I hope this helps... Have Fun, ~ Michael |
|
pipn
|
|
| Thanks Michael that fixed it. Another problem I ran in to is trying to pass a variable as a grammar.
As an example, asking the user for their access word to continue. Before asking them I would query a database to get their access word and pass it to a variable. I tried putting the variable in the grammar check but it keeps failing. <grammar type="text/gsl"> [(<value expr="AccessWord"/>)] </grammar> |
|
MattHenry
|
|
|
Hi there, To be clear, using VXML variable syntax inside of a grammar is entirely disallowed. I might suggest that you review our tutorial on dynamic grammars to get an idea on how you can isert DB values dynamically into a grammar file: http://docs.voxeo.com/voicexml/2.0/t_16.htm ~Matt |
| login |
|