AI Zone Admin Forum Add your forum
when is %inputrejoinder set?
 
 

the System Variable manual says:

%inputrejoinder rule tag of any pending rejoinder for input or 0 if none

In my control script I have:

$$_rejoinderToRetry = %inputrejoinder;
 ^
log(FILE TMP/mylog.txt rejoinderToTry = %inputrejoinder \n)
 ^
log(FILE TMP/mylog.txt output rejoinder = %outputrejoinder \n)

 if ( %
response == $_responseCount {nofail(TOPIC ^rejoinder())# try for rejoinders. might generate an answer directly from what we are looking for.
 
^log(FILE TMP/mylog.txt 2rejoinderToTry = %inputrejoinder \n)
 ^
log(FILE TMP/mylog.txt 2output rejoinder = %outputrejoinder \n)

 if (%
response == $_responseCount){
  
# if rejoinder doesn't match then do error handling
  
if( $$_rejoinderToRetry != 0){
   
^log(FILE TMP/mylog.txt we are going to re-ask the question a few times\n)
   ^
log(FILE TMP/mylog.txt rejoinder count is $_rejoinderRetryCount \n

the log file shows:

rejoinderToTry =
output rejoinder =
2rejoinderToTry =
2output rejoinder =
we are going to re-ask the question a few times
rejoinder count is

my questions are:
1) when does the %inputrejoinder variable get set and why doesn’t it show 0 if it is not set?
2) how can I get the tag of the rejoinder that didn’t match so that I can call ^reuse() and re-prompt the user for the information I requested?

Thank you for your help.

 

 
  [ # 1 ]

Apologies.  Manual changed to say null (not 0) if not set.  0 is actually the value that would be stored in the users topic file if there was none, not a value you see in script.

Technically, the output rejoinder is set during execution of your script, and is transferred over to become the inputrejoinder when the user is loaded for the next volley. So it’s already there when your script starts running.

Your control script was a reasonable attempt to get the tag, although your code is faulty because there should not be a ;
in $$_rejoinderToRetry = %inputrejoinder;

If you did :trace all on your prior volley, it would tell you in the trace if the output rejoinder had been set OR you could look at the resulting user topic file after your prior volley: This line: 1 1 0 DY 0 2053 2053 0 # start, input#, no rejoinder, #0topics, #1topics, layer2     says in the comment that no rejoinder is set.

 

 
  [ # 2 ]

Thanks for the fast reply Bruce.

Testing for existence on the variable works like a charm, thanks. I am seeing the %nputrejoinder set when there are rejoinders. I am seeing ~member2.1  as the value. What I want to do is set up a generalized way repeat the prompt ($MaxRetries) when I don’t get a response from the user the bot can use. In the actual rule, I can put in

tQUESTION () what is your group number?
    
aVALID (_~numberthank you
               $groupnumber 
_0
               
^reuse(ORIGNINAL_REQUEST#got what we want so keep processing.
    
aTRY_AGAIN () I am not sure what that means\n
           
^retry(TOPRULE

and it repeats the question and things are good.

I want to put in a general mechanism in the controller to behave this way by default.

When I tried using ^retry(TOPRULE) in the controller, I end up in a loop. My guess is because it is retrying the rule on the conroller instead of ~member.2.  I tried using ^reuse($_originalRejoinder) but that of course, doesn’t repeat the original prompt. Is there a way to get the next level up from %inputrejoinder? Are there any string manipulation function where I can strip off the last level so I call ^reuse( ~member.2) instead of ^reuse(~member.2.1)

 

 

 
  [ # 3 ]

^extract,  ^findtext

~member.2.1,  the 2nd .n is the rejoinder index.  If all of your initial questions are top level, you can just strip that off to do ^reuse(~member.2)

 

 
  [ # 4 ]

Bruce,

As I was trying your suggestion, I ran into a problem on stripping off the last dot and number.

it seems that ^length doesn’t like variables as a parameter.

^log(FILE TMP/mylog.txt calling length on system var $$_rejoinderToRetry \n)

    $
$remainder = ^length( $$_rejoinderToRetry )
    ^
log(FILE TMP/mylog.txt we never get here... remainder = $$remainder \n)
    $
$remainder -= 2
    
^log(FILE TMP/mylog.txt remainder -= $$remainder \n)
    $
$remainder *= -1
    
^log(FILE TMP/mylog.txt remainder * -= $$remainder \n)

    $
$spawningRule = ^extract($$_rejoinderToRetry -$$remainder)
    ^
log(FILE TMP/mylog.txt going to reuse $$spawningRule  )
    ^
reuse($$spawningRule

the log is showing

calling length on system var ~member.2.1 

and nothing else happens.

If I put a constant string in the ^length() like ^length( “fribble”) the other log things print out.

 

 

 

 
  [ # 5 ]

This thread explains why you can’t use ^length() on the %inputrejoinder value. The length function will think it is looking at a non-existent concept.

The solution is to use ^burst to split the %inputrejoinder into segments at the periods then put them back together (leaving off the last one)

here is some sample code for those that find this thread later on.

@= ^burst( $$_rejoinderToRetry .)
    $
$buildingRule null
    
$$tokencount = ^length(@9) - 2
    
^loop( $$tokencount ){
     
$$curtoken = ^first(@9subject)
     $
$buildingRule = ^join($$buildingRule $$curtoken  .)
    
}
    
# for the last token no period
    
$$curtoken = ^first(@9subject)
    $
$buildingRule = ^join($$buildingRule $$curtoken)
    ^
reuse($$buildingRule
 

 
  login or register to react