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

if/else value reset
 
 

if/else value reset..
i don’t know what reason

this code.

topic: ~MONGOCOUNSELOR keep repeat [WSMSG:OPEN]

t: (WSMSG:OPEN _*1) ^keep()
$cust=‘_0

$$jsonobject=^jsoncreate(object)

if (^mongoinit(mongodb://localhost:27017 test articles)) {}
else {init failed - $$mongo_error}

if (^mongofinddocument($cust)) {

$mongodata=^mongofinddocument($cust)
$$jsonstring = ^jsonparse($mongodata)
$$custname = ^jsonpath(.name $$jsonstring)
$$custphone = ^jsonpath(.phone $$jsonstring)
$$custaddr = ^jsonpath(.addr $$jsonstring )
^mongoclose()

^jsonobjectinsert($$jsonobject name $custname)
^jsonobjectinsert($$jsonobject phone $custphone)
^jsonobjectinsert($$jsonobject addr $custaddr)

^mongoinit(mongodb://localhost:27017 test buy)

$mongodata=^mongofinddocument($cust)
$$jsonstring = ^jsonparse($mongodata)
$$product1 = ^jsonpath(.product1 $$jsonstring )
$$product2 = ^jsonpath(.product2 $$jsonstring )
^mongoclose()

# name: $$custname /phone: $$custphone /addr: $$custaddr /product1: $$product1 /product2: $$product2 ////

^jsonobjectinsert($$jsonobject product1 $product1)
^jsonobjectinsert($$jsonobject product2 $product2)

}
else
{^mongoclose()}

if ($$custname) {

$$custname hello. your product is ^join($$product1 ?)
name: $$custname /phone: $$custphone /addr: $$custaddr /product1: $$product1 /product2: $$product2 ////

}
else{

hello. what is your name?
name: $$custname /phone: $$custphone /addr: $$custaddr /product1: $$product1 /product2: $$product2 ////
}

a:(~no)your product is ^join($$product2 ?)
  name: $$custname /phone: $$custphone /addr: $$custaddr /product1: $$product1 /product2: $$product2 ////

Image Attachments
ifelsevalueresetcode실행.jpg
 

 
  [ # 1 ]

$$ fix to $

 

 
  [ # 2 ]

I dont understand what your question is.

 

 
  [ # 3 ]
Bruce Wilcox - Oct 23, 2016:

I dont understand what your question is.

i try rejoinders put in to if/else..

is it wrong?

 

 
  [ # 4 ]

Rejoinders are independent rules (hence they are not put inside of if/else, nor did you).
But $$variables ONLY have meaning during the current volley. They are not preserved across volleys. Only single dollar variables are.  So a rejoinder like this:
a:(~no)your product is ^join($$product2 ?)

will NOT have $$product2 defined. Would have to be $product2

 

 
  [ # 5 ]
Bruce Wilcox - Oct 24, 2016:

Rejoinders are independent rules (hence they are not put inside of if/else, nor did you).
But $$variables ONLY have meaning during the current volley. They are not preserved across volleys. Only single dollar variables are.  So a rejoinder like this:
a:(~no)your product is ^join($$product2 ?)

will NOT have $$product2 defined. Would have to be $product2

I appreciate your support.

 

 
  login or register to react
‹‹ jsonobject to string      if/else in rules ››