SupportTeam Report post Posted 04/20/2020 07:17 AM When the data returned to VoiceGuide contains arrays, it is sometimes required for all the values of specific field to be extracted into one Result Variable (RV). Here is the approach that can be used (code is in VBScript): counter = 1 separator = "|" concatenated = "" rv_name = "module_name_returned_path_" & counter & "_field_name" rv_value = vgo.RvGet($RV_LINEID, rv_name) Do While rv_value <> "" If concatenated = "" Then concatenated = rv_value Else concatenated = concatenated & separator & rv_value End If counter = counter + 1 rv_name = "module_name_returned_path_" & counter & "_field_name" rv_value = vgo.RvGet($RV_LINEID, rv_name) Loop vgo.RvSet $RV_LINEID, "AllFieldNameEntries", concatenated vgo.Run_ResultReturn $RV_LINEID, "success" In the above approach all the values from RVs: $RV[module_name_returned_path_X_field_name] will be concatenated into $RV[AllFieldNameEntries] (separated by character assigned to "separator" variable) Share this post Link to post
SupportTeam Report post Posted 04/22/2020 09:16 AM Here is an example demonstrating operation. A short demo VoiceGuide script was created which uses a Web Service module to retrieve a 7 day 'hourly' weather forecast from weather.gov provided web service. The following "Run Script" module then extracts the temperatures from returned data and puts them in a comma separated list. TTS is then used to read out the temperature list. The VoiceGuide Script looks like this: Here is actual script used: test_ws_weather_gov.vgs The Web Service module performs a GET to this address: http://api.weather.gov/gridpoints/OKX/32,34/forecast/hourly (You can click on above link to see the current returned data. The grid-points used correspond to location of New York City) The returned data from weather.gov is: weather.gov_returned_data.txt The above returned data creates $RVs which then allow individual entries from returned JSON to be accessed from other modules in script. The module "Get Temp List" uses this VBScript to access all the temperatures and put them in a list: counter = 1 separator = "," concatenated = "" rv_name = "properties_periods_" & counter & "_temperature" rv_value = vgo.RvGet($RV_LINEID, rv_name) Do While rv_value <> "" If concatenated = "" Then concatenated = rv_value Else concatenated = concatenated & separator & rv_value End If counter = counter + 1 rv_name = "properties_periods_" & counter & "_temperature" rv_value = vgo.RvGet($RV_LINEID, rv_name) Loop vgo.RvSet $RV_LINEID, "AllFieldNameEntries", concatenated vgo.Run_ResultReturn $RV_LINEID, "success" NB. This JavaScript works the same in the "Get Temp List" module: //JavaScript var counter = 1; var separator = ","; var concatenated = ""; rv_name = "properties_periods_" + counter + "_temperature"; rv_value = vgo.RvGet($RV_LINEID, rv_name); while (rv_value != "") { if (concatenated == "") { concatenated = rv_value; } else { concatenated = concatenated + separator + rv_value; } counter = counter + 1; rv_name = "properties_periods_" + counter + "_temperature"; rv_value = vgo.RvGet($RV_LINEID, rv_name); } vgo.RvSet($RV_LINEID, "AllFieldNameEntries", concatenated); vgo.Run_ResultReturn($RV_LINEID, "success"); The list of temperatures is stored by above script in $RV[AllFieldNameEntries] and is then read out using TTS in the "Say Temp List" module. Google Cloud was used as TTS engine in this example, and it completed returning the 2 minute long .WAV file back in 3 seconds: tts_219_1.wav For completeness here is the vgEngine trace capturing the call: weather.gov_vgengine.txt.zip Share this post Link to post