Guest ChrisAC Report post Posted 03/01/2006 07:06 PM Hello, Would someone look at my .vgs script? I can't figure out why I can't get a return value from an RvSet statement. Attached are the script, trace log, temp .vbs, and a test vbs where the value IS returned. Here is a snippet of my code: 'Script : Answer and Record.vgs 'Module : RecordCall? 'Description: Y/N MsgBox to ask whether to record conversation. 'Already chose to answer this call via previous module ValidIDAlert or InvalidIDAlert set vg = CreateObject("VoiceGuide.CommandLink") if msgbox("Record Conversation ?", vbYesNo + vbQuestion + vbDefaultButton2, "Record ?") = vbYes then vg.RvSet $RV_LINEID, "tRecord", "Record" 'msgbox "Record Option was $RV[tRecord]" 'NOT returning value in VBS vg.Run_ResultReturn $RV_DEVICEID, "yes" else vg.RvSet $RV_LINEID, "tRecord", "NoRecord" 'msgbox "Record Option was $RV[tRecord]" 'NOT returning value in VBS vg.Run_ResultReturn $RV_DEVICEID, "no" end if 'Add this to Call log even if I decide to answer the call myself Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 set fso = CreateObject("Scripting.FileSystemObject") set tsFile = fso.OpenTextFile("C:\VGCallLog.csv", ForAppending, True) msgbox "Record Option was $RV[tRecord]" 'This Does NOT return a value msgbox "Record Option was " & "$RV[tRecord]" 'This also Does NOT return a value tsFile.WriteLine "$RV_STARTTIME,$RV_CALLLENGTH,$RV[tLineName],$RV_CIDNUMBER,$RV[tNumber],$RV[tCompany],$RV[tRecord]" 'above csv file leaves the column for tRecord empty tsFile.Close set tsFile = Nothing set fso = Nothing set vg = Nothing The correct value does show up in the trace log . . . 134359.73 0 cl RvSet tRecord, NoRecord 134359.73 0 rv lg add [tRecord]{NoRecord} 134359.73 0 cl Run_ResultReturn >>no<< 134359.73 0 rv lg add [RecordCall?_ResultReturn]{no} 134359.73 0 cl module's runwait=1, WavPlayHasNowFinished=0 . . .but not in anything else. Is my logic incorrect? The module works fine except for the $RV[tRecord] value. Thanks, Chris TraceLog_and_Support_Files.zip Share this post Link to post
SupportTeam Report post Posted 03/01/2006 09:09 PM The $RV[myRvName] placeholders are processed and replaced with the RV values before the VBScript is ran. So you cannot set the RV in the VBScript using .RvSet() and then use a placeholder $RV[myRvName] to access the RV in the same script. The $RV[myRvName] is not defined at time of placeholder replacement, so the placeholder will be replaced by an empty string. You still may use RvGet, but there is no need really... you already have the value available to you in the script - you've jsut used it in the RvSet call... so there is no need to use an RV to access tha value anyway... Share this post Link to post
Guest ChrisAC Report post Posted 03/01/2006 10:13 PM The $RV[myRvName] placeholders are processed and replaced with the RV values before the VBScript is ran. I see. My RvSet value isn't being assigned until midway through the vbScript. You still may use RvGet, but there is no need really... you already have the value available to you in the script - you've just used it in the RvSet call... so there is no need to use an RV to access tha value anyway... I need to write that value into the log file. The value is dependent on whether I answer yes or no in the message box. tsFile.WriteLine "$RV_STARTTIME,$RV_CALLLENGTH,$RV[tLineName],$RV_CIDNUMBER,$RV[tNumber],$RV[tCompany],$RV[tRecord]" Are you saying that this line should not be in the same module? . . . Or are you saying I should use a different syntax of writing $RV[tRecord] into the log file? Sorry if this is a dumb question, I'm picking up the vbs scripting pretty quick, but it took several days of trial & error to get correct results from RvSet, RvSet_RvList, RvGet objects. Still, the learning part is quite exciting. Share this post Link to post
SupportTeam Report post Posted 03/01/2006 10:32 PM Store the value you are assigning to $RV[tRecord] in another varaible and just use that variable when creating your string to save in log file.... Something like this (changed lines in bold) 'Script : Answer and Record.vgs 'Module : RecordCall? 'Description: Y/N MsgBox to ask whether to record conversation. 'Already chose to answer this call via previous module ValidIDAlert or InvalidIDAlert set vg = CreateObject("VoiceGuide.CommandLink") if msgbox("Record Conversation ?", vbYesNo + vbQuestion + vbDefaultButton2, "Record ?") = vbYes then sActionToTake = "Record" vg.RvSet $RV_LINEID, "tRecord", sActionToTake vg.Run_ResultReturn $RV_DEVICEID, "yes" else sActionToTake = "NoRecord" vg.RvSet $RV_LINEID, "tRecord", sActionToTake vg.Run_ResultReturn $RV_DEVICEID, "no" end if 'Add this to Call log even if I decide to answer the call myself Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 set fso = CreateObject("Scripting.FileSystemObject") set tsFile = fso.OpenTextFile("C:\VGCallLog.csv", ForAppending, True) msgbox "Record Option was " & sActionToTake tsFile.WriteLine "$RV_STARTTIME,$RV_CALLLENGTH,$RV[tLineName],$RV_CIDNUMBER,$RV[tNumber],$RV[tCompany]," & sActionToTake 'above csv file leaves the column for tRecord empty tsFile.Close set tsFile = Nothing set fso = Nothing set vg = Nothing Share this post Link to post
Guest ChrisAC Report post Posted 03/02/2006 04:10 PM Well, that sure solved the problem! It sounds so simple when you say it. Thanks for taking the time to actually write the lines, I really appreciate it. I'm mostly learning by following examples. I just learned two things: sActionToTake = "Record" vg.RvSet $RV_LINEID, "tRecord", sActionToTake . . . tells me to try using an assigned variable in some cases to RvSet if I am having trouble with a particular RV. tsFile.WriteLine "$RV_STARTTIME,$RV_CALLLENGTH,$RV[tLineName],$RV_CIDNUMBER,$RV[tNumber],$RV[tCompany]," & sActionToTake . . . was having some troubles in the past using variables writing out to a file (mostly just syntax). This helps alot. Your help file also has plenty of examples, including good links to vbs functions. That's where I'm going now. . . . Thanks again, Chris Share this post Link to post