Global Data Structures

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
dthomas
Posts: 14
Joined: Tue Jun 11, 2019 6:06 pm

Global Data Structures

Post by dthomas »

Is there a way to define a global data structure like a hash table that can be used over multiple screens or do you have to use a fb or flat files to store info and read in and parse for each screen.

User avatar
Russ C.
Posts: 213
Joined: Thu Nov 16, 2017 3:32 pm
Contact:

Re: Global Data Structures

Post by Russ C. »

I would do this using a script module.

Making everything public then accessing each property as ScriptModule1.<Property> on the other screens
Best regards,

Russ
(801) 708-6690
Technical Support
Contact Us

Beijer Electronics AB
http://www.beijerelectronics.us

dthomas
Posts: 14
Joined: Tue Jun 11, 2019 6:06 pm

Re: Global Data Structures

Post by dthomas »

I have added a script module and I am just trying to test some things - and see what I can output to test what I am getting and setting. For now I am using the most basic type of an output test via a MessageBox. Right now my Script Looks like this:

Code: Select all

namespace Neo.ApplicationFramework.Generated
{
    using System.Windows.Forms;
    using System;
	using System.Collections;
    using System.Drawing;
    using Neo.ApplicationFramework.Tools;
    using Neo.ApplicationFramework.Common.Graphics.Logic;
    using Neo.ApplicationFramework.Controls;
    using Neo.ApplicationFramework.Interfaces;
    
    
    public partial class CheckedInList
    {
		public static void MakeTable() {

			string test = "This is a test";
			MessageBox.Show(test);
			
		}
    }
}
When I link this to a button for action and try to run the code - it starts to build and then throws and Event Error with Log - I open the log and I find

Unable to load DLL 'BeHwApi.dll'

and:
2019-06-12 14:36:09,809 [1] FATAL Neo.ApplicationFramework.Common.Runtime.GlobalsBase - Unhandled Exception causing shutdown.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Neo.ApplicationFramework.Tools.License.LicenseServiceCF.k()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Neo.ApplicationFramework.Common.Utilities.WindowThreadHelper.a(Delegate A_0, Object[] A_1)
at Neo.ApplicationFramework.Common.Utilities.WindowThreadHelper.InvokeSynchronized(Delegate method, Object[] args)
at Neo.ApplicationFramework.Common.Utilities.NeoApplication.InvokeSynchronized(Delegate method, Object[] args)
at Neo.ApplicationFramework.Common.Utilities.NeoApplication.InvokeSynchronized(Delegate method)
at Neo.ApplicationFramework.Common.Utilities.NeoApplication.InvokeSynchronized(Action method)
at Neo.ApplicationFramework.Tools.License.LicenseServiceCF.z(Object A_0, EventArgs`1 A_1)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at System.EventHandlerExtensions.Fire[T](EventHandler`1 handler, Object sender, T e)
at Core.Component.Engine.Instantiation.RootComponentService.Start()
at Core.Component.Engine.Instantiation.RootComponentService.Core.Component.Engine.Instantiation.IRootComponentServiceSetup.Start()
at Neo.ApplicationFramework.Common.Runtime.GlobalsBase.Go(String executingAssemblyName, String executablePath, String[] args, String[] designersToCreate, String[] preloadScreenList, Func`1 startupobjectProvider)
2019-06-12 14:36:16,830 [1] ERROR Neo.ApplicationFramework.Tools.Backlight.BacklightController - Failed to find registryKey HKEY_CURRENT_USER\ControlPanel\backlight
2019-06-12 14:36:25,664 [1] FATAL Neo.ApplicationFramework.Common.Runtime.GlobalsBase - Unhandled Exception causing shutdown.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Neo.ApplicationFramework.Tools.License.LicenseServiceCF.k()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Neo.ApplicationFramework.Common.Utilities.WindowThreadHelper.a(Delegate A_0, Object[] A_1)
at Neo.ApplicationFramework.Common.Utilities.WindowThreadHelper.InvokeSynchronized(Delegate method, Object[] args)
at Neo.ApplicationFramework.Common.Utilities.NeoApplication.InvokeSynchronized(Delegate method, Object[] args)
at Neo.ApplicationFramework.Common.Utilities.NeoApplication.InvokeSynchronized(Delegate method)
at Neo.ApplicationFramework.Common.Utilities.NeoApplication.InvokeSynchronized(Action method)
at Neo.ApplicationFramework.Tools.License.LicenseServiceCF.z(Object A_0, EventArgs`1 A_1)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at System.EventHandlerExtensions.Fire[T](EventHandler`1 handler, Object sender, T e)
at Core.Component.Engine.Instantiation.RootComponentService.Start()
at Core.Component.Engine.Instantiation.RootComponentService.Core.Component.Engine.Instantiation.IRootComponentServiceSetup.Start()
at Neo.ApplicationFramework.Common.Runtime.GlobalsBase.Go(String executingAssemblyName, String executablePath, String[] args, String[] designersToCreate, String[] preloadScreenList, Func`1 startupobjectProvider)
at Neo.ApplicationFramework.Generated.Globals.Main(String[] args) in c:\Users\dallas.thomas\Desktop\SimpleSerialCom402\BuildFiles\SimpleSerialCom402.cs:line 286
I have tried to trace this down - and all I can think is that IX Developer has an issue with MessageBox.Show - however I am not sure why that is the case.

Any help would be very much appreciated as I would prefer to use this for quick debugging rather than creating a box on the screen and a tag that links to it. Unless there is a way to output results to output that is.

Thanks

dthomas
Posts: 14
Joined: Tue Jun 11, 2019 6:06 pm

Re: Global Data Structures

Post by dthomas »

Ok so I see that it is my function declaration that is causing the problem. Is there a way to create your own function declarations that will not cause an error when building?

My thought process was I could have 4 functions within the script, one for creation of a data structure, one for modification and 2 for different types of access and deletion.

Actions that call the script and the specific module would be attached to a button click on a screen. This of course does not work if I am unable to create my own function/module.

User avatar
Russ C.
Posts: 213
Joined: Thu Nov 16, 2017 3:32 pm
Contact:

Re: Global Data Structures

Post by Russ C. »

You can create a button click event on a screen and copy and paste the function into your script like:

Code: Select all

public void Btn_Click(System.Object sender, System.EventArgs e)
{
   // do stuff here
}
and you can hook it up in code like

Code: Select all

void SomeFunction()
{
   Button.Click += Btn_Click;
}

or hooking a button on a screen up to a function in a script module like:

Code: Select all

void Screen_Opened(System.Object sender, System.EventArgs e)
{
   Button.Click += ScriptModule1.Btn_Click;
}

Just make sure to unhook the even on a screen closed to prevent multiple function calls the next time the screen is opened.

This can be done like:

Code: Select all

void Screen_Closed(System.Object sender, System.EventArgs e)
{
   Button.Click -= ScriptModule1.Btn_Click;
}
Best regards,

Russ
(801) 708-6690
Technical Support
Contact Us

Beijer Electronics AB
http://www.beijerelectronics.us

dthomas
Posts: 14
Joined: Tue Jun 11, 2019 6:06 pm

Re: Global Data Structures

Post by dthomas »

Ok, so I think I understand this and yet I am running into errors. More specifically when I try to build the code I am getting:
'Neo.ApplicationFramework.Generated.Confirmation' does not contain a definition for 'Button.Click' and no extension method 'Button.Click' accepting a first argument of type 'Neo.ApplicationFramework.Generated.Confirmation' could be found...
So I have a Screen called Confirmation - in the script I have:

Code: Select all

void Confirmation_Opened(System.Object sender, System.EventArgs e)
{
    ..... some code
    .....

    Button.Click += ScriptModule1.Btn_Click;
}

void Confirmation_Closed(System.Object sender, System.EventArgs e)
{
    Button.Click -= ScriptModule1.Btn_Click;
}
And in ScriptModule I have:

Code: Select all

public void Btn_Click()
{
    ..... some code
}
I am sure I am missing something stupid that I should not be missing at all.

I then tried modifying Btn_Click in ScriptModule to include the System arguments and in Confirmation I removed the Button_Click += from the Screen_Opened hook and tried to create:

Code: Select all

void somefunction ()
{
   Button.Click += Btn_Click;
}
I also removed the screen closed hook in confirmation. When I try to build I get the same error as before but I also get an error:
The name 'Btn_Click' does not exist in the current context
This one is rather straightforward as Btn_Click is local to ScriptModule.

dthomas
Posts: 14
Joined: Tue Jun 11, 2019 6:06 pm

Re: Global Data Structures

Post by dthomas »

Of course after I type this big response I try something else that seems to work.

I went back in to Scriptmodule and removed system args from function definition. Then I went back to Confirmation screen and in the hook for Button_Click I just called Scriptmodule.function, and everything built fine.

I am however not doing the
Button.Click += Btn_Click;
Am is missing something by not doing this?

User avatar
Russ C.
Posts: 213
Joined: Thu Nov 16, 2017 3:32 pm
Contact:

Re: Global Data Structures

Post by Russ C. »

dthomas wrote:
Button.Click += Btn_Click;
Am is missing something by not doing this?

Nope, adding it to the actions of the button should do the same thing. So if its working, you should be good. :)
Best regards,

Russ
(801) 708-6690
Technical Support
Contact Us

Beijer Electronics AB
http://www.beijerelectronics.us

dthomas
Posts: 14
Joined: Tue Jun 11, 2019 6:06 pm

Re: Global Data Structures

Post by dthomas »

All good now thanks for the help :D

Now I just have to figure out how to change the .NET framework this project is using. 2.40 SP2 from what I read should support at least 4.6.1 and yet right now it is only using 4.0.

Post Reply