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..

Static variables for each topic.
 
 

Hi, I want to retrieve some information specific from each topic without executing the topic.
So that I can, based on the topic name e.g. define a timeout for each topic.

I have a seperated .top file for each topic, so I want to define it in there and not in a central place.

Is this possible to do?

 

 
  [ # 1 ]

It sounds like you want to create a pre-initialized global variable for a topic, something like ~pets_timeout.
You can use a table for this. Since you want to do this presumably for a bunch of topics, create a tablemacro and then at the top of each topic file you care about, just put the table macro and pass as argument the topic name sans ~, then the table has the values for initializing and the table code joins your topic name and planned rest of name, like _timeout and assigns the value. This all runs at build time

 

 
  [ # 2 ]
Bruce Wilcox - Nov 9, 2016:

It sounds like you want to create a pre-initialized global variable for a topic, something like ~pets_timeout.
You can use a table for this. Since you want to do this presumably for a bunch of topics, create a tablemacro and then at the top of each topic file you care about, just put the table macro and pass as argument the topic name sans ~, then the table has the values for initializing and the table code joins your topic name and planned rest of name, like _timeout and assigns the value. This all runs at build time

Alright, from what I understood I tried the following:

tablemacro: ^setTopicDefaults(^topic ^timeout)
 
$varTimeout = ^join(\$ ^topic _timeout)
 ^
$varTimeout = ^timeout 

table
: ^setTopicDefaults()
pets 10 

But both $varTimeout and $pets_timeout are null at runtime.

What am I doing wrong here?

 

 
  [ # 3 ]

Sorry. Tablemacros are good for building facts but the variables are not saved as part of the main system. A boot topic would create permanent variables, but then it’s not all neatly spread out over your files it’s all in one place.
If you built these as facts in the tablemacro, then you could look up the data when you needed it.

 

 
  [ # 4 ]
Bruce Wilcox - Dec 19, 2016:

Sorry. Tablemacros are good for building facts but the variables are not saved as part of the main system. A boot topic would create permanent variables, but then it’s not all neatly spread out over your files it’s all in one place.
If you built these as facts in the tablemacro, then you could look up the data when you needed it.

I tried

tablemacro: ^setTopicDefaults(^topic ^timeout)
^
createfact(^topic timeout ^timeout)

table: ^setTopicDefaults()
pets 5 


and

u: (tabletest)
 @
= ^query(sv pets timeout)
 
timeout:  @2object 

But the output is:

timeout:

 

 
  [ # 5 ]

@2 = ^query(direct_sv pets timeout ?)

Or
^query(direct_sv pets timeout ? 1 ? @2object)

 

 
  login or register to react