Asked — Edited
Resolved Resolved by ptp!

Configuration Form When Creating A Plugin

I have went thru the tutorial for the plugin and have successfully created a basic plugin. Now I want to go the next step and create a plugin that has a configuration page that is accessed by clicking the gear icon but can not figure out how to do it.

The plugin I hope to create will allow the user to create a connection to a database using a DSN.

RichardZ

Update: One Step Closer - I found the UCConfigurationButton

Update2: Stumbled upon ptp's testplugin on github and creating a ConfigForm.cs using it as my example.


ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

#1  

That is a neat goal! I took the lazy way and just added a plan button to make configuration forms.

Does there appear to be a big difference or advantage?

PRO
USA
#2  

I have been working on a robot brain database and with this plugin I hope to have one variable to send the SQL query and a variable array for the returned data. Then do all the coding in ARC. One of the first things I am going to try is to put in the database an excel spreadsheet of data I have of music. This spreadsheet has every song that hit the top 100, how long it charted, who wrote it, the artist, flip side, album, ..... from 1890 to 2011. (The Whitburn project).

But not being a .net programmer, the work is slow. My programming skills came from my work with Z80 assembly language, GWBasic, VBScript and Arduino C++ and of course ARC.

But with the help of the Community and Google, I think I can do it.

PRO
Synthiam
#3  

Take a look at creating your own functions by extending EZ-Script capability.

Then you could have something like....


$id = 3
$x = QuerySingle("Select column from mytable where id = " + $id)

or return an array like..


$x = QueryArray("Select * from mytable")

Look at this example in the plugin tutorial: https://synthiam.com/Community/Tutorials/146/23

PRO
USA
#4  

@Dj Oh I like that idea, time for another cup of java and go thru this tutorial. I might be in over my head (as I usually am) with this database brain idea. I currently have a script running populating the database with every word in the english language.

Thank you DJ, I was hoping you would post something.

PRO
USA
#5  

Ok new plan, thank you again DJ. Plugin that adds 2 new EZ-Script commands. DSNConnect and QueryDB


# First parameter is the DSN name, the second is 1 = open, 0 = close
# Returns 1 if no error
$X = DsnConnect("DSN Name", 1)  

#Always returns an array
#Syntax depends on the database and DSN driver
$x = QueryDB("Select * from table where ...")

#6  

Thanks for writing this. Creating a database plugin is on my long list of things I will probably never get to, but there are so many potential uses for it.

Alan

PRO
USA
#7  

@DJ Or anyone else who has the answer

Ok I think I am close but need a little help; Once the DSNConnect("DSNName", 1) is executed and I am ready to do a Query

How can I reference in my code the DSNName variable? Consider the following code. The line 5 from the bottom cn = new OdbcConnection("dsn=" + myDSN); The myDSN variable will not be defined. That parameter was supplied with the DSNConnect() command.


 // Check if the function is our function (SetColor)
            if (e.Name.Equals("DSNConnect", StringComparison.InvariantCultureIgnoreCase))
            {

                // Check if the correct number of parameters were passed to this function
                if (e.Parameters.Length != 2)
                    throw new Exception("Expects 2 parameters. Usage: DSNConnect(''DSN Name'', 1)");


                // Do something
                byte myDSN = Convert.ToString(e.Parameters[0]);
                byte myconstat = Convert.ToByte(e.Parameters[1]);
                if (e.Parameters[1].Equals(1))
                {

                    OdbcConnection cn;
                    cn = new OdbcConnection("dsn=" + myDSN);
                    cn.Open();

                    // Return something. Good idea to return TRUE if your function isn't meant to return anything
                    e.ReturnValue = true;
                }
                else
                {
                    OdbcConnection cn;
                    cn = new OdbcConnection("dsn=" + myDSN);
                    cn.Close();

                    // Return something. Good idea to return TRUE if your function isn't meant to return anything
                    e.ReturnValue = true;
                }
            }
            if (e.Name.Equals("QueryDB", StringComparison.InvariantCultureIgnoreCase))
            {
                string mySQL = Convert.ToString(e.Parameters[0]);
                OdbcCommand cmd;
                OdbcConnection cn;
                cn = new OdbcConnection("dsn=" + myDSN);
                cmd = new OdbcCommand(mySQL, cn);
                e.ReturnValue = true;
            }
            return;

Azerbaijan
#8  

thank you for the information for my final assignment