Jump to content


< Back to Forum


 

Script Modules


  • Please log in to reply

#1 ThaoHuynh 11 July 2017 - 07:31 PM

Hi VG Team,

 

I would like to use response result from web service.

 

ie:   If result = 'a' 

             run module 'Say Card Number'

       else

             run module 'Enter Card Number'

How can i do that?

 

Thank you for your support.



#2 SupportTeam 11 July 2017 - 08:07 PM

Use an Evaluate Expression module.

 

The Web Service module will create a number of Result Variables ($RVs). Best to look at vgEngine trace to see what these are. 

If you know the exact XML or JSON that the Web Service returns then you can deduce what $RVs are created, but best/easiest to just look in vgEngine trace after running a call to the Web Service.

 

Use the Evaluate Expression module to evaluate the $RV that you want to check the value of, and then set paths that match each value.

 

Say your Web Service module creates this $RV (amongst many others) :

 

$RV[MyWS_Report_Mode]

 

and the above $RV can have values aaaa or bbbb or something else.

 

then you would use this as expression to evaluate in the Evaluate Expression module (notice the quotes):

 

"$RV[MyWS_Report_Mode]"

 

and the paths would be:

 

on {aaaa} goto [Say Card Number]

on {bbbb} goto [SomeModuleB]

on {True} goto [Enter Card Number]



#3 ThaoHuynh 11 July 2017 - 09:01 PM

Thank you so much.

 

I also have a issue in script module. Can VoiceGuide speak 3 random digits?



#4 SupportTeam 11 July 2017 - 09:41 PM

Use an 'Evaluate Expression' type module to evaluate this expression:

 

100 + Int(900*Rnd)

 

this will result in random number between 100 and 999.

 

The random number will be saved in $RV with the same name as the title of the Evaluate Expression module.

 

The $RV can then be used in a 'Say Numbers' type module to speak out the digits.

 

Use a Success or True path to go from the 'Evaluate Expression' type module to the 'Say Numbers' type module.

 

 

see vgEngine trace excerpt of a script doing this:

 

'Evaluate Expression' module was titled: GenerateSomeRnd

 

It created $RV[GenerateSomeRnd] that held the random number value, and the $RV[GenerateSomeRnd] was then played out by the Say Numbers module:

213304.349  11   5   1 state [GenerateSomeRnd] Evaluate [100 + Int(900*Rnd)]
213304.349  11   5   1       eval  [100 + Int(900*Rnd)]
213304.349  11   5   1       eval  InvokeMember Eval returned
213304.349  11   5   1       rvns  add   GenerateSomeRnd_Input|100 + Int(900*Rnd)
213304.349  11   5   1       rvns  add   GenerateSomeRnd|621
213304.349  11   5   1       Eval Expr result:[621]
213304.349  11   5   1       path {621} not found
213304.349  11   5   1       matching path not found [621], try boolean paths.
213304.349  11   5   1       ex: ScriptIo.VGMTYPE_EVALEXPR [621] could not be converted to boolean. Take Success path as string non-empty.
213304.349  11   5   1       FindNextVgmTitleInPathList: next module title is=[SayRnd]
213304.349  11   5   1       matching path found (Boolean True)
213304.349  11   5   1 t     timer clear (force=False)
213304.349  11   5   1       RunModule start
213304.349  11   5   1       RunModule start Say Numbers, [SayRnd], iModuleIdx=62, previous: vgm=61, vgs=2:2
213304.349  11   5   1       rv    replace start [$RV[GenerateSomeRnd]]
213304.349  11   5   1       rv    replace end   [621]
213304.349  11   5   1 state [SayRnd] Say Numbers: 621 as Digits


#5 SupportTeam 11 July 2017 - 09:49 PM

Also see attached screenshot :

  • script_rrnd.gif
  • script_rrnd_2.gif


#6 ThaoHuynh 12 July 2017 - 12:13 PM

Thank you so so so much.