Author Topic: User Variables in the Brain  (Read 4441 times)

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
User Variables in the Brain
« on: April 17, 2008, 09:09:58 pm »
When making brain edits or plugins for the brain, the user will need a method of storing some variable values.  From what I've read on the forum, this is done with CUSTOMMEM and CUTOMMEM2 using the EncodeVar() and DecodeVar() functions.  The post that I found this info in was dated 10/02/2003 and it said that there were problems with losing variable types, a boolean would come back as a string, etc.  I did a search for CUSTOMMEM but didn't see anything about it being fixed or a better way.  
My questions is, has this problem been resolved?  Is there another, maybe better way to store user variables?  I could save them out to a user created INI file or something similar, but that would be slower and I wanted to see what all you other programmers were doing that might be better?
Austin, Texas, USA, Earth

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
User Variables in the Brain
« Reply #1 on: April 17, 2008, 09:25:25 pm »
Hey Jake... how about creating a area in the database to hold your user variables?

Wow! Jake, that's a great idea!  Do you know the piece of code that will do that?

Sorry Jake, I do not, but I'll research it and get back to you.

Thanks, Jake!  And while I'm waiting on you, maybe someone else has the piece of code... that would be k00l, I'm already bothering you way too often anyway.

Austin, Texas, USA, Earth

TechSteele

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
User Variables in the Brain
« Reply #2 on: April 18, 2008, 02:32:36 pm »
I just had a chance to read the newer posts.

It may help if we had an idea of what you wanted to file/table to the brain.
If they are variables that will change all the time, and need to be called/changed on the fly during a convo, that may be above me.

If you just want to create a table for recall of static info, thats not as hard.
 

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
User Variables in the Brain
« Reply #3 on: April 21, 2008, 04:58:47 pm »
The table was for holding variables that would be changing all the time.  I pretty much have worked it out except I'm running into the "3 pass" problem that I ran into before.  The "3 pass" problem is a problem that I've run into in my scripting of UltraHal's brain that I've posted about before where every time I press ENTER to enter my conversation to UltraHal, whatever code I've written gets executed 3 times.  I haven't totally figured this one out yet and no one has explained it to me, but I have found some work-arounds that are working for now.
Austin, Texas, USA, Earth

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
User Variables in the Brain
« Reply #4 on: April 28, 2008, 01:16:51 am »
I posted the following in another topic, but it also resolves this topic, so I'm copying it here...

OK... I got it working by storing a SKIP value in a table, allowing the script to run for SKIP1, but doing an "Exit Function" for SKIP2 and SKIP3.

It works, but it sure is messy.

I'm holding out for a better possible answer from Robert. I sent him an email tonight asking him to take a look at this thread if he had time and try to put me on the right path if there is one.

In case anyone is interested in the messy code, here it is...


Keep in mind that I edited the brain to put PLUGINAREA2 just below
the 1st Function line, the UltraHal Function that starts...
"Function UltraHal(ByVal InputString,"
So that my PLUGIN2 starts before anything happens.
Here's the section of my plugin that does the SKIP...



'------------------
Rem PLUGIN: PLUGINAREA2
'The comment above tells Ultra Hal Assistant to insert the following code
'on-the-fly into the main brain code in the section referenced.
'------------------

'create skipit if needed-----------------------------------------------------
If HalBrain.TopicSearch("skipit", "ja1_vars") = "" Then
HalBrain.ReadOnlyMode = false
HalBrain.AddToTable "ja1_vars", "TopicSearch", "skipit", "skip1"
End If
-----------------------------------------------------------------------------


'skip code-------------------------------------------------------------------
HalBrain.ReadOnlyMode = false
ja1_skipit = HalBrain.TopicSearch("skipit", "ja1_vars")
'MsgBox "ja1_skipit = -" & ja1_skipit & "-"
'------------------
If ja1_skipit = "skip1" Then
ja1_skipit = "skip2"
HalBrain.ReadOnlyMode = false
HalBrain.RunQuery "UPDATE ja1_vars SET topic = """ & ja1_skipit & """ WHERE searchString = 'skipit'", ja1_tempVal
ja1_skipit = ""
End If
'------------------
If ja1_skipit = "skip2" Then
ja1_skipit = "skip3"
HalBrain.ReadOnlyMode = false
HalBrain.RunQuery "UPDATE ja1_vars SET topic = """ & ja1_skipit & """ WHERE searchString = 'skipit'", ja1_tempVal
ja1_skipit = ""
Exit Function
End If
'------------------
If ja1_skipit = "skip3" Then
ja1_skipit = "skip1"
HalBrain.ReadOnlyMode = false
HalBrain.RunQuery "UPDATE ja1_vars SET topic = """ & ja1_skipit & """ WHERE searchString = 'skipit'", ja1_tempVal
ja1_skipit = ""
Exit Function
End If
'----------------------------------------------------------------------------
Austin, Texas, USA, Earth

ramccoid

  • Sr. Member
  • ****
  • Posts: 321
    • View Profile
    • http://www.visualillustrations.co.uk
User Variables in the Brain
« Reply #5 on: April 28, 2008, 01:28:25 am »
Hi Jake,

Try this link, you might find it useful.

http://www.artificialintel.org/AI/Forum/phpBB3/viewtopic.php?f=9&t=72&p=210#p210

Hope it helps,

Roy.
 

Jake

  • Full Member
  • ***
  • Posts: 146
    • View Profile
    • http://Ainsworth.net
User Variables in the Brain
« Reply #6 on: May 03, 2008, 02:26:04 am »
Thanks for the reply and link, ramccoid.  I created an account on that site and will check it out.
Austin, Texas, USA, Earth