AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Deleting all variables at once?
 
 

Hello,

is there a command that allows us to delete ALL instantiated variables (instantiated as in created during a conversation) at once?

Also, is there an alternative to ^reuse( ~topicname.subtopic ) ?

I cant find these things in the documentation.

 

 
  [ # 1 ]

So you can clear variables that might linger into the next volley

### `^walkvariables ( ‘^function )`
calls the named output macro for every global permanent user variable currently non-null.
The function should have 1 argument, the topic name. It does not involve
$$ or $_ variables, or bot variables.

is there an alternative to ^reuse( ~topicname.subtopic )—- what do you mean?  Why do you want an alternative to the mechanism and what should it do?

 

 
  [ # 2 ]

is there an alternative to ^reuse( ~topicname.subtopic )—- what do you mean?  Why do you want an alternative to the mechanism and what should it do?

I am just afraid there are some side-effects to reuse I don’t know of.
Alright, yesterday I was a little frustrated because things weren’t working my way, hence the question.

Allow me to ask this instead: Does ^reuse( ~topic.subtopic ) work in a linear way? So we shift the conversation by entering a certain subtopic. Does ^reuse, once called have ANY side-effects, anything that affects what topics it goes to next (when not specified by the user)? Or is the sole thing it does just jump to a subtopic when called? (This sounds weird, but I am trying to work out a rather specific problem with my/our chatbot)


As for ^walkvariables, do you have a short example of it could be used? The way I understand it, it does ^walkproperties ( myoutputmacro ) and every $variable (variables like $var) are then printed out, if “myoutputmacro” does that, right?

 

 

 
  [ # 3 ]

^reuse is like a subroutine call. It pays no attention to the pattern on the rule named. It executes the output side of that rule and then returns to its caller. Side effects are whatever you do from that output code. If you invoke other topics then they get invoked. it can set rejoinder data on that invoked rule.

As for walkvariables:  ^walkvariables (’^myoutputmacro) would print out each global permanent variable if that’s what your macro does. It’s easy enough to try it and see.

 

 
  [ # 4 ]

  and then returns to its caller

Say I consider “subtopics” states. I call ^reuse(~topic.subtopicX) in a state “subtopicA” - does that mean that once I am done in whatever is done in subtopicX I go back to “subtopicA”?

 

 
  [ # 5 ]

Your terminology of “substopics is I think what I call rules in a topic.
So as I said, when you call reuse you are current at Rule A and you are asking Rule X to execute it code. It will do that and then return to Rule X to resume.  Eg

u: (are you green)
I am yellow.
^reuse(greenlabel)
I am purple.


u: GREENLABEL (are you red)
    I am as green as the sky.

If you ask “are you green” the output will be “I am yellow. I am as green as the sky. I am purple.”

 

 
  [ # 6 ]

Alright, I’ve got it. So my understanding of reuse was right.

And rule was the word I was looking for.

Thank you

 

 
  [ # 7 ]

Alright, is there any way to make the macro display what variable we have in particular?

So far i have:

outputmacro: ^testvariables($_arg1)
 if(
$_arg1 == $var1{
            var1
$_arg1.
        
}
 else{
  other variable 
$_arg1
 } 

Is there anything I could write so “other variable” actually displays the name of the variable?

 

 
  [ # 8 ]

You are using $_ variable as argument, which is the value of what was passed in (by value call).
You can use ^arg1 which is a read-write (by name call).

outputmacro: ^showit(^var)
‘^var : ^var \n

 

 
  [ # 9 ]

Alright, thank you.

I have one more question.

Say, I have 5 user variables: $var1,$var2, $var3, $var4,$var5

Using ^reset( VARIABLES ) would, according to the documentation, set all 5 of them NULL.

Say, I want to set them NULL except $var1 and $var2. I attempted having $var1 and $var2 as $$var1 and $$var2 instead.

However, ^reset (VARIABLES ) also delted $$var1 and $$var2 although according to the documentation, it is not supposed to do that.

How do I prevent ^reset (VARIABLES) from deleting certain variables, if possible?

The reason why I am trying to do this is because some variables I set null are not set null, others are:

tSETNULLANDREP ($enterEnd50)
    
    
$geschenkidee null  $anwendungszweck null $things null $art null
    $ausfuehrung 
null $preis null $zusammenfassung null
    $kaufbereitschaft 
1-a $introyes 1a $gosearch null $searchcreate null $searchable null $produktname null
    $produkbeschreibung 
null $weitersuchen null $enterEnd2 null $stillhelp null
WALKVARIABLES
: ^walkvariables('^testvariables)
    Resetting values ^reuse( ~kaufabsicht.FIRSTQ ) 

Variables $gosearch, $searchcreate, $searchenable among others are not set null (the first 6 variables are, the rest aren’t, basically).


EDIT: This works:

$_var1tmp $var1
$_var2tmp 
$var1
^resetVARIABLES )
$var1 $_var1tmp
$var2 
$_var2tmp 

Another problem I’ve run into now is:

The bot seems to get “deleted” / “reset” with ^reset( VARIABLES ) as well. Any input I give after ^reset( VARIABLES ) is called results in nothing. The bot does not respond.

 

 
  [ # 10 ]

Alright, I’ve found a solution for the last problem mentioned.
Copied directly:

$_kundetemp $kunde
 $_tabletemp 
$tablename
 $_stdtokentmp 
$stdtoken
 $_cs_tokentmp 
$cs_token
 $_botprompttmp 
$botprompt
 $_userprompttmp 
$userprompt
 $_cs_externaltagtmp 
$cs_externaltag
 $_cs_languagetmp 
$cs_language
 $_cs_control_maintmp 
$cs_control_main
 $_cs_bottmp 
$cs_bot
    
^resetVARIABLES )
 
$kunde $_kundetemp
 $tablename 
$_tabletemp 
 $stdtoken 
$_stdtokentmp
 $cs_token 
$_cs_tokentmp
 $botprompt 
$_botprompttmp
 $userprompt 
$_userprompttmp
 $cs_externaltag 
$_cs_externaltagtmp
 $cs_language 
$_cs_languagetmp
 $cs_control_main 
$_cs_control_maintmp
 $cs_bot 
$_cs_bottmp 
 
# TEST: Deine Tabelle ist $tablename
 # WALKVARIABLES: ^walkvariables('^testvariables)
    
Resetting values ^reuse( ~kaufabsicht.FIRSTQ 

It seems variables that keep the bot running were also with declared with $...

So I had to preserve them as in the way mentioned.  It works.

 

 
  [ # 11 ]

You can also put code inside your macro to reject specific variables

outputmacro: ^testvariables(^variable)

if (’^variable == ‘$mysafevar) {^return()}

I have not tested it but it should be feasible

 

 
  login or register to react